akhauriyash/Code-Regression huggingface dataset:
def main():
  import sys
  input = sys.stdin.readline

  X,Y,Z,K = map(int,input().split())
  A = list(map(int,input().split()))
  B = list(map(int,input().split()))
  C = list(map(int,input().split()))
  A.sort(reverse = True)
  B.sort(reverse = True)
  C.sort(reverse = True)
  AB = [a+b for a in A for b in B]
  AB.sort(reverse = True)
  res = [c+ab for ab in AB[:min(K, len(AB))] for c in C]
  res.sort(reverse = True)
  print("\n".join(list(map(str,res[:K]))))

if __name__ == "__main__":
  main()


Measured memory_bytes: 207288
#include <stdio.h>
int main(void){
    int H , W ;
    int h , w ;
    
    while(1){
        scanf("%d %d" , &H , &W);
        if(H == 0 && W == 0){break;}
        
        if(W % 2 ==0){
            for(h = 1 ; h <= H ; h++){
                
                if(h % 2 != 0){
                    for(w = 1 ; 2 * w <= W ; w++){
                        printf("#");
                        printf(".");
                        
                    }
                    printf("\n");
                }//if(h % 2 != 0)
                
                else if(h % 2 == 0){
                    for(w = 1 ; 2 * w <= W ; w++){
                        printf(".");
                        printf("#");
                    }
                    printf("\n");
                }//else if(h % 2 == 0)
            
                
            }//for(h = 1...)
            
            printf("\n");
            
        }//if(W % 2 == 0)
        else if(W % 2 != 0){
            for(h = 1 ; h <= H ; h++){
                
                if(h % 2 != 0){
                    for(w = 1 ; 2 * w <= W ; w++){
                        printf("#");
                        printf(".");
                    }
                    printf("#");
                    printf("\n");
                }//if(h % 2 != 0)
                
                else if(h % 2 == 0){
                    for(w = 1 ; 2 * w <= W ; w++){
                        printf(".");
                        printf("#");
                    }
                    printf(".");
                    printf("\n");
                }//else if(h % 2 == 0)
            }//for(h = 1..)
            printf("\n");
            
        }//else if(W % 2 != 0)
        
    }//while(1)
    
    return 0;
}//int main(void)


Measured memory_bytes: 2088
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  int key;
  struct node *next;
  struct node *pre;
};
typedef struct node * point;
point nil;
point search(int key){
  for(point new=nil->next;new!=nil;new=new->next){
    if(new->key==key){
      return new;
    }
  }
  return nil;
}
void init(){
  nil=malloc(sizeof(struct node));
  nil->next=nil;
  nil->pre=nil;
}
void print(){
  point cur=nil->next;
  int i=0;
  while(1){
    if(cur==nil)break;
    if(i++>0)printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");
}
void delete(point t){
  if(t==nil)return;
  t->pre->next=t->next;
  t->next->pre=t->pre;
  free(t);
}
void deleteF(){
  delete(nil->next);
}
void deleteL(){
  delete(nil->pre);
}
void deleteK(int key){
  delete(search(key));
}
void insert(int key){
  point x=malloc(sizeof(struct node));
  x->key=key;
  x->next=nil->next;
  nil->next->pre=x;
  nil->next=x;
  x->pre=nil;
}
void in(){
  int key,i,n;
  int size=0;
  char c[20];
  int np=0,nd=0;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",c,&key);
    if(c[0]=='i'){
      insert(key);
      np++;
      size++;
    }
    else if(c[0]=='d'){
      if(strlen(c)>6){
        if(c[6]=='F')deleteF();
        else if(c[6]=='L')deleteL();
      }
      else {
        deleteK(key);
        nd++;
      }
      size--;
    }
  }
}

int main(){
  in();
  print();
  return 0;
}



Measured memory_bytes: 32976
using System;
using System.Collections;
using System.Collections.Generic;

class Program
{
    public static void Main()
    {
        string[] S=Console.ReadLine().Split(' ');
        int N = int.Parse(S[0]);
        int K = int.Parse(S[1]);

        decimal sum = 0;

        for(int i=1;i<=N;i++)
            sum += F(i,N,K);

        Console.WriteLine(sum);
    }
    static decimal F(int I, int N,int K)
    {
        int times = 0;

        for(int i=I; i < K;)
        {
            i <<= 1;
            times++;
        }
        decimal d = (decimal)0.5;
        decimal r = (decimal)1/N;
        for (int i = 0; i < times; i++)
            r *= d;
        return r;
    }
}

Measured memory_bytes: 13268
#include "stdio.h"
 
int if_can_divide(int A[200], int N)
{
	int i;

	for(i=0;i<N;i++){
		if(A[i]%2!=0){
			return 0;
		}
	}

	return 1;
}
 
 
void divide(int A[200], int N)
{
	int i;

	for(i=0;i<N;i++){
		A[i]/=2;
	}
}
 
