akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
using namespace std;
int main(void){
    int N;
    cin>>N;
    string S[N];
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    int M;
    cin>>M;
    string T[M];
    for(int i=0;i<M;i++){
        cin>>T[i];
    }
    int count=0;
    int answer=0;
    for(int i=0;i<N;i++){
        count=0;
        for(int j=0;j<N;j++){
            if(S[i]==S[j]){
                count+=1;
            }
        }
        for(int j=0;j<M;j++){
            if(S[i]==T[j]){
                count-=1;
            }
        }
        if(answer<count){
            answer=count;
        }
    }
    cout<<answer<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
using namespace std;

long long a[100005];
long long bits[100];

int main(void){
    long long N, K; cin >> N >> K;
    for (int i = 0; i < N; i++){
        long long n; cin >> n;
        a[i] = n;
        int cnt = 0;
        while (n > 0){
            if (n % 2){
                bits[cnt]++;
            }
            n /= 2;
            cnt++;
        }
    }
    int limit = 0;
    while ((1LL<<(limit+1)) <= K){
        limit++;
    }
    long long X1 = 0;
    for (int i = 0; i < limit; i++){
        if (2*bits[i] < N){
            X1 += (1LL<<i);            
        }
    }
    long long X2 = (1LL<<limit);
    int flag = 0;
    for (int i = limit-1; i >= 0; i--){
        if (K & (1LL << i)){
            if (2*bits[i] >= N){
                flag = 1;
                continue;
            }else{
                X2 += (1LL << i);
            }
        }else{
            if (2*bits[i] < N && flag){
                X2 += (1LL << i);
            }
        }
    }
    long long ans = 0;
    long long ans2 = 0;
    if (!K){
        X1 = X2 = 0;
    }
    for (int i = 0; i < N; i++){
        ans += X1 ^ a[i];
    }
    for (int i = 0; i < N; i++){
        ans2 += X2 ^ a[i];
    }
    cout << (ans > ans2 ? ans : ans2) << endl;
    
    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for (int i=(a); i>=(b); --i)
#define REP(i,b) for (int i=0; i<(b); ++i)
#define endl '\n'
#define sz(x) (int) x.size()
#define mod %
#define fillchar(x,y,z) memset(x,z,y)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define sqr(x) ((x)*(x))
typedef long long int64;
typedef unsigned long long qword;
using namespace std;
const int maxn=1e5+5;
int n,x;
int f[maxn][4];
void Input()
{
    cin >> n;
    FOR(i,1,n) {
        FOR(j,1,3) {
            cin >> x;
            FOR(k,1,3) if (k!=j)
                f[i][j]=max(f[i][j],f[i-1][k]+x);
        }
    }
    cout << max({f[n][1],f[n][2],f[n][3]});
}
void Solve()
{

}
int main()
{
    #ifdef meomeomeooooo
        freopen("input.txt","r",stdin);
        //freopen(".out","w",stdout);
    #endif // meomeomeooooo
    iostream::sync_with_stdio(false);
    cin.tie(0);
    Input();
    Solve();
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mk make_pair
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MAXN = 1e6 + 5;
const int MAXM = 5e5 + 5;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
int a[MAXN], b[MAXN];
int n, k, sum;

bool check(int g){
    for(int i = 1;i <= n; ++i){
        b[i] = a[i] % g;
    }
    sort(b + 1, b + n + 1);
    int L = 1, R = n, cnt = 0;
    while(L<R){
        if(b[L] + b[R] >g){
            cnt+=(g-b[R]);
            b[L] -= (g-b[R]);
            b[R] = g;
            --R;
        }else if(b[L] + b[R] == g){
            cnt += b[L];
            b[R] = g;
            --R;
            b[L] = 0;
            ++L;
        }else{
            cnt += b[L];
            b[R] += b[L];
            b[L] = 0;
            ++L;
        }
    }
    if(L==R && (b[L]%g!=0))  return false;
    return cnt <= k;
}

int main(){
    scanf("%d%d", &n, &k);
    for(int i = 1;i <= n;++i){
        scanf("%d", &a[i]);
        sum += a[i];
    }
    int up = int(sqrt(sum));
    int ans = 0;
    for(int i = up; i >= 1; --i){
        if(sum%i == 0){
            //cout << "i: " << i << " sum/i: " << sum/i << endl;
            if(check(i))  ans = max(ans, i);
            if(check(sum/i)) ans = max(ans, sum/i);
        }
    }
    printf("%d\n", ans);
    return 0;
}
/*

*/

Measured memory_bytes: 2304
m=10**9+7
input()
i=s=r=0
f=1
a=input().split()
for _ in a:
 s+=pow(i+1,m-2,m);r+=int(a[i])*~-s+int(a[~i])*s;i+=1;f=f*i%m
print(r*f%m)

Measured memory_bytes: 11484
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int n, target, count = 0, j, sw = false;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> target;
        if (target == 2)
        {
            count += 1;
        }
        if (target > 2)
        {
            for (j = 2; j < sqrt(target) + 1; j++)
            {
                if (target % j == 0)
                {
                    sw = true;
                    break;
                }
            }
            if (!sw)
            {
                count += 1;
            }
            sw = false;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define check system("pause")
#define all(x) (x).begin(),(x).end()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 0x3f3f3f3f
const ll mod = 1e9+7;
const int N = 1e6+20;
#define dep(i,a,b) for(int i=(a);i>=(b);i--)
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define mes(p,b) memset(p,b,sizeof(p))
#define sz(x) int(x.size())

int main()
{
  	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int h1,h2,m1,m2,t;
	cin>>h1>>m1>>h2>>m2>>t;
	int ans=(h2-h1)*60+m2-m1;
	ans-=t;
	if(ans<0) cout<<0;
	else
	cout<<ans;
	
	
	
	
	
	
	
	
	
	
	
  	return 0;
}



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

using namespace std;

using ll = long long;

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

    int L;
    cin >> L;

    int d = 0;
    for (int p = 2; p <= L; p *= 2) ++d;

    int sum = pow(2, d), res = L - sum;
    const int n = d + 1, m = 2 * d + __builtin_popcount(res);

    cout << n << ' ' << m << '\n';
    for (int i = 1, p = 1; i < n; ++i) {
        cout << i << ' ' << i + 1 << ' ' << 0 << '\n';
        cout << i << ' ' << i + 1 << ' ' << p << '\n';
        p *= 2;
    }

    // add edge : (i + 1) -- sum --> (n)
    for (int i = d - 1; 0 <= i; --i) {
        if (res >> i & 1) {
            cout << i + 1 << ' ' << n << ' ' << sum << '\n';
            sum += pow(2, i);
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int h,n,x,i,j,k,m=0;
     
    for(h=1;h>0;h++)
    {
     
        scanf("%d %d",&n,&x);
 
    for(i=1;i<=n-2;i++)
        {
 
            for(j=i+1;j<=n-1;j++)
            {
             
                for(k=j+1;k<=n;k++)
                {
                    if(i+j+k==x)
                    {
                        m++;
                    }
                }
             
            }
             
        }
 
    if(n==0&&x==0)
    {
        h = h*(-1);
    }
    else
    {
        printf("%d\n",m);
         
        m = 0;
    }
     
  }
 
 
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int ara[4];
int main()
{
	
	int i,j,a,b,c;
	
	cin>>a>>b>>c;
	  ara[a]++;
	ara[b]++;
	ara[c]++;
	int k=0;
	for(i=1;i<=9;i++)
	{
		if(ara[i]!=0)k++;
	}
	if(k==2)
 cout<<"Yes\n";
	else cout<<"No\n";
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define chmax(x,y) x = max(x,y)

 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
typedef vector<LL> VL;
typedef vector<vector<long long>> VVLL;
const int MOD = 1e9+7;
const int INF = 1e9;
const LL LINF = 1e18;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  string N; cin >> N;
  string ans = "No";
  REP(i, 3) {
    if(N[i] == '7') ans = "Yes";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
H, W = map(int, input().split())
matrix = []
ans = []
for i in range(H):
    h = list(input())
    if "#" in h:
        matrix.append(h)
for j in range(W):
    w = [w_[j] for w_ in matrix]
    if "#" in w:
        ans.append(w)
for k in range(len(ans[0])):
    print("".join([r[k] for r in ans]))

Measured memory_bytes: 3188
import math
import sys
from operator import itemgetter

# N, K = map(int, input().split())
# h = list(map(int, input().split()))
# S = [input() for _ in range(H)]
# X = [[0 for j in range(100)] for i in range(200)]


def solve(a):
	a = sorted(a, reverse = True)
	ans = a[0] // 2
	for i in range(1, len(a)):
		ans += a[i]
	print(ans)

if __name__ == '__main__':
	### input
	n = int(input())
	arr = []
	for i in range(n):
		arr.append(int(input()))
	###solve
	solve(arr)
	
	

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n,k;
	cin>>n>>k;
	vector<ll> h(n);
	for(int i=0;i<n;++i){
		cin>>h[i];
	}
	if(k>=n){
		cout<<"0";
		return 0;
	}
	ll cnt=0;
	sort(h.begin(),h.end());
	for(int i=0;i<n-k;++i){
		cnt+=h[i];
	}
	cout<<cnt<<"\n";
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int	main(void)
{
  	int		N;
  	char	s[100];
  	char	t[100];
  	int		num;
  	int		i;
  
  	num = scanf("%d", &N);
  	if (num != 1)
      	return (0);
  
  	num = scanf("%s %s", s, t);
  	if (num != 2)
      	return (0);
  
  	for (i=0; i<N; i++)
    {
      	printf("%c%c", s[i], t[i]);
    }
  	return (0);
}

Measured memory_bytes: 128
#include<stdio.h>


int main(void){
  int n;

  scanf("%d", &n);
  printf("%d\n", fib(n));

  return 0;
}

int fib(int n){
  int n1=1, n2=1, tmp=0, i;
  for(i=1; i<n ; i++){
    tmp = n1 + n2;
    n1 = n2;
    n2 = tmp;
  }
    return n2;
}

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

int main(){
	int n;
	cin >> n;
	int* h = new int[n];
	for(int i=0;i<n;i++) cin >> h[i];
	int tmp=0;
	int tmp_max=0;
	for(int i=0;i<n-1;i++){
		//cout << i << " " << tmp << endl;
		if(h[i] >= h[i+1])tmp++;
		else{
			if(tmp > tmp_max) tmp_max = tmp;
			tmp=0;
		}if(i == n-2){
			if(tmp > tmp_max) tmp_max = tmp;
		}
	}
	cout << tmp_max << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {    
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);          
          
        String A = sc.next();
        String B = sc.next();
        
        if(A.charAt(0) == 'H' && B.charAt(0) == 'H' || A.charAt(0) == 'D' && B.charAt(0) == 'D'){
            System.out.println('H');
        }else{
            System.out.println('D');
        }        
        
    }            
}
        
        

Measured memory_bytes: 19412
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

struct Era{
	string name;
	int start, end;
};

int main()
{
	ios_base::sync_with_stdio(0);
	int N, Q;
	while (cin >> N >> Q, N ){
		Era era[N];
		rep (i, N ){
			int y1, y2;
			cin >> era[i].name >> y1 >> y2;
			era[i].end = y2;
			era[i].start = y2 - y1 + 1;
		} // end rep
		rep (j, Q ){
			int year; cin >> year;

			string ans1 = "";
			int ans2 = 0;
			rep (i, N ){
				if (era[i].start <= year && year <= era[i].end ){
					ans1 = era[i].name;
					ans2 = year - era[i].start + 1;
					break;
				} // end if
			} // end rep

			if (ans2 != 0 ){
				cout << ans1 << ' ' << ans2 << endl;
			}else{
				cout << "Unknown" << endl;
			} // end if
		} // end rep
	} // end while
		
	return 0;
}

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

int main() {
  string S;
  cin >> S;

  string words[4] ={"dream", "dreamer", "erase", "eraser"};
  
  reverse(S.begin(), S.end());
  for (int i = 0; i < 4; i++) reverse(words[i].begin(), words[i].end());

  bool can = true;
  for (int i = 0; i < S.size();) {
    bool can2 = false;
    for (int j = 0; j < 4; j++) {
      string d = words[j];
      if (S.substr(i, d.size()) == d) {
        can2 = true;
        i += d.size();
      }
    }
    if (!can2) {
      can = false;
      break;
    }
  }
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

int main() {
  long long a,b;
  cin >> a >> b;
  
    if((a%2==0 && b%2==0) || (a%2==1 && b%2==1)){
    cout << (a+b)/2 << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} 


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

i64 N; cin >> N;
VI mi, pl;
rep(i, 0, N){
    int a; cin >> a;
    if (a >= 0) pl.push_back(a);
    else mi.push_back(a);
} 
sort(ALL(pl), greater<i64>());
sort(ALL(mi));

if (mi.empty()) mi.push_back(pl.back()), pl.pop_back();
if (pl.empty()) pl.push_back(mi.back()), mi.pop_back();

VI x, y;
rep(i, 1, mi.size()){
    x.push_back(pl[0]);
    y.push_back(mi[i]);
    pl[0] -= mi[i];
}
rep(i, 1, pl.size()){
    x.push_back(mi[0]);
    y.push_back(pl[i]);
    mi[0] -= pl[i];
}
x.push_back(pl[0]);
y.push_back(mi[0]);
cout << pl[0] - mi[0] << "\n";
rep(i, 0, N-1) cout << x[i] << " " << y[i] << "\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 5236
from heapq import heappush, heappop


def main():
    while True:
        n, m = map(int, input().split())
        if n == 0:
            break
        s, g = map(int, input().split())
        s -= 1
        g -= 1
        edges = [[] for _ in range(n)]
        for _ in range(m):
            x, y, d, c = map(int, input().split())
            x -= 1
            y -= 1
            edges[x].append((y, d, c))
            edges[y].append((x, d, c))

        que = []
        heappush(que, (0, 1, s, None))
        dic = {}
        dic[(1, None, s, None)] = 0
        INF = 10 ** 20
        ans = INF
        while que:
            score, speed, node, pre_node= heappop(que)
            if score >= ans:break
            for to, dist, limit in edges[node]:
                if to == pre_node or speed > limit:continue
                new_score = score + dist / speed
                if speed == 1 and to == g and ans > new_score:ans = new_score
                for new_speed in (speed - 1, speed, speed + 1):
                    if new_speed <= 0:continue
                    if (new_speed, to, node) not in dic or dic[(new_speed, to, node)] > new_score:
                        dic[(new_speed, to, node)] = new_score
                        heappush(que, (new_score, new_speed, to, node))
        if ans == INF:
            print("unreachable")
        else:
            print(ans)


main()



Measured memory_bytes: 11152
import java.util.Scanner;

class Main {
	int W,N;
	int[] w,v;
	int[][] dp;
	int count;
	
	public static void main(String args[]){
		Main app = new Main();
		Scanner scan = new Scanner(System.in);
		app.count = 0;
		while(true){
			app.W = Integer.valueOf(scan.nextLine());
			if(app.W==0){
				break;
			}
			app.N = Integer.valueOf(scan.nextLine());
			app.w = new int[app.N];
			app.v = new int[app.N];
			String[] str;
			for(int i=0;i<app.N;i++){
				str = scan.nextLine().split(",");
				app.v[i] = Integer.valueOf(str[0]);
				app.w[i] = Integer.valueOf(str[1]);
			}
			app.dp = new int[app.N+1][app.W+1];
			app.count++;
			app.DP(app.count);
		}
	}
	
	public void DP(int count){
		for(int i=0;i<N;i++){
			for(int j=0;j<W+1;j++){
				if(j<w[i]){
					dp[i+1][j] = dp[i][j];
				}else{
					dp[i+1][j] = Math.max(dp[i][j],dp[i][j-w[i]]+v[i]);
				}
			}
		}
		
		for(int i=W;i>0;i--){
			if(dp[N][i]>dp[N][i-1]){
				System.out.println("Case "+count+":");
				System.out.println(dp[N][i]);
				System.out.println(i);
				break;
			}
		}
	}
}

Measured memory_bytes: 31324
H,W,K = map(int,input().split())
c = [tuple(input()) for i in range(H)]
ans = 0
for i in range(2**H):
    s = i
    b = [list(x) for x in c]
    for j in range(H):
        if s >= (2**(H-j-1)):
            s -= 2**(H-j-1)
            b[j] = ["."]*W
    b = list(zip(*b))
    for k in range(2**W):
        bt = [list(x) for x in b]
        t = k
        for l in range(W):
            if t >= (2**(W-l-1)):
                t -= 2**(W-l-1)
                bt[l] = ["."]*H
        u = sum(bt[m].count("#") for m in range(W))
        if u == K:
            ans += 1
print(ans)

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i ++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i --)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {T a; K b;};

int main( void ){
	initialize();
	ll N, B, C;
	cin >> N >> B >> C;
	map<ll, ll> mp;
	mp[N]++;
	mp[B]++;
	mp[C]++;
	if (mp[N] == 2|| mp[B] == 2 || mp[C] == 2)
		cout << "Yes\n";
	else
		cout << "No\n";
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
	// cin.tie( 0 );
	// ios::sync_with_stdio( false );
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

ll L, A, B, M;

vector<vector<ll>>& operator*=(vector<vector<ll>>& lhs, vector<vector<ll>> rhs) {
    auto result = lhs;
    for (ll i = 0; i < result.size(); i++) {
        for (ll j = 0; j < result[i].size(); j++) {
            result[i][j] = 0;
            for (ll k = 0; k < lhs.size(); k++) {
                (result[i][j] += lhs[i][k] * rhs[k][j] % M) %= M;
            }
        }
    }
    return lhs = result;
}

int main() {
    cin >> L >> A >> B >> M;

    ll ans = 0;
    ll pre = 0;
    ll s = A;
    for (ll d = 1; d <= 18; d++) {
        ll target = 1;
        for (ll j = 0; j < d; j++) {
            target *= 10;
        }
        ll low = pre - 1, eq_high = L;
        while (low != eq_high - 1) {
            ll mid = (low + eq_high) / 2;
            ll s_mid = A + B * mid;
            (s_mid < target ? low = mid : eq_high = mid);
        }

        ll C_d = eq_high - pre;
        pre = eq_high;

        vector<vector<ll>> mat = {
                { target % M,     0, 0 },
                {          1,     1, 0 },
                {          0, B % M, 1 }
        };

        vector<vector<ll>> result = {
                { 1, 0, 0 },
                { 0, 1, 0 },
                { 0, 0, 1 }
        };

        while (C_d) {
            if (C_d % 2 == 1) {
                result *= mat;
            }

            C_d /= 2;
            mat *= mat;
        }

        vector<ll> v = { ans, s, 1 };
        ans = 0;
        s = 0;
        for (ll i = 0; i < 3; i++) {
            (ans += v[i] * result[i][0] % M) %= M;
            (s += v[i] * result[i][1] % M) %= M;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
use std::vec::Vec;

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 read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let (n, k) = read_touple::<usize>();
    let mut h: Vec<usize> = read_vec();

    h.sort_by(|a, b| b.cmp(&a));
    let mut ans: usize = 0;
    for i in k..n {
      ans += h[i];
    }

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


Measured memory_bytes: 13560
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
using namespace std;
#define make_pair mp
#define pb push_bacck
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;

const int jx[] = {-1,0,1,
						2,2,2,
						1,0,-1,
						-2,-2,-2};
const int jy[] = {-2,-2,-2,
						-1,0,1,
						2,2,2,
						1,0,-1};
//const int sx[] = {-1,0,1,-1,0,1,-1,0,1};
//const int sy[] = {-1,-1,-1,0,0,0,1,1,1};

int n;
//int park[10][10];
pii sp[10];
//bool memo[10][9];

bool isInside( int x, int y ){
	return ( 0 <= x && x < 10 && 0 <= y && y < 10 );
}

bool dfs( int x, int y , int pos ){
	//cout << "pos:" << pos << " " << x << "," << y << endl;
	if( pos == n ) return true;
	for( int i = 0; i < 12; i++ ){
		int nx = x + jx[i],
				ny = y + jy[i];
		if( !isInside(nx,ny) ) continue;
		if( abs(nx - sp[pos].first) <= 1 && abs(ny - sp[pos].second) <= 1 ){
			if( dfs(nx,ny,pos+1) ) return true;
		}
		/*for( int j = 0; j < 9; j++ ){
			int nsx = sp[pos].first + sx[j],
					nsy = sp[pos].second + sy[j];
			if( !isInside(nsx,nsy) || !memo[pos][j] ) continue;
			if( nx == nsx && ny == nsy ){
				if( dfs(nx,ny,pos+1) ) return true;
				else memo[pos][j] = false;
			}
		}*/
	}
	return false;
}

int main(){
	int px, py;
	while( cin >> px >> py, px || py ){
		/*for( int i = 0; i < 10; i++ ){
			for( int j = 0; j < 9; j++ ){
				memo[i][j] = true;
			}
		}*/
		cin >> n;
		for( int i = 0; i < n; i++ ){
			cin >> sp[i].first >> sp[i].second;
		}
		if( dfs(px,py,0) ) cout << "OK" << endl;
		else							 cout << "NA" << endl;
	}
}

Measured memory_bytes: 1152
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    s=input().replace("BC","X")
#    print(s)
    c=0
    d=0
    for i in s:
        if i=="A":
            c+=1
        elif i=="X":
            d+=c
        else:
            c=0
    print(d)
#    while "AX" in s:
#        s=s.replace("AX","XA")
#        print(s)
if __name__ == '__main__':
    main()

Measured memory_bytes: 67564
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
//---------------------------------------------------------------------------------------------------
typedef pair<int,int> P;

int main(void){
    // Your code here!
    int n; cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    Rort(d);
    int ans = 1 ;
    rep(i,n-1) {
        if (d[i+1] < d[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  int n; cin >> n;
  int ans = 1e9;
  for(int i = 0; i <= n; ++i) {
    // tmp6 円分を 6^p で支払う
    int tmp6 = i;
    int cnt = 0;
    while(true) {
      if(tmp6 == 0) break;
      cnt += tmp6%6;
      tmp6 /= 6;
    }
    // tmp9 円分を 9^p で支払う
    int tmp9 = n-i;
    while(true) {
      if(tmp9 == 0) break;
      cnt += tmp9%9;
      tmp9 /= 9;
    }
    ans = min(ans, cnt);
  }
  cout << ans << '\n';
  return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ll<<62)-1)
#define cINFINT ((1<<30)-1)


class Graph
{
public:
	explicit Graph( int nodeSize )
		: mNodeSize( nodeSize )
		, mEdgeSize( 0 )
		, mEdge( nodeSize )
		, mDepth( nodeSize )
		, mMark( nodeSize )
		, mMark2( 0 )
		{}
	
	// Edge定義
	struct Edge
	{
		bool operator<( const Edge& other )
		{ return this->cost != other.cost ?
			this->cost < other.cost : this->to < other.to;  }
		int to; int cost; int rev;
	};
	
	// Edge情報を読み取る
	void readEdge_Undirect_NoCost( int m ) { readEdge_( m, false, false ); }
	void readEdge_Direct_NoCost( int m ) { readEdge_( m, true, false ); }
	void readEdge_Undirect_Cost( int m ) { readEdge_( m, false, true ); }
	void readEdge_Direct_Cost( int m ) { readEdge_( m, true, true ); }
	void readEdge_Direct_Flow( int m ) { readEdge_Flow_( m ); }
	
private:
	void readEdge_( int m, bool isDirected, bool isCost )
	{
		REP( i, m )
		{
			int a, b, c = 1, r = -1;
			cin >> a >> b;
			if( isCost ) cin >> c;
			mEdge[a-1].push_back( { b-1, c, -1 } );
			if( !isDirected ) mEdge[b-1].push_back( { a-1, c, r } );
			++mEdgeSize;
		}
	}
	void readEdge_Flow_( int m )
	{
		REP( i, m )
		{
			int a, b, c;
			cin >> a >> b >> c;
			mEdge[a-1].push_back( { b-1, c, int(mEdge[b-1].size()) } );
			mEdge[b-1].push_back( { a-1, 0, int(mEdge[a-1].size() - 1) } );
			++mEdgeSize;
		}
	}
	
public:
	// 必要なときだけメモリ確保するように
	void assignMark2()
	{
		vector<int> tmp( mNodeSize, cINFINT );
		mMark2.assign( mNodeSize, tmp );
	}
	void setupMark2ForCost()
	{
		REP( i, mNodeSize )
		{
			mMark2[i][i] = 0;
			for( const auto& e : mEdge[i] ) mMark2[i][e.to] = e.cost;
		}
	}


public:
	// MARK構造体
	struct MARK
	{
		int num = 0;
		MARK& operator+=( const MARK& rhs )
		{
			this->num += rhs.num;
			return *this;
		}
	};

public:
	int mNodeSize; // VertexSize
	int mEdgeSize; // EdgeSize
	vector< vector< Edge > > mEdge; // 隣接リスト
	
	// 作業用変数
	vector<int> mDepth /* Used */;
	vector<int> mMark;
	// 必要なときだけメモリ確保するように
	vector< vector<int> > mMark2;
};

ll ansnum = 1;
ll k = 0;
void dfs_tree_depth_( Graph& g, int v )
{
	ll lc = k - 2;
	if( v == 0 ) ++lc;
	for( const auto& e : g.mEdge[v] )
	{
		if( g.mDepth[e.to] >= 0 ) continue;
		g.mDepth[e.to] = g.mDepth[v] + 1;

		ansnum = ansnum*max(0ll, lc)%cMOD;
		--lc;

		dfs_tree_depth_( g, e.to );
	}
}
void dfs_tree_depth( Graph& g, int rootNode )
{
	fill( ALL( g.mDepth ), -1 );
	g.mDepth[rootNode] = 0;
	ansnum = ansnum*k%cMOD;
	dfs_tree_depth_( g, rootNode );
}

int main()
{
	cin.tie( 0 ); ios::sync_with_stdio( false );
	ll n;
	cin >> n >> k;
	Graph g( n );
	g.readEdge_Undirect_NoCost( n-1 );
	
	dfs_tree_depth(g,0);
	cout << ansnum << endl;
	
	return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int a, b, x;
	scanf("%lld%lld%lld", &a, &b, &x);
	if(a == 0){
		printf("%lld\n", b / x + 1);
	}
	else{
		printf("%lld\n", b / x - (a - 1) / x);
	}
	return 0;
}

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

using namespace std;

int main() {
    int r, d, x;
    cin >> r >> d >> x;
    vector<int> xs = vector<int>();
    int xx = x;
    for (int i = 1; i <= 10; i++) {
        xx = r * xx - d;
        cout << xx << endl;
    }

    return 0;
}

Measured memory_bytes: 888
n = int(input())
line = input().split(" ")
a = list(map(int, line))
a.sort(reverse=True)
ascore = 0
bscore = 0
for i in range(0, len(a)):
    if i % 2 == 0:
        ascore += a[i]
    else:
        bscore += a[i]
print(ascore - bscore)


Measured memory_bytes: 3060
N,M = map(int, input().split())

from collections import defaultdict
d = defaultdict(list) 
for i in range(N):
    a,b = map(int, input().split())
    d[a].append(b)

import heapq
q = []
ans = 0
for i in range(1,M+1): #1~MまでOK
    ls = d[i]
    for l in ls:
        heapq.heappush(q,-l)
    if len(q)==0:continue
    a = heapq.heappop(q)
    # print(i,ls,-a)
    ans += a
print(-ans)

Measured memory_bytes: 77912
n=int(input())
s=list(input())
li=[]
a=0
if n%2==1:
  print("No")
else:
  for i in range(0,n//2):
    li.append(s[i])
  for i in range(0,n//2):
    if s[i+n//2]==li[i]:
      a=a+0
    else:a=a+1
  if a==0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
using namespace std;

int main() {
	string  a, b, c;
	cin >> a >> b >> c;
	a.at(0) = a.at(0) - 32;
	b.at(0) = b.at(0) - 32;
	c.at(0) = c.at(0) - 32;
	cout << a.at(0) << b.at(0) << c.at(0);
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var S = new string[N];
            var MARCH = new long[5];
            var answer = 0L;
            for (var i = 0; i < S.Length; i++)
            {
                S[i] = Console.ReadLine();
                switch (S[i][0])
                {
                    case 'M': MARCH[0]++; break;
                    case 'A': MARCH[1]++; break;
                    case 'R': MARCH[2]++; break;
                    case 'C': MARCH[3]++; break;
                    case 'H': MARCH[4]++; break;
                }
            }

            for (var i = 0; i < 3; i++)
            {
                for (var j = i + 1; j < 4; j++)
                {
                    for (var k = j + 1; k < 5; k++)
                    {
                        if (MARCH[i] > 0 && MARCH[j] > 0 && MARCH[k] > 0)
                        {
                            answer += MARCH[i] * MARCH[j] * MARCH[k];
                        }
                    }
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13408
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
#define all(c) (c).begin(), (c).end()
#define rep(i, a, n) for( ll i=a; i<n; i++)
#define repp(i, a, n, p) for( ll i=a; i<n; i+=p)
#define pb push_back
#define mp make_pair

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

    if ( a % b == 0 ){
        cout << "0" << endl;
    }

    else {
        ll at = a/b;
        ll Min = min ( abs(a - at*b), abs(a- (at+1)*b));
        cout << Min << endl;
    }
}



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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define int long long

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

const ll MOD = 1e9;
ll res = 0, rem = 0;
int n;
//2 bal + 100, 5 bal + 100
vector<vector<int>> v, dp;
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    v.assign(121, vector<int>(121, 0));
    dp.assign(121, vector<int>(121, 0));
    for(int i = 0; i < n; ++i){
        string s; cin >> s; int pos = -1;
        for(int i = 0; i < sz(s); ++i){
            if(s[i] == '.') pos = i;
        }
        if(pos == -1){
            pos = sz(s); s += '.';
        }
        while(sz(s) - pos <= 9) s += '0';
        s.erase(s.begin() + pos);
        ll x = std::stoll(s, 0, 10);
        // cout << s << " " << x << "\n";
        ll cur = x, den = MOD;
        // cout << cur << " " << den << "\n";
        if(x == cur/MOD) rem++;
        while(cur%2 == 0 && den%2 == 0){
            cur /= 2; den /= 2;
        }
        while(cur%5 == 0 && den%5 == 0){
            cur /= 5; den /= 5;
        }
        // cout << cur << " " << den <<  "\n";
        int a = 0, b = 0, c = 0, d = 0;
        while(cur%2 == 0){
            cur /= 2; a++;
        }
        while(den%2 == 0){
            den /= 2; b++;
        }
        while(cur%5 == 0){
            cur /= 5; c++;
        }
        while(den%5 == 0){
            den /= 5; d++;
        }
        if(a - b >= 0 && c - d >= 0) rem++;
        v[a - b + 60][c - d + 60]++;
    }
    // for(int i = 50; i <= 65; ++i){
    //     for(int j = 50; j <= 65; ++j){
    //         cout << v[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    // cout << "\n";
    vector<vector<int>> tst(3, vector<int>(6, 0));
    // tst[0][5] = tst[0][]
    for(int i = 119; i >= 0; --i){
        for(int j = 119; j >= 0; --j){
            // if(i == 55 && j == 61) cout << dp[i + 1][j] << " " << dp[i][j + 1] << " " << dp[i + 1][j + 1] << " " << v[i][j] << " " << dp[i][j] << "\n";
            dp[i][j] = dp[i + 1][j] + dp[i][j + 1] - dp[i + 1][j + 1] + v[i][j];
        }
    }
    // for(int i = 50; i <= 65; ++i){
    //     for(int j = 50; j <= 65; ++j){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    for(int i = 0; i < 120; ++i){
        for(int j = 0; j < 120; ++j){
            int a2 = i - 60, a5 = j - 60;
            a2 *= -1, a5 *= -1;
            res += v[i][j] * dp[a2 + 60][a5 + 60];
            // if(v[i][j] > 0 && dp[a2 + 60][a5 + 60] > 0){
                // cout << i - 60 << " " << j - 60 << " " << v[i][j] << "\n";
                // cout << a2 << " " << a5 << " " << dp[a2 + 60][a5 + 60] << " \n\n";
            // }
        }
    }
    cout << (res - rem)/2;
    return 0;
}

Measured memory_bytes: 3888
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 4*1001001001001001001;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) {
            res = res * x % mod;
        }
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main () {
    
    const ll MAX_N = 2010; 
    vector<vector<ll> > c(MAX_N, vector<ll>(MAX_N, 0));
    for (ll i = 0; i < MAX_N; i++) {
        c[i][0] = 1;
        c[i][1] = i;
    }
    for (ll i = 1; i < MAX_N; i++) {
        for (ll j = 1; j <= i; j++) {
            c[i][j] = c[i-1][j] + c[i-1][j-1];
            c[i][j] %= MODLL;
         }
    }
    
    ll n,k; cin >>n>>k;

    for (ll i = 1; i <= k; i++) {
        ll res = c[k-1][i-1]; 
        //cout << res << endl;
        res *= c[n-k+1][i];
        //cout << c[n-k+1][i] << endl;
        //cout << n-k-(i-1)+1 << " " << i << endl;
        res %= MODLL; 
        cout << res << endl;
    }

    return 0;
}



Measured memory_bytes: 31872
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[51];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	bool flag=false;
	int cnt=0;
	for(int i=0;i<N-1;i++){
		if(A[i]<A[i+1]){
			cnt++;
		}
	}
	if(cnt==N-1){
		cout<<"YES"<<endl;
		return 0;
	}
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			bool flag2=true;
			swap(A[i],A[j]);
			for(int k=0;k<N-1;k++){
				if(A[k]>A[k+1]){
					flag2=false;
				}
			}
			if(flag2==true){
				flag=true;
			}
			swap(A[i],A[j]);
		}
	}
	if(flag==true){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <deque>
#include <map>
#include <iomanip>
#include <limits>
#include <map>

using namespace std;

const int CMax = 100002;
const int CVMax = 102;
const int CInf = 2000000001;
const long long CMod = 1000000007;

int n, A[CMax], tmp;

long long gcd(long long a, long long b)
{
    if (b != 0) return gcd(b, a % b);
    else return a;
}

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);

    printf("%d\n", max(a+b, max(a-b, a*b)));

    return 0;
}


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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int N = 100 + 7;
int n, f[N], x;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> x >> n;
  for (int i = 1; i <= n; i++) {
    int val;
    cin >> val;
    f[val] = 1;
  }
  int mn = (int) 1e9;
  for (int i = 0; i < N; i++) {
    if (f[i] == 0) {
      mn = min(mn, abs(i - x));
    }
  }
  for (int i = 0; i < N; i++) {
    if (f[i] == 0 && abs(i - x) == mn) {
      cout << i << "\n";
      return 0;
    }
  }
  return 0;
}


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

int main(){
  int i=2;
  int a[1000000];
  cin >> a[1];
  if(a[1]==1||a[1]==2||a[1]==4){
    cout << 4 << endl;
    return 0;
  }

  while(1){

      if(a[i-1]%2==0){
        a[i] = a[i-1]/2;
      }else{
        a[i] = 3*a[i-1]+1;
      }
      if(a[i]==4){
        break;
      }
      i++;
  }

  cout << i+3 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
const int max_n = 1e5;
const ll mod = 1e9+7;
int main(){
  ll n; cin >> n;
  cout << (n*(n-1))/2 << endl;
  return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.Functor
import Data.List

readInts = map read . words <$> getLine :: IO [Int]

data Day = SUN | MON | TUE | WED | THU | FRI | SAT
  deriving (Read, Enum)

solve :: Day -> Int
solve s = 7 - fromEnum s

main = solve <$> readLn >>= print

Measured memory_bytes: 508
n = gets.to_i
a = n.times.map { gets.to_i - 1 }

b = 0
count = 0
visited = Hash.new
loop do
  break if b == 1
  visited[b] = true

  if visited[a[b]]
    count = -1
    break
  end

  b = a[b]
  count += 1
end

puts count

Measured memory_bytes: 9084
#include<iostream>
#include<cstring>

using namespace std;

int main(){
	char s[110];
	int cnt = 0;
	 while(cin >> s) {
	int i = 0, j = strlen(s) - 1;
	for(i = 0; i <= j; i++,j--)
		if(s[i] != s[j]) break;
		if(i > j) cnt++;
		}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1136
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func main() {
	S := getString()
	T := getString()
	A := getInt()
	B := getInt()
	U := getString()
	
	if U == S {
		A--
	} else if U == T {
		B--
	}
	
	fmt.Println(A, B)
}

type Graph struct {
	n     int
	edges [][]int
}

func NewGraph(n int) *Graph {
	g := &Graph{
		n:     n,
		edges: make([][]int, n),
	}
	return g
}

func (g *Graph) AddEdge(u, v int) {
	g.edges[v] = append(g.edges[v], u)
	g.edges[u] = append(g.edges[u], v)
}

func dfs(c int, edges [][]int, visited map[int]struct{}) {
	visited[c] = struct{}{}

	for _, v := range edges[c] {
		_, flag := visited[v]
		if flag {
			continue
		}
		dfs(v, edges, visited)
	}
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p%2 == 0 {
		t := powMod(n, p/2)
		return calcMod(t * t)
	} else {
		return n * powMod(n, p-1)
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray)-1])
}

func calcMod(x int) int {
	return x % mod
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	if sc.Text() == "1" {
		fmt.Println("Hello World")
		return
	}
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	b, _ := strconv.Atoi(sc.Text())
	fmt.Println(a + b)
}


Measured memory_bytes: 640
def gcd(x, y)
  if (y > x)
    tmp = y
    y = x
    x = tmp
  end
  if (x % y == 0)
    return y
  else
    return gcd(y, x%y)

  end
end
while (str = gets)
  a, b = str.split(" ").map(&:to_i)
  puts [gcd(a, b), (a * b) / gcd(a, b)].join(" ")
end


Measured memory_bytes: 6852