akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
   i64 N,M; cin>>N>>M;
   cout<<abs((N-2)*(M-2))<<endl;
}


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

    ll i,j,k,n,x,y;
    map<ll,ll>m;
    vector<ll>v;
    cin>>n>>k;
    for(i=0;i<k;i++)
    {
        cin>>x;
        while(x--)
        {
            cin>>y;
            m[y]++;
        }
    }
    ll c=0;
    for(i=1;i<=n;i++)
    {
        if(m[i]==0)
            c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3608
using System;
class _0110 {
    static int Parse(string s) {
        int res = 0, b = 1;
        for(int i = s.Length-1; i >= 0; i--) {
            res += (s[i] - '0') * b;
            b *= 10;
        }
        return res;
    }
    public static void Main() {
        string str;
        char c;

        while ((str = Console.ReadLine()) != null) {
            for (c = '0'; c <= '9'; c++) {
                string cExpr = str.Replace('X', c);
                string[] strs = cExpr.Split('+', '=');
                if (c == '0' && ((strs[0].Length > 1 && strs[0][0] == '0') || (strs[1].Length > 1 && strs[1][0] == '0') || (strs[2].Length > 1 && strs[2][0] == '0'))) continue;
                if (Parse(strs[0]) + Parse(strs[1]) == Parse(strs[2])) {
                    Console.WriteLine(c);
                    break;
                }
            }
            if (c == ('9' + 1)) Console.WriteLine("NA");
        }
    }
}

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

#define int long long
typedef pair<double, int> P;
const int INF = 1e16;

double S(int k) {
  int sum = 0;
  int t = k;
  while ( t ) {
    sum += t%10;
    t /= 10;
  }

  return (double)k/(double)sum;  
}

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

  vector<int> candi; // snuke number の候補
  for ( int i = 1; i < 10; i++ ) candi.push_back(i);  

  int a = 10;
  while ( a < INF ) {
    for ( int i = 0; i < 1000; i++ ) {
      int b = a*i+a-1;      
      candi.push_back(b);      
    }
    a *= 10;
  }

  sort(candi.begin(), candi.end());
  candi.erase(unique(candi.begin(), candi.end()), candi.end());

  double mi = (double)INF;
  vector<int> snukes;  
  for ( int i = (int)candi.size()-1; i >= 0; i-- ) {
    if ( mi >= S(candi[i]) ) {      
      mi = S(candi[i]);      
      if ( i < (int)candi.size()-100 ) snukes.push_back(candi[i]);      
    }
  }  

  reverse(snukes.begin(), snukes.end());  
  for ( int i = 0; i < K; i++ ) {
    cout << snukes[i] << endl;
  }
  
  return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int k,a,now_max=2, now_min=2;
vector<int> v;

signed main() {
    cin >> k;
    rep(i,k) {
        cin >> a;
        v.pb(a);
    }
    reverse(all(v));
    for(auto i : v) {
        int tmp = (i+now_min-1)/i*i;
        if (now_min <= tmp && tmp <= now_max) {
            now_min = tmp;
            now_max = now_max/i*i+i-1;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << now_min << " " << now_max << endl;
}





Measured memory_bytes: 1400
#include<cstdio>

using namespace std;
using ll=long long;


int main(void)
{
	char a[200000+2];

	while(scanf("%[a-z]\n", a)==1)
	{
		int c[256]={};
		int l=0;

		for(int i=0;a[i];i++)
		{
			c[a[i]]++;
			l++;
		}

		ll ans=1;
		for(int i=0;a[i+1];i++)
		{
			l--;
			c[a[i]]--;
			ans+=l-c[a[i]];
		}
		printf("%lld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 384
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v: Vec<usize> = read_vec();
    let (n, x) = (v[0], v[1]);
    let mut s = read_vec::<usize>();
    s.sort();
    s.reverse();

    let big_int: u64 = 1000_000_000 + 7;
    let mut dp = vec![0u64; x + 1];
    dp[x] = 1;
    for si in 0..s.len() {
        let snum = s[si];
        let mut new_dp = vec![0; x + 1];
        for xnum in 0..x + 1 {
            new_dp[xnum] += dp[xnum] * (n - si - 1) as u64;
            new_dp[xnum] %= big_int;

            new_dp[xnum % snum] += dp[xnum];
            new_dp[xnum % snum] %= big_int;
        }
        dp = new_dp;
    }
    let mut ans = 0u64;
    for i in 0..dp.len() {
        ans += i as u64 * dp[i];
        ans %= big_int;
    }
    println!("{0}", ans);
}


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

#define nums(a) (int)(unsigned char)s[a]
#define REP(i,a,b)	for(int i=(a);i<(b);i++)

int main()
{
	char s[100009];
	cin >> s;
	int k;
	cin >> k;
	int len = strlen(s);

	REP(i,0,len){
		if(123 - nums(i) <= k && nums(i)!= 97){
			k = k- 123 + nums(i);
			s[i]= 97; 
			
		}
		if(i == len-1){
			s[i]= s[i]+ k%26; 
			if(nums(i) > 122 ) s[i] = s[i]-26;
		}
	}

	REP(i,0,len) cout << s[i] ;
	cout << endl;
	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long LL;
#define M(a,b) memset(a,b,sizeof(a))
#define pb push_back
const int maxn = 100000+10;
const LL mod = 1000000007;
struct Node {
    int l,r;
    bool operator < (const Node &a)const {
        return (r-l+1)<(a.r-a.l+1);
    }
}s[maxn+(maxn<<1)];
vector<int>g[maxn];
int c[maxn];
int n,m;
void add(int l,int r) {

    while(l<=m) {
        ++c[l];
        l+=l&(-l);
    }
    while(r<=m) {
        --c[r];
        r+=r&(-r);
    }
    return ;
}
int query(int i) {

    int res=0;
    while(i) {
        res+=c[i];
        i-=i&(-i);
    }
    return res;
}
int main() {

    M(c,0);
    scanf("%d%d",&n,&m);
    for (int i=0;i<=m;++i) {
        g[i].clear();
    }
    for (int i=1;i<=n;++i) {
        scanf("%d%d",&s[i].l,&s[i].r);
        int len=s[i].r-s[i].l+1;
        g[len].pb(i);
    }
    for(int i=1;i<=m;++i) {
        int ans=0;
        for (int j=0;j<g[i].size();++j) {
            int &pos=g[i][j];
            add(s[pos].l,s[pos].r+1);
        }
        for (int j=i;j<=m;j+=i) {
            ans+=query(j);
        }
        n-=g[i].size();
        printf("%d\n",ans+n);
    }
    return 0;
}

Measured memory_bytes: 9088
#include <iostream>

using namespace std;

int main(){
  int a,b,x,s;
  int c[10]={0};
  while(cin>>a>>b>>x){
    c[a-1]++;c[b-1]++;c[x-1]++;
    s=0;
    for(int i=20-a-b;i<10;i++){
      if(c[i]==0) s++;
    }
    if(s/7.0<0.5) cout<<"YES";
    else cout<<"NO";
    cout<<endl;
    c[a-1]--;c[b-1]--;c[x-1]--;
  }
  return 0;
}

Measured memory_bytes: 1152
N, M = map(int, input().split())
keep = [[] for i in range(N)]
keep2 = []


for i in range(M):
    p, y = map(int, input().split())
    keep[p - 1].append([i, p, y])


for i in range(N):
    keep[i] = sorted(keep[i], key=lambda x: x[2])

for i in range(N):
    biggest = len(keep[i])
    j = 0
    while j < biggest:
        keep[i][j][2] = j + 1
        j += 1
    keep2 += keep[i]

keep2 = sorted(keep2, key=lambda x: x[0])

for i in range(M):
    ans = ''
    ans += '0' * (6 - len(str(keep2[i][1]))) + str(keep2[i][1])
    ans += '0' * (6 - len(str(keep2[i][2]))) + str(keep2[i][2])
    print(ans)


Measured memory_bytes: 41368
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	
 
const ll mod=1e9+7;
const int INF=INT_MAX/2;

int main(){
	ll n,m;
	cin>>n>>m;
	ll a[m];
	ll sum=0;
	REP(i,m){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>n)cout<<-1<<endl;
	else cout<<n-sum<<endl;
}
 

Measured memory_bytes: 3716
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_C&lang=jp
sample_input = list(range(3))
sample_input[0] = '''5
H4 C9 S4 D2 C3'''
sample_input[1] = '''2
S1 H1'''
sample_input[2] = '''5
H4 C9 S4 D2 C3'''
give_sample_input = None
if give_sample_input is not None:
    sample_input_list = sample_input[give_sample_input].split('\n')
    def input():
        return sample_input_list.pop(0)
        
# main
import copy

def swap_list_item(lst, i, j):
    tmp = lst[i]
    lst[i] = lst[j]
    lst[j] = tmp
    
class Card:
    number = None
    mark = None
    def __init__(self, str_card):
        self.number = int(str_card[1])
        self.mark = str_card[0]
        pass
    def __eq__(self, other):
        return self.number == other.number
    def __lt__(self, other):
        return self.number < other.number
    def to_str(self):
        return self.mark + str(self.number)

def selection_sort(list_of_data):
    num_of_data = len(list_of_data)
    for i in range(num_of_data):
        minj = i
        for j in range(i, num_of_data):
            if list_of_data[minj] > list_of_data[j]:
                minj = j
        if not minj == i:
            swap_list_item(list_of_data, i, minj)
            
def bubble_sort(list_of_data):
    flag = True
    while flag:
        flag = False
        n = num_of_data - 1
        while n >= 1:
            if list_of_data[n] < list_of_data[n-1]:
                swap_list_item(list_of_data, n, n-1)
                flag = True
            n -= 1
        
def get_mark_order_info(card_list, number):
    result = ''
    for card in card_list:
        if card.number == number:
            result += card.mark
    return result

def print_card_list(card_list):
    output = ''
    for card in card_list:
        output += card.to_str() + ' '
    output = output.rstrip()
    print(output)

num_of_data = int(input())
data_list_str = input().split()
data_cards = [Card(str) for str in data_list_str]
data_cards_bubble = copy.copy(data_cards)
data_cards_selection = copy.copy(data_cards)

mark_order_info = []
for number in [n+1 for n in range(13)]:
    mark_order_info.append(get_mark_order_info(data_cards, number))
    
bubble_sort(data_cards_bubble)
selection_sort(data_cards_selection)

mark_order_info_bubble = []
for number in [n+1 for n in range(13)]:
    mark_order_info_bubble.append(get_mark_order_info(data_cards_bubble, number))

mark_order_info_selection = []
for number in [n+1 for n in range(13)]:
    mark_order_info_selection.append(get_mark_order_info(data_cards_selection, number))
    
print_card_list(data_cards_bubble)
if (mark_order_info == mark_order_info_bubble):
    print('Stable')
else:
    print('Not stable')
    
print_card_list(data_cards_selection)
if (mark_order_info == mark_order_info_selection):
    print('Stable')
else:
    print('Not stable')

Measured memory_bytes: 8232
S = raw_input()
T = raw_input()
m = len(S)
n = len(T)
ans = "UNRESTORABLE"
for i in range(m-n, -1, -1):
    ok = True
    for j in range(n):
        if not ((S[i+j] == T[j]) or (S[i+j] == '?')):
            ok = False
            break
    if ok:
        s = ""
        for j in range(m):
            if i <= j < i+n:
                s += T[j-i]
            elif S[j] == '?':
                s += 'a'
            else:
                s += S[j]
        ans = s
        break
print ans

Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

template<typename Monoid>
struct SegmentTree{
    using F = function<Monoid(Monoid, Monoid)>;

    int sz;
    vector<Monoid> seg;

    const F f;      // モノイドに対して二項演算を行う関数オブジェクト
    const Monoid M1;

    SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1){
        sz = 1;
        while(sz < n)   sz <<= 1;
        seg.assign(2 * sz, M1);
    }

    void set(int k, const Monoid &x){
        seg[k + sz] = x;
    }

    void build(){
        for(int k = sz - 1; k > 0; --k){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    void update(int k, const Monoid &x){
        k += sz;
        seg[k] = x;
        while(k >>= 1){
            seg[k] = f(seg[k << 1], seg[k << 1 | 1]);
        }
    }

    Monoid query(int a, int b){
        Monoid L = M1, R = M1;
        for(a += sz, b += sz; a < b; a >>= 1, b >>= 1){
            if(a & 1)   L = f(L, seg[a++]);
            if(b & 1)   R = f(seg[--b], R);
        }
        return f(L, R);
    }

    Monoid operator[](const int &k) const{
        return seg[k + sz];
    }
};

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

    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    map<int, vector<int>> pos;
    SegmentTree<int> seg(n, [](int a, int b){return min(a, b);}, INF);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        seg.set(i, a[i]);
        pos[a[i]].push_back(i);
    }
    seg.build();
    
    vector<int> dp(n);
    dp[0] = 0;
    int maxsales = 0;
    for(int i = 1; i < n; ++i){
        int foo = seg.query(0, i);
        dp[i] = max(0, a[i] - foo);
        chmax(maxsales, dp[i]);
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(dp[i] == maxsales)   ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 13056
n = gets.to_i
a = n.times.map{gets.split.map(&:to_i)}
sum = 0
n.times do |i|
    sum += a[i][0]
end
b = sum
n.times do |i|
    b = a[i][1] if a[i][0] > a[i][1] && b > a[i][1]
end
puts sum-b

Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  vector<int> b(a);
  for (int i = 0; i < a; i++) {
    cin >> b.at(i);
  }
  int kaunto = 0;
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < a; j++) {
      if (i != j) {
      kaunto += b.at(i) * b.at(j);
      }
    }
  }
  cout << kaunto / 2 << endl;
}

Measured memory_bytes: 3536
# -*- coding: utf-8 -*-
n = int(input())
h = list(map(int, input().split()))

import numpy as np

h.append(0)
h_np = np.array(h)
water_counter = 0
while True:
    h_np -= 1
    water = h_np >= 0
    if True not in water:
        break
    change_counter = 0
    for i in range(1, n+1):
        if water[i-1] != water[i]:
            change_counter += 1
    water_counter += (change_counter+water[0]) // 2

print(water_counter)

Measured memory_bytes: 14436
i = 0
a = []
while True:
    x = raw_input().split()
    if int(x[0]) == 0 and int(x[1]) == 0:
        break
    else:
        if int(x[0])>int(x[1]):
            x[0],x[1]=x[1],x[0]
        a.append(x)


for j in range(len(a)):
    print " ".join(a[j])
    

Measured memory_bytes: 6788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,k;
/* 8 4 2 6
16  4 8 16 32  
2+4;*/
int main()
{
	ll i=0;
	cin>>a>>b>>c>>k;
	while(a>=b)
	{
		i++;
		b=b*2;
	}
	while(c<=b)
	{
		i++;
		c=c*2;
	}
	//cout<<a<<" "<<b<<"  "<<c<<endl;
	if(i<=k)
	cout<<"Yes";
	else
	cout<<"No";
	//cout<<i;
	
}

Measured memory_bytes: 3616
#include <iostream>

using namespace std;

int main(){
  int n;
  string a,b,c;
  cin>>n>>a>>b>>c;
  int ans=0;
  for(int i=0;i<n;i++)ans+=(1+(a[i]!=b[i])+(b[i]!=c[i])+(c[i]!=a[i]))/2;
  cout<<ans<<"\n";
}

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

int main(){

int n;

cin >> n;
    set<int> s;
    for(int i=0; i < n; i++) {
        int x; cin >> x;
 
        if (s.count(x)) s.erase(x);
        else s.insert(x);

        
    }
    cout << s.size() << endl;

}

Measured memory_bytes: 4864
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N;
int x[100], y[100];

int main() {
    cin >> N;
    for (int j = 0; j < N; ++j) cin >> x[j] >> y[j];

    vector<vector<vector<pair<double, double>>>> rg(N);

    for (int j = 0; j < N; ++j) {
        for (int k = j+1; k < N; ++k) {
            double hx = -(y[j] - y[k]), hy = x[j] - x[k];
            complex<double> c(hx, hy);
            double a1 = arg(c);

            vector<pair<double, double>> vec1, vec2;
            if (a1 < 0) {
                vec1.emplace_back(a1+M_PI, a1+2*M_PI);

                vec2.emplace_back(0, a1+M_PI);
                vec2.emplace_back(a1+2*M_PI, 2*M_PI);
            } else {
                vec1.emplace_back(0, a1);
                vec1.emplace_back(a1+M_PI, 2*M_PI);

                vec2.emplace_back(a1, a1+M_PI);
            }

            rg[j].push_back(vec1);
            rg[k].push_back(vec2);
        }
    }

    cout << fixed << setprecision(10) << endl;
    for (int j = 0; j < N; ++j) { sort(begin(rg[j]), end(rg[j])); }
    for (int j = 0; j < N; ++j) {
        vector<pair<double, double> > res;
        res.emplace_back(0, 2 * M_PI);
        for (vector<pair<double, double> > vec : rg[j]) {
            vector<pair<double, double> > nxt;
            for (auto r1 : res) {
                for (auto r2 : vec) {
                    if (max(r1.first, r2.first) >= min(r1.second, r2.second)) continue;
                    nxt.emplace_back(max(r1.first, r2.first), min(r1.second, r2.second));
                }
            }
            res = nxt;
        }

        double prob = 0;
        for (auto pr : res) {
            prob += (pr.second - pr.first) / (2 * M_PI);
        }
        cout << prob << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

char a[3] = {'.','#'};

string answer() {
    string s; cin >> s;

    if (s == "end") {
        exit(0);
    }

    return s;
}

signed main()
{ // #define int long long をしてるのでscanfを使うと意味不明な値が入力され死にます
    int N; cin >> N;

    string S[2];

    bool r = true; // 右に伸ばしているか

    while (true) {
        if (r) {
            bool f = true;

            S[0] += ' ';
            S[1] += ' ';

            int pos = S[0].size() - 1;

            rep(i, 2) rep(j, 2) {
                S[0][pos] = a[i];
                S[1][pos] = a[j];

                cout << S[0] << endl;
                cout << S[1] << endl;

                string ans = answer();

                if (ans == "T") {
                    goto nxt1;
                }
            }

            S[0] = S[0].substr(0, S[0].size() - 1);
            S[1] = S[1].substr(0, S[1].size() - 1);

            r = false;
nxt1:;
        } else {
            bool f = true;

            string T[2];

            T[0] += ' ';
            T[0] += S[0];
            T[1] += ' ';
            T[1] += S[1];

            rep(i, 2) rep(j, 2) {
                T[0][0] = a[i];
                T[1][0] = a[j];

                cout << T[0] << endl;
                cout << T[1] << endl;

                string ans = answer();

                if (ans == "T") {
                    goto nxt2;
                }
            }

            break;
nxt2:;
            S[0] = T[0];
            S[1] = T[1];
        }
    }

    cout << S[0] << endl;
    cout << S[1] << endl;

    string s; cin >> s;
}


Measured memory_bytes: 596
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		//????????????????????????
		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		
		//?????????
		String[] arrayString = bf.readLine().split(" ");
		
		//Stack
		Stack stack=new Stack();
		
		for(int i=0;i<arrayString.length;i++){
			String str=arrayString[i];
			if(str.equals("+")){
				stack.push(stack.pop()+stack.pop());
			}else if(str.equals("-")){
				int a=stack.pop();
				int b=stack.pop();
				stack.push(b-a);
			}else if(str.equals("*")){
				stack.push(stack.pop()*stack.pop());
			}else{
				stack.push(Integer.parseInt(str));
			}
		}
		
		System.out.println(stack.pop());
	}

}
class Stack{
	ArrayList<Integer> array;
	
	public Stack(){
		array=new ArrayList<Integer>();
	}
	
	public void push(int i){
		array.add(i);
	}
	
	public int pop(){
		int result=array.get(array.size()-1);
		array.remove(array.size()-1);
		return result;
	}
}

Measured memory_bytes: 24304
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
		int n;	cin >> n;
	string s;	cin >> s;
	if(n&1)
		return cout << "No", 0;
	string t = s.substr(0, n/2);
	t += t;
	if(s == t)
		cout << "Yes";
	else
		cout << "No";	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int r, g, b, n;
    cin >> r >> g >> b >> n;

    int count = 0;
    for(int i=0; i<=n; i+=r){
        for(int j=0; i+j<=n; j+=g){
            int tmp = n - (i + j);
            if(tmp%b == 0 && tmp >= 0){
                count++;
            }
        }
    }
    cout << count;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int v[100],c[100],s=0; 
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	for(int i=0;i<n;i++){
		cin>>c[i];
		if(v[i]>c[i]){
			s=s+v[i]-c[i];
		}
	}
	if(s==0)cout<<"0";
	else cout<<s;
} 

Measured memory_bytes: 256
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int n = Reader.NextUInt;
        int last = 0;
        int cur = 0;
        int max = 0;
        for (int i = 0; i < n; i++)
        {
            var h = Reader.NextUInt;
            if (last >= h) max = Max(max, ++cur);
            else cur = 0;
            last = h;
        }
        Console.WriteLine(max);
    }
}

static class Reader
{
    const int BUF_SIZE = 1 << 13;
    static Stream Stream;
    static byte[] buffer = new byte[BUF_SIZE];
    static int ptr = 0;
    static Reader() { Stream = Console.OpenStandardInput(); }

    private static void Read()
    {
        Stream.Read(buffer, 0, BUF_SIZE);
    }

    private static byte Next { get { if (ptr == buffer.Length) { Read(); ptr = 0; } return buffer[ptr++]; } }

    public static int NextUInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; byte next;
            do { next = Next; } while (next < 48);
            do { res = res * 10 + next - 48; next = Next; } while (48 <= next);
            return res;
        }
    }
}