int main(void){
	int N;
	int A[200];
	int cnt = 0;
	int i;

	scanf("%d", &N);

	for(i=0;i<N;i++){
		scanf("%d", &A[i]);
	}

	while(if_can_divide(A, N))
	{
		divide(A, N);
		cnt++;
	}



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

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

const int MOD = 2019;

int A[2020][2];

int main() {

    string S;
    cin >> S;

    int pre = 0, ans = 0;
    
    A[pre][0]++;
    int curr = 1, prev = 0;

    for (auto s : S)
    {
        int x = s - '0';
        pre = (pre * 10 + x) % MOD;

        for(int i=0; i<MOD; i++)
            A[i][curr] = 0;
        for(int i=0; i<MOD; i++)
            A[(i * 10) % MOD][curr] += A[i][prev];

        ans += A[pre][curr];
        A[pre][curr]++;

        swap(prev, curr);
    }
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/


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

    int n; cin >> n;
    map<string, int> mp;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        mp[s]++;
    }
    vector <string> task = {"AC", "WA", "TLE", "RE"};
    for (string i: task) {
        cout << i << " x " << mp[i] << endl;
    }

    return 0;
}


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

int main(){
  int a[5];
  cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
  rep(i,5){
    if(a[i]==0)cout<<i+1<<endl;
  }
}

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(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 INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

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

Measured memory_bytes: 3636
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = [input() for _ in range(N)]

cnt_s = Counter(S)
tmp = cnt_s.most_common()[0][1]
for key, val in sorted(cnt_s.most_common(), key=lambda x:x[0]):
		if val == tmp:
      			print(key)

Measured memory_bytes: 51796
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<functional>
#define PAIR pair<int,int>
using namespace std;
vector<vector<int> > hk;
vector<int> minum;
void input() {
	hk.resize(10);
	for (int i = 0; i < 10; ++i) {
		hk[i].resize(10);
	}
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			cin >> hk[i][j];
		}
	}
	bool flag = true;
	while (flag) {
		flag = false;
		for (int i = 0; i < 10; ++i) {
			for (int j = 0; j < 10; ++j) {
				for (int k = 0; k < 10; ++k) {
					int nx = hk[i][k] + hk[k][j];
					if (hk[i][j] > nx) {
						flag = true;
						hk[i][j] = nx;
					}
				}
			}
		}
	}
	minum.resize(10);
	for (int i = 0; i < 10; ++i) {
		minum[i] = hk[i][1];
	}
}
int main() {
	int W, H;
	cin >> W >> H;
	input();
	long long ans = 0;
	for (int i = 0; i < W*H; ++i) {
		int a;
		cin >> a;
		if (a != -1) {
			ans += minum[a];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int n, m;
vector<int> v[100010];
int main() {
    cin.tie(0); cin.sync_with_stdio(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
    }
    priority_queue<pair<int, int>> q;
    long long ans = 0;
    for (int i = 1; i <= m; i++) {
        sort(v[i].begin(), v[i].end());
        if (!v[i].empty()) {
            q.emplace(v[i].back(), i);
        }
        if (!q.empty()) {
            auto x = q.top();
            q.pop();
            ans += x.first;
            v[x.second].pop_back();
            if (!v[x.second].empty()) {
                q.emplace(v[x.second].back(), x.second);
            }
        }
    }
    cout << ans;
}   

Measured memory_bytes: 5632
from sys import stdin
from itertools import groupby

s = list(stdin.readline().rstrip())
s.sort()
li = []
for key, value in groupby(s):
    li.append(len(list(value)))
if len(li) == 1:
    li += [0]*2
elif len(li) == 2:
    li += [0]

if abs(li[2]-li[1]) <= 1 and abs(li[1]-li[0]) <= 1 and abs(li[2]-li[0]) <= 1:
    print("YES")
else:
    print("NO")

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


int main() {
	//code
	//cout<<"ashish"<<endl;
	long long int n;
	cin>>n;
	string s;
	char c[26]={'z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y'};
	while(n>0){
        int x=n%26;
        s+=c[x];
        if(x==0) n=n-26;
        else n=n-x;
        n=n/26;
	}
	reverse(s.begin(),s.end());
	cout<<s;
	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ill long long int
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a[3];
  rep(i, 0, 3){
    cin >> a[i];
  }
  if(a[0] == a[1]){
    if(a[0] == a[2]){
      cout << "1\n";
      return 0;
    }
    cout << "2\n";
    return 0;
  }
  if(a[0] != a[2]){
    if(a[1] != a[2]){
      cout << "3\n";
      return 0;
    }
  }
  
  cout << "2\n";
  return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    string s;
    cin >> s;
    int n = (int)s.size();
    int ans = 0;
    rep(i, (n+1)/2 ) {
        if (s[i] != s[(n-1) - i]) ans++;
    }
    cout << ans << endl;
}

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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define pb push_back


// string size = str.size()

// stack <int> s; 
// queue <int> gquiz; 
// __gcd(m, n) 

// ll arr[10e5 + 5];
// char arr[10e5 + 5];

// printf ("%.9f\n",x);

bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}


int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,k;
    cin >> k >> n;
    ll arr[n+5] = {0};
    ll arr_n[n+5] = {0};
    ll sum = 0; 
    for(ll i = 1; i<=n; i++)
    {
        cin >> arr[i];
        // sum += arr[i];
    }
    ll d = 0;
    for(ll i = 1; i<n;i++)
    {
        d += arr[i+1] - arr[i];
    }
    // cout << "d is " << d << endl;
    arr[n+1] = k - d;
    ll diff = -1;
    ll index = 0;
    for(ll i = 1; i<n; i++)
    {
        if(arr[i+1] - arr[i] > diff)
        {
            index = i+1; 
            diff = arr[i+1] - arr[i];
        }
    }
    // cout << diff << endl;
    // cout << "index is " << index << endl;
    ll dist = 0,dist1=0;
    for(ll i = index; i<n; i++)
    {
        // if(arr[i+1]!=0)
            dist += abs(arr[i+1] - arr[i]);
    }
    // cout << dist << endl;

    for(ll i = 1; i<index;i++)
    {
        // if(arr[i+1]!=0) b b
            dist+=abs(arr[i+1] - arr[i]);
    }
    // cout << dist << endl;

    for (ll i = index-1; i>1; i--)
    {
        dist1+= abs(arr[i-1] - arr[i]);
    }
    // cout << dist1 << endl;

    for(ll i = n; i >index;i--)
    {
        dist1 += abs(arr[i-1] - arr[i]);
    }
    // cout << dist1 << endl;

    dist1 += arr[n+1];
    // cout << dist << endl;
    // cout << dist1 << endl;
    dist = min(dist,dist1);
    cout << dist << endl;

    // arr_n[1] = arr[1];
    // for(ll i = 2; i<=n; i++)
    // {
    //     arr_n[i] += arr[i] - arr[i-1];
    // }
    // for(ll i = 1; i<=n; i++)
    // {
    //     cout << arr_n[i]<< " ";
    // }
    return 0;
}   

Measured memory_bytes: 3328
n,k=map(int,input().split())
s=input()
ans=''
for i in range(len(s)):
  if i==k-1:
    if s[i]=='A':
      ans+='a'
    elif s[i]=='B':
      ans+='b'
    else:
      ans+='c'
  else:
    ans+=s[i]
print(ans)

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("path.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll a, b, k;
    cin >> a >> b >> k;
    if (k <= a)
        cout << a-k << " " << b;
    else
        cout << "0 " << max(0LL, b - (k-a));

    return 0;
}


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

pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> {
    let s = read1::<String>();
    s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T>>()
}

fn main() {
    let n = read1::<usize>();
    let mut l = readn::<usize>(" ");

    l.sort();

    let ans = (0..n).map(|i| l[2*i]).sum::<usize>();
    println!("{}", ans);
}

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

int main() {
	int n;
	cin >> n;
	vector<pii> v(n);
	rep(i, n) cin >> v[i].first >> v[i].second;
	vector<int> p(n);
	rep(i, n) p[i] = i;
	double sum = 0;
	int cnt = 0;
	do {
		rep(i, n - 1) {
			int s = p[i];
			int t = p[i + 1];
			int dx = v[t].first - v[s].first;
			int dy = v[t].second - v[s].second;
			sum += sqrt(dx * dx + dy * dy);
		}
		cnt++;
	} while (next_permutation(p.begin(), p.end()));
	printf("%.10f", sum / cnt);
	return 0;
}

Measured memory_bytes: 3816
#include <stdio.h>

int main() {

  int r,d,n,i,j,k,l;
  int p,c;
  int a[60] = {0};
  int b[60] = {0};


  while(1) {

    scanf("%d %d", &n, &r);

    if(n == 0 && r == 0) {
      break;
    }


    for(i =0 ; i<=n ; i++) {
      a[n-1-i] = i+1;
      b[n-1-i] = i+1;
    }



    for(i = 0; i < r; i++) {
      scanf("%d %d",&p,&c);

      for(j = 0; j<c;j++) {
	a[j] = b[p+j-1];
	//printf("a[%d] = %d\n",j,a[j]);
      }
      for(j = 0;j<p-1;j++) {
	a[c+j] = b[j];
	//printf("a[%d] = %d\n" ,c+j ,a[c+j]);
      }

      for(j = 0;j<p+c-1;j++) {
	b[j] = a[j];
      }
    }


    printf("%d\n",a[0]);

  }

  return 0;
}

Measured memory_bytes: 600
from fractions import gcd
A, B, C, D = list(map(int, input().split()))

def num(x, y):
    return (x * y) // gcd(x, y)

print(B-A+1-((B//C+B//D-B//(num(C, D)))-((A-1)//C+(A-1)//D-(A-1)//(num(C, D)))))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 105;

bool used[MAX_N];
int b[MAX_N];
int val[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    bool dame = false;
    rep(i,n){
        cin >> b[i];
        --b[i];
        if(b[i] > i) dame = true;
    }
    if(dame){
        cout << "-1\n";
        return 0;
    }
    vi ans;
    while(len(ans) < n){
        for(int i = n-1; i >= 0; i--){
            if(val[i] == b[i] && !used[i]){
                ans.pb(b[i]);
                used[i] = true;
                srep(j,i+1,n){
                    val[j]++;
                }
                break;
            }
        }
    }
    each(hoge,ans){
        cout << hoge+1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

int n, i, sum, l;
int d[51];

scanf("%d", &n);

for(i=1; i<=n; i++) scanf("%d", &d[i]);

for(i=1; i<n; i++){

for(l=i+1; l<=n; l++) sum = sum + d[i] * d[l];

}

printf("%d", sum);

}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" ";
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long X){

    for(lli n=1;;n++){
        lli c = n*n+n-2*X;
        if(c>=0){
            cout<<n<<endl;
            return;
        }
    }

}

int main(){
    // cout << fixed << setprecision(5);

    long long X;
    scanf("%lld",&X);
    func(X);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i++)
int h,w,a,li[15][15],s=0;

int min(int a, int b){
	if(a>b) return b;
	else return a;
}

int main(void){
	scanf("%d %d",&h,&w);
	REP(i,0,10) REP(j,0,10) scanf("%d", &li[i][j]);
	REP(k,0,10) REP(i,0,10) REP(j,0,10) li[i][j]=min(li[i][j], li[i][k]+li[k][j]);
	REP(i,0,h) REP(j,0,w){
		scanf("%d",&a);
		if(a==-1) continue;
		else s+=li[a][1];
	}
	
	printf("%d\n",s);
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef int ttttt;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;
const ll mod = 998244353LL;
int extgcd(int a,int b,int& x,int& y){
  int d=a;
  if(b != 0){
    d = extgcd( b , a%b, y, x);
    y -= (a/b)*x;
  } else{
    x=1; y=0;
  }
  return d;
}

int mod_inverse(int a,int m){
  int x,y;
  extgcd(a,m,x,y);
  return (m+x%m) %m;
}

ll N,M,A,B,K;
ll gam[300002];

ll comb(ll n,ll m){
  if(n<m) return 0;
  //cout <<gam[n]<<" "<<mod_inverse(gam[m],mod)<<" "
  return (((gam[n]*mod_inverse(gam[m],mod))%mod)*mod_inverse(gam[n-m],mod))%mod;
}

ll calc(ll a){
  ll n = K - a*A;
  if(n < 0 || (n%B!=0) ) return 0;
  return (comb( N,a )*comb( N,n/B ))%mod;
}

ttttt main()
{
  ll ans = 0;
  gam[0]=1;
  rep1(i,300000){
    gam[i]= (i*gam[i-1])%mod;
    //if(i<30) cout<<gam[i]<<endl;
  }
  cin>>N>>A>>B>>K;
  //cout<<comb(N,A)<<endl;
  rep(i,N+1){
    ans += calc(i);
    ans%=mod;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2688
H , W = map(int,input().split())
S = [[""]*(W+2)]*(H+2)
for i in range(H):
    p = [""]+list(input())+[""]
    S[i+1] = p

def countBom(S,i,j):
    con_bom =0
    for h in range(-1,2):
        for w in range(-1,2):
            if S[i+h][j+w] == "#":
                con_bom += 1
    return con_bom




for i in range(H):
    for j in range(W):
        if S[i+1][j+1] ==".":
            S[i+1][j+1] = countBom(S,i+1,j+1)
    print("".join(list(map(str,(S[i+1])))))



Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    
	char s[50];
	int a = 0,i;
	scanf("%s",&s);
	a = strlen(s);
	a-=8;
	for(i = 0;i<a;i++){
	printf("%c",s[i]);
	}
	
	
	
		return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>

#define all(x) begin(x),end(x)

using namespace std;
using ll = long long;

template<typename T>
T gcd(T a, T b) {
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

int main()
{
    ll a, b;
    cin >> a >> b;

    if (a > b) {
        ll tmp = b;
        b = a;
        a = tmp;
    }

    cout << lcm(a, b) << endl;
}


Measured memory_bytes: 256
#ifdef DBG1
  #define LOCAL
#endif

#ifdef LOCAL
  #define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifdef DBG1
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dbg(...)
#endif

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;

bool solve() {
  static char s[200500];
  if (scanf("%s", s) != 1) { return false; }

  ll res = 0;
  int cntB = 0;
  for (int i = 0; s[i]; ++i) {
    if (s[i] == 'W') {
      res += cntB;
    } else {
      cntB += 1;
    }
  }
  printf("%lld\n", res);
  return true;
}

int main() {
  while (solve());
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;



int main(void){
    int n;
    while(true){
        cin>>n;
        if(n==0)break;
        vector<int>x(n),y(n);
        for(int i=0;i<n;i++)cin>>x[i]>>y[i];
        int nowx=10,nowy=10;
        int m;
        cin>>m;
        string s;
        int d;
        int ans=0;
        for(int i=0;i<m;i++){
            cin>>s>>d;
            if(s=="N"){
                for(int i=0;i<d;i++){
                    nowy++;
                    for(int j=0;j<n;j++){
                        if(nowx==x[j]&&nowy==y[j]){
                            ans++;
                            x[j]=-1;
                            y[j]=-1;
                        }
                    }
                }
            }
            if(s=="S"){
                for(int i=0;i<d;i++){
                    nowy--;
                    for(int j=0;j<n;j++){
                        if(nowx==x[j]&&nowy==y[j]){
                            ans++;
                            x[j]=-1;
                            y[j]=-1;
                        }
                    }
                }
            }
            if(s=="W"){
                for(int i=0;i<d;i++){
                    nowx--;
                    for(int j=0;j<n;j++){
                        if(nowx==x[j]&&nowy==y[j]){
                            ans++;
                            x[j]=-1;
                            y[j]=-1;
                        }
                    }
                }
            }
            if(s=="E"){
                for(int i=0;i<d;i++){
                    nowx++;
                    for(int j=0;j<n;j++){
                        if(nowx==x[j]&&nowy==y[j]){
                            ans++;
                            x[j]=-1;
                            y[j]=-1;
                        }
                    }
                }
            }
        }
        //cout<<ans<<endl;
        if(ans==n)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }   
    return 0;
}


Measured memory_bytes: 3152
I=lambda:map(int,input().split())
N,M=I()
*H,=I()
m=[0]*N
for _ in[0]*M:
  A,B=I()
  m[A-1]=max(m[A-1],H[B-1])
  m[B-1]=max(m[B-1],H[A-1])
print(sum(1 for i in range(N) if H[i]>m[i]))

Measured memory_bytes: 20028
N = gets.chomp.to_i
array = gets.chomp.split(" ").map(&:to_i)

alice = 0
bob = 0

array.sort!.reverse!

array.each_with_index {|a, i|
  if i%2==0
    alice += a
  else
    bob += a
  end
}

p alice - bob


Measured memory_bytes: 1788
import math
N = int(input())
a = [int(_) for _ in input().split()]

floor = math.floor(sum(a) / len(a))
ceil = math.ceil(sum(a) / len(a))

ceil_sum = sum([(item - ceil) ** 2 for item in a])
floor_sum = sum([(item - floor) ** 2 for item in a])

print(min(ceil_sum, floor_sum))

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

int main(){
  string s;
  int n;
  cin >> n >> s;
  int ans = 0;
  for (int i = 1; i < n-1; i++){
    bool l[26] = {0}, r[26] = {0};
    for (int j = 0; j < i; j++){
      l[(int)(s[j] - 'a')] = true;
    }
    for (int j = i; j < n; j++){
      r[(int)(s[j] - 'a')] = true;
    }
    int tmp = 0;
    for (int i = 0; i < 26; i++){
      if (l[i] && r[i]){
        tmp++;
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int a,b,c,h=0,s=0;
  while(scanf("%d,%d,%d",&a,&b,&c)!=EOF) {
      if (a==b) h++;
	  if (a*a+b*b==c*c) s++;
  }
  cout << s << endl << h << endl;
  return 0;
}

Measured memory_bytes: 1208
//#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>

//Some constants don't work
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef INT_MIN
#define INT_MIN -2147483648
#endif
//short hand tricks
typedef long long ll;

using namespace std;

int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(false);
    vector<int> v(5);
    for(int i=0; i<5; i++) {
        cin >> v[i];
    }
    for(int i=0; i<5; i++) {
        if(v[i]==0) {
            cout << (i+1) <<"\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3540
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <map>
 
#define rep(i,n) for(int (i) = 0;(i)<(n);(i)++)
#define ll long long
using namespace std;
 
int main() {
	int m, n;
	cin >> n >> m;
	float border = 0;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		border += a[i];
	}
	border /= (float)(4 * m);
	sort(a.begin(), a.end());
	if (a[n - m] >= border) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
vector<pair<ll, ll>> wv(110);
ll dp[110][100100] = {0};

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
int main(void){
	
	int N, W;
	
	cin >> N >> W;
	
	rep(i, N)
		cin >> wv[i].first >> wv[i].second;
		
	rep(i, N){
		rep(sum_w, W + 1){
			if(sum_w - wv[i].first >= 0)
				chmax(dp[i+1][sum_w], dp[i][sum_w - wv[i].first] + wv[i].second);
			chmax(dp[i+1][sum_w], dp[i][sum_w]);
		}
	}
	
	cout << dp[N][W];
	
	return 0;
}

Measured memory_bytes: 79360
#include <iostream>
#include <string>

using namespace std;

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

    string nStr;
    nStr = to_string(N);

    auto sum = 0;
    for (auto ch : nStr) {
        sum += atoi(&ch);
    }
    if (N % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

 
int main(){
  int n,x;
  cin >> n >> x;
  int ans=0,best=inf;
  rep(i,n){
    int k; cin>>k;
    ans += k;
    best = min(best,k);
  }
  cout << n+((x-ans)/best) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=1<<19;
const int inf=0x3f3f3f3f;
const LL mod=924844033;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,sz[N];
int bgn[N],nxt[N],to[N],E;
LL fac[N],ifac[N],x[N],y[N];
int Base,len,rev[N];
inline void add_edge(int u,int v){nxt[++E]=bgn[u],bgn[u]=E,to[E]=v;}
inline void Add(LL&x,LL y){x=x+y<mod?x+y:x+y-mod;}
inline LL qpow(LL a,LL b)
{
	LL ret=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ret=ret*a%mod;
	return ret;
}
inline void init()
{
	fac[0]=ifac[0]=1;
	For(i,1,n)fac[i]=fac[i-1]*i%mod;
	ifac[n]=qpow(fac[n],mod-2);
	rFor(i,n,2)ifac[i-1]=ifac[i]*i%mod;
}
inline void dfs(int u,int f)
{
	sz[u]=1;
	for(int v,i=bgn[u];i;i=nxt[i])
	{
		if((v=to[i])==f)continue;
		dfs(v,u);
		sz[u]+=sz[v];
		x[sz[v]]--,x[n-sz[v]]--;
	}
}
inline void init_NTT(int n)
{
	for(Base=1;Base<=n;Base<<=1)len++;
	For(i,1,Base-1)rev[i]=rev[i>>1]>>1|(i&1)<<(len-1);
}
inline void NTT(LL *x,int Base,int flag)
{
	For(i,0,Base-1)if(i<rev[i])swap(x[i],x[rev[i]]);
	for(int K=2;K<=Base;K<<=1)
	{
		LL wn=qpow(5,mod/K);
		if(flag)wn=qpow(wn,mod-2);
		for(int M=0;M<Base;M+=K)
		{
			LL w=1,a,b,*l=x+M,*r=x+M+(K>>1);
			For(i,0,(K>>1)-1)
			{
				a=*l,b=*r*w%mod;
				Add(*l=a,b),Add(*r=a,mod-b);
				w=w*wn%mod,++l,++r;
			}
		}
	}
	if(flag)
	{
		LL inv=qpow(Base,mod-2);
		For(i,0,Base-1)x[i]=x[i]*inv%mod;
	}
}
inline void Solve()
{
	x[n]=n;
	For(i,1,n)x[i]=(x[i]+mod)*fac[i]%mod;
	For(i,0,n)y[i]=ifac[n-i];
	init_NTT(n<<1);
	NTT(x,Base,0),NTT(y,Base,0);
	For(i,0,Base-1)x[i]=x[i]*y[i]%mod;
	NTT(x,Base,1);
	For(i,n+1,n+n)printf("%lld\n",x[i]*ifac[i-n]%mod);
}
int main()
{
	int x,y;
	file();
	read(n);
	init();
	For(i,2,n)read(x),read(y),add_edge(x,y),add_edge(y,x);
	dfs(1,0);
	Solve();
	return 0;
}


Measured memory_bytes: 28800
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;

typedef pair<ll, ll> P;

const int MOD = 1000000007;
const ll INF = 1LL << 60;


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

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

int main(int argc, char**argv){
    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    for (int i = 0; i < n; i++){
        cin >> v[i];
    }

    ll max_value = -9999999999;
    int r = min(n, k);
    for (int a = 0; a <= r; a++){
        for (int b = 0; a + b <= r; b++){
            vector<ll> in_hands;
            for (int i = 0; i < a; i++){
                in_hands.push_back(v[i]);
            }
            for (int i = 0; i < b; i++){
                in_hands.push_back(v[n-1-i]);
            }
            sort(in_hands.begin(), in_hands.end());

            ll value = 0;
            int n_removed = 0;
            for (auto item_v : in_hands){
                if (item_v < 0 && n_removed < k - (a+b)){
                    n_removed++;
                    continue;
                }
                value += item_v;
            }
            chmax(max_value, value);
        }
    }

    cout << max_value << endl;

    return 0;
}
















Measured memory_bytes: 256
import sys


def main(s, t):
    s_ = ''
    for i in sorted(s):
        s_ += i

    t_ = ''
    for i in sorted(t, reverse=True):
        t_ += i

    if s_ < t_:
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':
    _s = input()
    _t = input()
    ret = main(_s, _t)
    print(ret)

Measured memory_bytes: 3060
eval"N,*A="+`dd`.split*?,
c,d=[0,N].map{|i|y=A[i+N-1];A[i,N].map{|i|y^y=i}}
d+=m=[k=-1]
f=->l,t{l=m[l]until l<0||d[l]==t;l+1}
d.map{|x|m<<k=f[k,x]}
(2*N-1).times{|i|$.=f[$.,c[i%N]];p i+=1-N,A[N]^A[i]if$.==N}

Measured memory_bytes: 96168
#include <bits/stdc++.h>
#define FOR0(i, n) for (int i = 0; i < n; i++)
#define FOR1(i, n) for (int i = 1; i <= n; i++)
#define FORl(i, l, n) for (int i = l; i < n; i++)
using namespace std;
#define pi pair<ll, ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x, 0, sizeof(x));
#define vi vector<ll>
#define sync                      \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);                   \
	cout.tie(0);
#define endl '\n'
#define sp << " " <<
#define intmax 1e14
ll mod = 1e9 + 7;

ll power(ll num, ll g, ll mod)
{
	if (g == 0)
		return 1;
	if (g % 2 == 1)
		return (num * power((num * num) % mod, g / 2, mod)) % mod;
	return power((num * num) % mod, g / 2, mod);
}

int main() {
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;

}

Measured memory_bytes: 3628
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

H, W = MAP()
A = [input() for _ in range(H)]

cnt_w = sum([X.count("#") for X in A])

def DFS(y, x, cnt):
	if 0 <= x+1 <= W-1 and A[y][x+1] == "#":
			return DFS(y, x+1, cnt+1)
	elif 0 <= y+1 <= H-1 and A[y+1][x] == "#":
			return DFS(y+1, x, cnt+1)
	else:
		return (y, x, cnt)

if A[0][0] != "#":
	print("Impossible")
elif (H-1, W-1, cnt_w) == DFS(0, 0, 1):
	print("Possible")
else:
	print("Impossible")

Measured memory_bytes: 5396
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    ll N;
    cin >> N;
    ll A[N];
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if(i == 0){
            if(A[0] != 0) {
                cout << -1 << endl;
                return 0;
            }
        }else{
            if(A[i] - A[i-1] > 1){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    ll currentStep = A[N - 1];
    ll sum = A[N - 1];
    for (int i = 1; i < N; ++i) {
        if(currentStep != 0){
            currentStep--;
        }
        if(currentStep < A[N - i - 1]){
            currentStep = A[N - i - 1];
            sum += A[N - i - 1];
        }
    }
    cout << sum << endl;

}


Measured memory_bytes: 1792
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>

#define p(a, b) pair<a, b>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s1,s2;
    cin >> s1  >> s2;
    if(s1[1] != s2[1]){
        cout << "NO";
        return 0;
    }
    if(s1[0] == s2[2] && s1[2] == s2[0]){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

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

  int tp = 0, hp = 0;

  for (int i = 0; i < n; i++) 
  {
    std::string tc, hc;
    std::cin>>tc>>hc;

    if (tc > hc)
    {
        tp+=3;
    }else if(tc < hc)
    {
        hp+=3;
    }
    else
    {
        tp++, hp++;
    }
  }

  std::cout<<tp<<" "<<hp<<std::endl;
  return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	string x, y;
	char xt[200000], yt[200000];
	vector<int> xv, yv;
	int nx, ny;
	cin >> x >> y;

	for (int i = 0; i < (int)x.size(); i++)
	{
		xt[i] = x[i];
	}
	for (int i = 0; i < (int)y.size(); i++)
	{
		yt[i] = y[i];
	}

	sort(xt, xt + (int)x.size());
	sort(yt, yt + (int)y.size());

	xv.push_back(1);
	yv.push_back(1);
	nx = 0;
	ny = 0;
	for (int i = 1; i < (int)x.size(); i++)
	{
		if (xt[i - 1] == xt[i]) {
			xv[nx]++;
		}
		else {
			xv.push_back(1);
			nx++;
		}
	}
	for (int i = 1; i < (int)y.size(); i++)
	{
		if (yt[i - 1] == yt[i]) {
			yv[ny]++;
		}
		else {
			yv.push_back(1);
			ny++;
		}
	}

	sort(xv.begin(), xv.end());
	sort(yv.begin(), yv.end());

	bool flg = true;
	if (xv.size() == yv.size()) {
		for (int i = 0; i < (int)xv.size(); i++)
		{
			if (xv[i] != yv[i]) {
				flg = false;
			}
		}
	}
	else {
		flg = false;
	}

	if (flg) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;

}

Measured memory_bytes: 1160
num = int(input())
seq = list(map(int, input().split()))

prev = None
increase = None
count = 0

prev = seq[0]
for x in seq[1:]:
    if increase is True:
        if x >= prev:
            pass
        else:
            increase = None
            count += 1
    elif increase is False:
        if x <= prev:
            pass
        else:
            increase = None
            count += 1
    elif increase is None:
        if x == prev:
            pass
        elif x > prev:
            increase = True
        else:
            increase = False
    prev = x

count += 1
print(count)


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

using namespace std;
typedef long long ll;

int main(int argc, char const *argv[])
{
	ll n;
	cin >> n;
	double k = 100;
	ll x = 100;
	ll c = 0;
	while(1){
		x += (ll)(k * .01);
		k = x;
		c++;

		if (x >= n)
		{
			cout << c << "\n";
			return 0;
		}
	}
}

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

using namespace std;

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

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

    int cnt = 0;
    int max_height = 0;
    for(int i = 0; i < N; i++) {
        if(H[i] >= max_height) {
            max_height = H[i];
            cnt++;
        }
    }
    cout << cnt << endl;

}


Measured memory_bytes: 256
#include <set>
#include <cstdio>
#include <cstdlib>
#include <climits>

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

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

int v[20];

int main(){
  while(int n = getInt()){
    int ans = INT_MAX;

    REP(i, n) v[i] = getInt();
    REP(i, (1 << n)){
      int a[2] = { 0, 0 };

      REP(j, n){
	a[(i & (1 << j)) == 0] += v[j];
      }

      ans = min(ans, std::abs(a[0] - a[1]));
    }

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N,X,Y;
  cin>>N>>X>>Y;
  map<int,int>k;
  for(int i=1;i<=N;i++){
    for(int j=i+1;j<=N;j++){
      int dir=j-i;
      int sid=abs(X-i)+abs(Y-j)+1;
      int m=min(dir,sid);
      k[m]++;
    }
  }
  for(int i=1;i<N;i++){
    cout<<k[i]<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3704
import java.io.*;
import java.util.ArrayList;
import java.util.Comparator;

public class Main {
  public static void main(String[] args) {
    new Main().run();
  }

  private void run() {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

        int n = Integer.parseInt(in.readLine());

        String[] lines;
        ArrayList<String[]> list = new ArrayList<>();
        for(int i = 0; i < n; i++) {
          lines = in.readLine().split(" ");
          list.add(new String[] {lines[0], lines[1], String.valueOf(i+1)});
        }

        list.sort(new Comparator<String[]>() {
          @Override
          public int compare(String[] sa, String[] sb) {
            if(sa[0].equals(sb[0]))
              return new Integer(sa[1]).compareTo(new Integer(sb[1])) * -1;
            else
              return sa[0].compareTo(sb[0]);
          } 
        });

        list.forEach(s -> out.println(s[2]));
        out.flush();
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 26324
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	int n;
	
	string s;
	cin>>s;
	
	int ans = 0;
	for(int i=0;i<3;++i) if(s.find(string(i+1,'R')) != string::npos) ans = i+1;
	
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3656
#include        <bits/stdc++.h>
#define ll      long long int
#define pb      push_back
#define mp      make_pair
#define F       first
#define S       second
#define MOD     1000000007
#define pii     pair<int,int>
#define vi      vector<int>
#define fio     ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define N       200010
#define M       1000000000000000
#define O       1LL
using namespace std;

vector<pii>v;
int dp[5005][2][5002];

int main()
{
    fio;
    int a,b;
    cin>>a>>b;
    if(a>8||b>8){
        cout<<":(";
    }
    else{
        cout<<"Yay!";
    }
    
    
    
    
    return 0;
}







Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

N = I()
S = input()

ans = 0

tmp = "#"
for s in S:
    if s != tmp:
        ans += 1
        tmp = s

print(ans)


Measured memory_bytes: 44528
n=int(input())
s=list(input())

c=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
ans=""

for i in range(len(s)):
    for j in range(len(c)):
        if s[i]==c[j]:
            ans+=c[(j+n)%len(c)]
print(ans)

Measured memory_bytes: 3064