Measured memory_bytes: 13140
# https://beta.atcoder.jp/contests/abc099/tasks/abc099_b
# B - Stone Monument

# B_Stone_Monument.py

height_west, height_east = map(int, input().strip().split(" "))

num_east = height_east - height_west

real_height_east = 0
for i in range(1, num_east+1):
    real_height_east += i

print(real_height_east - height_east)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    
    static Scanner cin = new Scanner();
    static void Main() {
        int N = cin.Int();
        string s = Console.ReadLine();
        string t = Console.ReadLine();

        int i;
        for (i = N; i >= 0; i--) {
            string tmps = s.Substring(N - i, i);
            string tmpt = t.Substring(0, i);
            if (tmps == tmpt) break;
        }

        Console.WriteLine(2 * N - i);
        Console.ReadLine();
    }
}

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

int main(){
  long n = 0;
  long m = 0;
  long l[100000] = {};
  long r[100000] = {};
  long L = 0;
  long R = 0;
  long i = 0;
  scanf("%ld %ld",&n,&m);
  for(i=0;i<m;i++){
    scanf("%ld %ld",&l[i],&r[i]);
  }
  L = 0;
  R = n+2;
  for(i=0;i<m;i++){
    if(L < l[i]){
      L = l[i];
    }
    if(r[i] < R){
      R = r[i];
    }
  }
  if(R-L>=0){
    printf("%ld",R-L+1);
  }else{
    printf("0");
  }
  //printf("#%ld %ld",L,R);
  return 0;
}
    

Measured memory_bytes: 1664
#include<stdio.h>
#define N 100
#define W 0
#define G 1
#define B 2
int n,m[N][N];
int c[N],d[N],f[N],g;
void in(){
  int a,b,c,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      m[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&a,&b);
    a--;
    for(j=0;j<b;j++){
      scanf("%d",&c);
      c--;
      m[a][c]=1;
    }
  }
}
void visit(int x){
  int y;
  c[x]=G;
  d[x]=++g;
  for(y=0;y<n;y++){
    if(m[x][y]==0)continue;
    if(c[y]==W){
      visit(y);
    }
  }
  c[x]=B;
  f[x]=++g;
}
void dfs(){
  int x;
  for(x=0;x<n;x++)c[x]=W;
  g=0;
  for(x=0;x<n;x++)if(c[x]==W)visit(x);
  for(x=0;x<n;x++)printf("%d %d %d\n",x+1,d[x],f[x]);
}
int main(){
  in();
  dfs();
  return 0;
}



Measured memory_bytes: 2112
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

min=0

if a<0 :
    aa=-1*a
    min+=aa*c+d+b*e
elif a==0 :
    min+=c+b*e
else :
    min+=(b-a)*e

print(min)


Measured memory_bytes: 5588
#include<bits/stdc++.h>
#include<atcoder/mincostflow>

using namespace std;
using ll = long long;
inline int ri() { int n; cin >> n; return n;}
const ll INF = 1e18;


int main()
{
    int n, k; cin >> n >> k;
    vector<vector<int>> a(n, vector<int>(n));
    for(int i = 0; i < n; i++)for(int j = 0; j < n; j++)cin >> a[i][j];
    atcoder::mcf_graph<int, ll> mf(2 * n + 2);
    int S = 2 * n, T = 2 * n + 1;
    mf.add_edge(S, T, n * k, INF);

    for(int i = 0; i < n; i++) {
        mf.add_edge(S, i, k, 0);
        mf.add_edge(i + n, T, k, 0);
    }

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            mf.add_edge(i, j + n, 1, INF - a[i][j]);
        }
    }

    auto p = mf.flow(S, T, n * k);
    vector<atcoder::mcf_graph<int,ll>::edge> v = mf.edges();
    cout << n * k * INF - p.second << endl;

    for(auto e : v) {
        if(e.from == S || e.to == T)continue;
        if(e.flow == 1) {
            a[e.from][e.to - n] = -1;
        }
    }


    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++)cout << (a[i][j] == -1 ? "X" : ".") << (j == n - 1 ? "\n" : "");
    }





}

Measured memory_bytes: 3900
#include<stdio.h>
int main(){
  int sx, sy, tx, ty;
  int x, y;//幅を求める
  int i;
  scanf("%d %d %d %d", &sx, &sy, &tx, &ty);
  x = tx-sx;
  y = ty-sy;
  //1回目の移動
  for(i=0; i<x; i++)
    printf("R");
  for(i=0; i<y; i++)
    printf("U");
  for(i=0; i<x; i++)
    printf("L");
  for(i=0; i<y; i++)
    printf("D");
  //2回目の移動
  printf("D");
  for(i=0; i<x+1; i++)
    printf("R");
  for(i=0; i<y+1; i++)
    printf("U");
  printf("L");
  printf("U");
  for(i=0; i<x+1; i++)
    printf("L");
  for(i=0; i<y+1; i++)
    printf("D");
  printf("R\n");
  return 0;
}
  

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String sd = sc.next();
		String t = sc.next();
		
		ArrayList<String> ss = new ArrayList<String>();
		for(int i = 0; i < sd.length() - t.length() + 1; i++) {
			int j;
			for(j = 0; j < t.length(); j++) {
				if(sd.charAt(i + j) != '?' && sd.charAt(i + j) != t.charAt(j)) {
					break;
				}
			}
			if(j >= t.length()) {
				ss.add((sd.substring(0,  i) + t + sd.substring(i + t.length())).replace('?',  'a'));
			}
		}
		
		if(ss.size() == 0) {
			System.out.println("UNRESTORABLE");
		} else {
			String[] s = new String[50];
			int i = 0;
			for(String str : ss) {
				s[i] = str;
			}
			Arrays.sort(s, 0, i);
			System.out.println(s[0]);
		}		

	}

}


Measured memory_bytes: 21972
#include<iostream>
using namespace std;
typedef long long ll;

const int MAX_N = 1e+5 + 5;

ll X[MAX_N];

int main() {
    int N;
    ll A, B;
    cin >> N >> A >> B;
    for (int i = 0; i < N; i++) cin >> X[i];
    ll ans = 0;
    for (int i = 1; i < N; i++) {
        ans += min(A * (X[i] - X[i - 1]), B);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

ll n,z,w;

int main(void) {
    cin >>n>>z>>w;
    ll score[n];
    ll minmax_a[n],minmax_b[n];
    rep(i,n){
        cin >> score[i];
    }
    if(n==1){
        cout << abs(score[0]-w) << endl;
        return 0;
    }
    // minmax_a[n-1]=abs(score[n-2]-score[n-1]);
    // minmax_b[n-1]=abs(score[n-2]-score[n-1]);
    for(int i=n-1;i>=0;i--){
        ll tmp_a=0,tmp_b=0;
        if(i==0){
            tmp_a=abs(w-score[n-1]);
        }else tmp_a=abs(score[i-1]-score[n-1]);
        for(int j=i+1;j<n;j++){
            tmp_a = max(tmp_a, minmax_b[j]);
        }
        DEBUG{cout << "a : " << tmp_a << endl;}
        minmax_a[i]=tmp_a;
        if(i==0)continue;
        tmp_b = abs(score[i-1]-score[n-1]);
        for(int j=i+1;j<n;j++){
            tmp_b = min(tmp_b, minmax_a[j]);
        }
        DEBUG{cout << "b : " << tmp_b << endl;}
        minmax_b[i]=tmp_b;
    }
    cout << minmax_a[0] << endl;
    return 0;
}


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

template<typename T> 
bool chmin(T& a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<typename T>
bool chmax(T& a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
int inf = 1ll<<30;

int main(){
    int n,w;
    cin>>n>>w;
    vector<int64_t>weight(n);
    vector<int64_t>value(n);
    vector<vector<int64_t>>dp(110,vector<int64_t>(100001));
    for(int i=0;i<n;i++)cin>>weight.at(i)>>value.at(i);
    for(int j=0;j<w+1;j++) if(j-weight.at(0) >= 0) dp.at(0).at(j)=value.at(0);

    for(int i=1;i<n;i++){
        for(int j=0;j<w+1;j++){
            if(j-weight.at(i) >= 0) chmax(dp.at(i).at(j) , dp.at(i-1).at(j-weight.at(i)) + value.at(i));
            chmax(dp.at(i).at(j) , dp.at(i-1).at(j));//　　　ポイント！
        }
    }
    /*for(int i=0;i<n;i++){
        for(int j=1;j<w+1;j++)cout<<dp.at(i).at(j)<<" ";
        cout<<endl;
    }*/

    cout<<dp.at(n-1).at(w)<<endl;
}


Measured memory_bytes: 87296
#include<iostream>
using namespace std;
int num[205];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &num[i]);
	}
	int count = 0;
	int flag = 1;
	for (int i = 0; i < n; i++) {
		if ((num[i] ) & 1) {
			flag = 0;
			break;
		}
	}
	while (flag) {
		count++;
		for (int i = 0; i < n; i++) {
			num[i] >>= 1;
			if (num[i] & 1) {
				flag = 0;
				break;
			}
		}
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>
#include <map>
#include<stack>
#include<fstream>

using namespace std;
const long long INF = 1LL << 60;  // どういう意味だろうか

const string write_file("");

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}



int main() {
	int A, B;

	cin >> A >>B;
	if((B % A) == 0){
		cout << A+B << endl;
	}
	else{
		cout << B - A <<endl;
	}



}


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

int main(){
  int H,W;
  while(1){
    cin >> H;
    cin >> W;
    if(H == 0 && W == 0){
      break;
    }
    for(int i = 0;i < H;i++){
      for(int j = 0;j < W;j++){
        cout<<'#';
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 3084
process.stdin.resume();
process.stdin.setEncoding('utf8');
var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});
reader.on('line', (line) => {
    lines.push(line);
});
reader.on('close', () => {
    const s = lines[0];
    lines.shift();
    const t = lines[0];
    const t1 = t.slice(0, t.length - 1);
    console.log(s === t1 ? "Yes" : "No");
});

Measured memory_bytes: 30072
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
#define MOD 1000000007

int main(){
    int n,m,q;
    cin >> n >> m >> q;
    vector<vi> lr(n+1,vi(n+1));
    rep(i,m){
        int l,r;
        cin >> l >> r;
        lr[l][r]++;
    }
    rep(i,n+1){
        rep(j,n){
            lr[i][j+1]+=lr[i][j];
        }
    }
    rep(i,n+1){
        rep(j,n){
            lr[j+1][i]+=lr[j][i];
        }
    }
    vi ans;
    rep(i,q){
        int x,y;
        cin >> x >> y;
        ans.push_back(lr[y][y]-lr[x-1][y]-lr[y][x-1]+lr[x-1][x-1]);
    }
    for(auto x:ans) cout << x << endl;
}

Measured memory_bytes: 4912
import java.io.IOException;
 
public class Main {
	/**
	* @param args
	*/

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int		n = parseNum();
		int[][]	c = new int[n][2];
		int[][]	d = new int[n][n];

		// カードを取得
		for (int i = 0; i < n; i++) {
			c[i][0] = parseNum();
			c[i][1] = parseNum();
		}

		for (int l = 1; l < n; l++) {
			for (int i = 0; i+l < n; i++) {
				for (int j = i+l, k = i; k < j; k++) {
					int	t = d[i][k]+d[k+1][j]+c[i][0]*c[k][1]*c[k+1][0]*c[j][1];
					d[i][j] = (d[i][j] == 0)?t:Math.min(d[i][j], t);
				}
			}
		}

		System.out.println(d[0][n-1]);
	}
 
	private static int parseNum() {
		try {
			int	buf = 0;
			int	num = 0;
			int	mns = 0;
			int	skp = 1;
 
			// -,0〜9以外は読み飛ばす
			while (true) {
				buf = System.in.read();
				if (buf == '-') {
					mns = 1;
					skp = 0;
				} else if (buf >= '0' && buf <= '9') {
					num = num * 10 + (buf - '0');
					skp = 0;
				} else if (skp == 0) {
					return (mns == 0)?num:num*(-1);
				}
			}
		} catch (IOException e) {}
		return -1;
	}
}

Measured memory_bytes: 19000
h1, h2 = map(int, input().split())
k1, k2 = map(int, input().split())
a, b, c, d = map(int, input().split())

hiroshi = h1*a + h1//10*c + h2*b + h2//20*d
kenjiro = k1*a + k1//10*c + k2*b + k2//20*d

if hiroshi > kenjiro:
    print("hiroshi")
elif hiroshi < kenjiro:
    print("kenjiro")
else:
    print("even")



Measured memory_bytes: 5596
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
typedef long long ll;
const ll MOD = 1e9+7;
int main(int argc,char **argv){
    (void)argc;
    (void)argv;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin>>n;
    ll a[n];
    rep(i,0,n)cin>>a[i];
    ll ans=0;
    rep(i,0,n){
        if(!i){
            ans+=0;
        }else{
            if(a[i-1]>a[i]){
                ans+=a[i-1]-a[i];
                a[i]=a[i-1];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5212
#include <vector>
#include <iostream>
#include <cmath>
#include <numeric>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n,now,tmp;
    cin >> n;
    if(n==1){
        cout << 0;
        return 0;
    }
    vector<int>c(n-1);
    vector<int>s(n-1);
    vector<int>f(n-1);
    for(int i=0;i<n-1;i++){
        cin >> c[i] >> s[i] >> f[i];
    }
    for(int i=0;i<n-1;i++){
        now=0;
        for(int j=i;j<n-1;j++){
            if(now<=s[j]){
                now=s[j];
            }else{
                tmp=s[j];
                while(now>tmp){
                    tmp+=f[j];
                }
                now=tmp;
            }
            now+=c[j];
        }
        cout << now << "\n";
    }
    cout << 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
const LL INF = 1LL << 60;
const int maxn = 2e5;
char s[maxn + 10];
LL cnt[30];
LL ans, sum;
int len;
void solve() {
	for(int i = 0; i < len; i++)cnt[s[i] - 'a']++;
	for(int i = 0; i < 26; i++)sum += cnt[i];
	for(int i = 0; i < 26; i++) {
		if(cnt[i] > 0) {
			ans += cnt[i] * (sum - cnt[i]);
		}
	}
	ans /= 2;
	ans++;
	printf("%lld\n", ans);
}
int main()
{
	scanf("%s", s);
	len = strlen(s);
	solve();
	return 0;
}


Measured memory_bytes: 384
#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<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

    string  s,t; cin>>s>>t;

    sort(s.begin(),s.end());
    sort(ALL(t));
    //reverse(ALL(s));
    reverse(ALL(t));

    if(s<t)cout<<"Yes\n";
    else  cout <<"No\n";


}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] v = sc.nextIntArray(n);
		int max = 0;

		for(int getNumber = 0; getNumber <= Math.min(n, k); getNumber++){
			for(int left = 0; left <= getNumber; left++){
				List<Integer> plusList = new ArrayList<>();
				List<Integer> minusList = new ArrayList<>();

				for(int i = 0;i < left; i++){
					int num = v[i];
					if(num >= 0)
						plusList.add(num);
					else
						minusList.add(num);
				}
				for(int i = 0; i < getNumber - left; i++){
					int num = v[n-1 - i];
					if(num >= 0)
						plusList.add(num);
					else
						minusList.add(num);
				}

				Collections.sort(minusList);

				for(int i = 0; i < k - getNumber; i++){
					if(minusList.isEmpty())
						break;
					minusList.remove(0);
				}
				int sum = plusList.stream().mapToInt(Integer::intValue).sum() + minusList.stream().mapToInt(Integer::intValue).sum();
				if(max < sum)
					max = sum;
			}
		}
		System.out.println(max);
	}

}

class Scanner {
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	private static final int BEFORE = -1;
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = BEFORE;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == BEFORE)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public String[] nextArray(int length) {
		String[] array = new String[length];
		for(int i = 0; i < length; i++)
			array[i] = next();
		return array;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public double[] nextDoubleArray(int length) {
		double[] array = new double[length];
		for(int i = 0; i < length; i++)
			array[i] = nextDouble();
		return array;
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public int[] nextIntArray(int length) {
		int[] array = new int[length];
		for(int i = 0; i < length; i++)
			array[i] = nextInt();
		return array;
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public long[] nextLongArray(int length) {
		long[] array = new long[length];
		for(int i = 0; i < length; i++)
			array[i] = nextLong();
		return array;
	}
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}


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

int main() {
  while (true) {
    int N, M;
    vector<int> P;
    cin >> N >> M;
    if (N == 0 && M == 0)
      return 0;
    // x1
    for (int i{}; i < N; ++i) {
      int p;
      cin >> p;
      P.push_back(p);
    }
    // x2
    for (int i{}; i < N; ++i) {
      for (int j{}; j < N; ++j) {
        P.push_back(P[i] + P[j]);
      }
    }
    sort(P.begin(), P.end());
    int ans{};
    for (const auto &m1 : P) {
      if (m1 >= M) {
        if (m1 == M) {
          ans = M;
        }
        break;
      }
      auto it = upper_bound(P.begin(), P.end(), M - m1);
      if (it != P.end() && --it != P.end()) {
        ans = max(ans, m1 + *it);
      }
    }
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 10672
#include <iostream>
#include <complex>
#include <algorithm>
#include <cmath>
using namespace std;
typedef complex<int> xy_t;
int n=0;
xy_t point[100001];
xy_t ans[100001];


bool cmp(xy_t a,xy_t b)
{
  if(a.imag()<b.imag())
    return true;
  else if (a.imag()>b.imag())
    return false;
  else
    if(a.real()<b.real())
      return true;
    else
      return false;
}
bool cmp2(xy_t a,xy_t b)
{
  return !cmp(a,b);
}
int cross_product(xy_t a,xy_t b)
{
  return (conj(a)*b).imag();
}
bool legal(xy_t a, xy_t b, xy_t c)
{
  xy_t a1=b-a;
  xy_t a2=c-b;
  if(cross_product(a1,a2)>=0)
    return true;
  else
    return false;
}

int side()
{
  int cn=2;
  ans[0]=point[0];
  ans[1]=point[1];
  for(int i=2;i<n;i++)
  {
    if(legal(ans[cn-2],ans[cn-1],point[i]))
    {
      ans[cn++]=point[i];
    }
    else
    {
      if(cn>2)
      {
        cn--;
        i--;
      }
      else
      {
        ans[1]=point[i];
      }
    }
  }
  return cn;
}

int side2(int c)
{
  int cn=1+c;
  ans[c]=point[n-2];
  for(int i=n-3;i>=0;i--)
  {
    if(legal(ans[cn-2],ans[cn-1],point[i]))
    {
      ans[cn++]=point[i];
    }
    else
    {
      if(cn-c>1)
      {
        cn--;
        i++;
      }
      else
      {
        ans[c]=point[i];
      }
    }
  }
  return cn;
}
void printans(int countn)
{
  for(int i=0;i<countn;i++)
  {
    int x=ans[i].real();
    int y=ans[i].imag();
    cout << x << ' '<<y<<endl;
  }
}

int main()
{
  cin>>n;
  for(int i=0;i<n;i++)
  {
    int x,y;
    cin>>x>>y;
    point[i]=xy_t(x,y);
  }
  sort(point,point+n,cmp);
  int countn=side2(side())-1;
  cout<<countn<<endl;
  printans(countn);

/*  for(int i=0;i<n;i++)
  {
    int x=point[i].real();
    int y=point[i].imag();
    cout << x << ' '<<y<<endl;
  }*/

  return 0;
}

Measured memory_bytes: 4664