akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

int N,M,i,j;
int a[3000],b[3000],c[3000];
int64_t dist[1010];
int64_t ans;
bool negative[1010];

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  cin>>N>>M;
  for(i=0;i<M;i++){
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;
    b[i]--;
    c[i]=-c[i];
  }
  for(i=0;i<N;i++){
    dist[i]=LINF;
  }
  dist[0]=0;

  for(i=0;i<N-1;i++){
    for(j=0;j<M;j++){
      if(dist[a[j]]==LINF)continue;
      if(dist[b[j]] > dist[a[j]] + c[j]){
        dist[b[j]] = dist[a[j]] + c[j];
      }
    }
  }

  ans=dist[N-1];
  for(i=0;i<N;i++){
    negative[i]=false;
  }
  for(i=0;i<N;i++){
    for(j=0;j<M;j++){
      if(dist[a[j]]==LINF)continue;

      if(dist[b[j]] > dist[a[j]] + c[j]){
        dist[b[j]] = dist[a[j]] + c[j];
        negative[b[j]]=true;
      }

      if(negative[a[i]] == true){
        negative[b[i]]=true;
      }
    }
  }

  if(negative[N-1]){
    cout << "inf" << endl;
  }else{
    cout << -ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
A = []
for i in range(3):
    a, b = map(int, input().split())
    A.append(a)
    A.append(b)
A = sorted(Counter(A).most_common())
ans = 'NO'
if A == [(1, 1), (2, 2), (3, 2), (4, 1)]:
    ans = 'YES'
print(ans)

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

using namespace std;

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

        int maxi=(n+1)/2;
        if(maxi>=k)
        {
                cout<<"YES"<<endl;
        }
        else
        {
                cout<<"NO"<<endl;
        }
        return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [0 for _ in range(2)]
for i in range(2):
  a[i] = [int(x) for x in input().strip().split()]

b1 = a[0][0]
b2 = sum(a[1])
ans = b1 + b2
for i in range(1, n):
  b1 += a[0][i]
  b2 -= a[1][i-1]
  ans = max(ans, b1+b2)
print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for(int i=0; i<n; ++i)
        cin >> a[i];

    long long ans = accumulate(a.begin(), a.end(), 0LL);
    vector<int> b = a;
    for(int i=1; i<n; ++i){
        for(int j=0; j<n; ++j){
            b[j] = min(b[j], a[(i+j)%n]);
        }
        ans = min(ans, x * (long long)i + accumulate(b.begin(), b.end(), 0LL));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<29;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;






int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c; cin >> a >> b >> c;
    if(b-a == c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a,b;
	do{
		scanf("%d %d",&a,&b);
	}while(a<-1000 || a>1000 || b<-1000 || b>1000);
	if(a<b)
		puts("a < b");
	else if(a>b)
		puts("a > b");
	else
		puts("a == b");
	return 0;
}

Measured memory_bytes: 580
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int> >;
using vii = vector<pair<int, int> >;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int dp[101][4][4][4];

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

	dp[0][3][3][3] = 1;

	rep(len, n) {
		rep(c1, 4) {
			rep(c2, 4) {
				rep(c3, 4) {
					if (dp[len][c1][c2][c3] == 0) continue;

					rep(a, 4) {
						if (a == 2 && c1 == 1 && c2 == 0) continue;
						if (a == 2 && c1 == 0 && c2 == 1) continue;
						if (a == 1 && c1 == 2 && c2 == 0) continue;
						if (a == 2 && c1 == 1 && c3 == 0) continue;
						if (a == 2 && c2 == 1 && c3 == 0) continue;


						dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3];
						dp[len + 1][a][c1][c2] %= mod;
					}
				}
			}
		}
	}
	int ans = 0;

	rep(c1, 4) {
		rep(c2, 4) {
			rep(c3, 4) {
				ans += dp[n][c1][c2][c3];
				ans %= mod;
			}
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
a = gets.to_i
# b = gets.to_i
# s = gets.chomp
# s,t = gets.split.map(&:to_s)
# n= gets.split.map(&:to_i)

# s = gets.chomp.chars.uniq
# puts gets.chomp.chars.uniq.size != 1 ? "Yes" : "No"
p a**3

Measured memory_bytes: 1788
import kotlin.collections.getValue

data class Key(val cost: Int, val canOpen: Int)

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map(String::toInt)

    var canOpenAll = 0.inv().shl(n)

    val keys = Array(m) {
        val (a, b) = readLine()!!.split(" ").map(String::toInt)
        val canOpen = readLine()!!
            .split(" ")
            .map(String::toInt)
            .fold(0) { r, c -> r or 1.shl(c - 1) }

        canOpenAll = canOpenAll or canOpen

        Key(a, canOpen)
    }

    if (canOpenAll != 0.inv()) {
        println(-1)
        return
    }

    val openAll = 0.inv().shl(n).inv()
    val dp = Array(openAll + 1) { Double.POSITIVE_INFINITY }
    dp[0] = 0.0

    keys.forEach {
        for (state in 0..openAll) {
            val nextState = state or it.canOpen
            val nextCost = dp[nextState]
            val newCost = it.cost + dp[state]
            if (newCost < nextCost) dp[nextState] = newCost
        }
    }

    println(dp[openAll].toInt())
}


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

#ifdef _MSC_VER
int debug = 1;
#else
int debug = 0;
#endif

int main() {
    int n;
    cin >> n;
    auto a = vector<int>(n + 5);
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    auto balls_in = vector<int>(n + 5);

    for (int i = n; i >= 1; i--) {
        auto sum = 0;
        for (int j = i + i; j <= n; j += i)
            sum += balls_in[j];
        if (sum % 2 != a[i]) {
            balls_in[i] = 1;
        }
    }

    cout << count(balls_in.begin(), balls_in.end(), 1) << "\n";
    for (int i = 1; i <= n; i++) {
        if (balls_in[i]) {
            cout << i << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 2432
import numpy as np
import random
import time 

random.seed(1111)
start=time.time()
D=int(input())
C=np.array(list(map(int,input().split())))
last_day=np.array([-1 for _ in range(26)])
score=np.array([list(map(int,input().split())) for _ in range(D)])
output=[0 for _ in range(D)]

#初期貪欲法
for day in range(D):
    today_point=C*(day-last_day)
    S_today=sum(today_point)
    for k in range(26):
        today_point[k]=score[day][k]-S_today+today_point[k]
 
    if day!=D-1:
        max_score=-1*float("inf")
        for k in range(26):
            nday_point=C*((day+1)-last_day)
            S_nday=sum(nday_point)-C[k]*(day-last_day[k])
            
            for i in range(26):
                if k!=i:
                    nday_point[i]=score[day+1][i]-S_nday+nday_point[i]
                else:
                    nday_point[i]=score[day+1][i]-S_nday+C[i]
 
                if today_point[k]+nday_point[i]>max_score:
                    max_score=today_point[k]+nday_point[i]
                    idx=k
    else:
        idx=np.argmax(today_point)
    
    last_day[idx]=day
    output[day]=idx+1

def score_cal(output):
    ans=0
    memo=np.array([-1 for _ in range(26)])
    for day in range(D):
        t=output[day]-1
        memo[t]=day
        tmp=C*(memo-day)
        ans=ans+score[day][t]+sum(tmp)
    return ans

  
random_day=[i for i in range(D)]
random_con=[i+1 for i in range(26)]

cnt=0
while time.time()-start<1.85:
    tmp_output=output[:]
    cnt+=1
    d=random.choice(random_day)
    con=random.choice(random_con)
    tmp_output[d]=con
    
    if score_cal(tmp_output)>score_cal(output):
        output[d]=con
      
print(*output,sep="\n")


Measured memory_bytes: 27312
n, m, x = map(int, input().split())
l = []
for _ in range(n):
    temp = list(map(int, input().split()))
    l.append(temp)

ans = 99999999

for i in range(2 ** n):
    bag = []
    for j in range(n):  # bit全探索
        if (i >> j) & 1:
            bag.append(l[j])
    skill = [0] * m
    enough = [0] * m  # 各スキルにつき、xを超えているかどうかを判断
    cost = 0
    for sub in bag:
        cost += sub[0]
        for kk in range(1, m+1):
            skill[kk - 1] += sub[kk]
            if skill[kk - 1] >= x:
                enough[kk - 1] += 1
    if 0 not in enough:  # すべてのスキルがxを超えていたら価格を計算
        if ans > cost:
            ans = cost  # 最低価格を下回っていたら更新
if ans == 99999999:  # 初期値からの変更がなければ-1を、そうでなければ最低価格を出力
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9236
#include<bits/stdc++.h>
#define FAST std::ios::sync_with_stdio(false);
#define endl '\n'
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MAX_N 100005
#define Mem(a,b) memset(a,b,sizeof(a))
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
using namespace std;

int cost[205][205];
int dis[205][205];
vector<int>vec;
int main()
{
    FAST;
    //FREI;
    int n,m,r;
    cin>>n>>m>>r;

    for(int i=0; i<=n; i++)
        for(int j=0; j<=n; j++)
            cost[i][j]=dis[i][j]=1e9;
    int tmp;
    for(int i=0; i<r; i++)
    {
        cin>>tmp;
        vec.push_back(tmp);
    }
    sort(vec.begin(),vec.end());
    int u,v;
    for(int i=0; i<m; i++)
    {
        cin>>u>>v>>tmp;
        cost[u][v]=cost[v][u]=tmp;
        dis[u][v]=dis[v][u]=tmp;
    }
    for(int k=1; k<=n; k++)
        for(int i=1; i<=n; i++)
            for(int j=1; j<=n; j++)
                if(dis[i][k]+dis[k][j]<dis[i][j])
                    dis[i][j]=dis[i][k]+dis[k][j];
    int cnt=1;
    int ans=1e9;

    for(int i=2; i<=r; i++)cnt*=i;
    for(int i=0; i<=cnt; i++)
    {
        bool flag=1;
        tmp=0LL;
        for(int j=0; j<vec.size()-1; j++)
        {
            tmp+=dis[vec[j]][vec[j+1]];
            //cout<<vec[j]<<"  "<<vec[j+1]<<"  asdf"<<tmp<<endl;
        }
        if(flag)ans=min(ans,tmp);
        next_permutation(vec.begin(),vec.end());
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e18;

int main(){
    string a;
    cin >> a;
    ll l = a.size();
    ll ans = l*(l-1)/2;
    map<char,ll>mp;
    rep(i,l){
        mp[a[i]]++;
    }
    for(auto it=mp.begin();it!=mp.end();it++){
        ll now = it->second;
        ans -= now*(now-1)/2;
    }
    ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int q;
    cin >> q;
    lli lparen = 0;
    lli rparen = 0;
    REP (i, 0, q) {
        int p, n;
        char c;
        cin >> p >> c >> n;
        if (c == '(') lparen += n;
        if (c == ')') rparen += n;
        if (lparen == rparen) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

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

    long long m = N / K;
    long long ans = m * m * m;
    if (K % 2 == 0) {
        long long l = 2 * N / K - m;
        ans += (l * l * l);
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int a, b, x;
	cin >> a >> b >> x;
	V dp(101010, upper);
	dp[0] = 0;
	rep(i,100001) {
		chmin(dp[i + 1000], dp[i] + a);
		chmin(dp[i + 500], dp[i] + b);
	}
	int ans = upper;
	REP(i, x, 100001) {
		chmin(ans, dp[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3348
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define int long long
#define F first
#define S second
#define endl "\n"
using namespace std;

const int nax = 3e5+5;
const int inf = 1e18;
const int mod = 1e9+7;

int n,m;
int a[nax], b[nax];
vector<int>adj[nax];

/*
 * DO SOMETHING RATHER THAN DOING NOTHING
 * */
int dp[101][nax];
signed main(){
    fast;
    cin>>n>>m;
    int mx = 0;
    for (int i = 0; i < n; i++)
    {
        cin>>a[i]>>b[i];
        mx = max(mx, b[i]);
    }
    for (int i = 0; i < 101;i++){
        for (int j = 0; j < nax;j++){
            dp[i][j] = inf;
        }
    }
        // base case
        dp[0][0] = 0;
    dp[0][b[0]] = a[0];
    for (int i = 1; i <n; i++)
    {
        dp[i][0] = 0;
        for (int j = 1; j < nax; j++)
        {
            dp[i][j] = dp[i-1][j];
            if(b[i]<=j){
                dp[i][j] = min(dp[i][j], dp[i - 1][j - b[i]] + a[i]);
            }
        }
    }
        int ans = 0;
    for(int i=nax;i>=0;i--){
        if(dp[n-1][i] <= m){
            ans = i;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 247396
#include <stdio.h>
#include <iterator>
#include <vector>

using namespace std;

int main()
{
  int n,q,c,t,x;
  vector<vector<long long int> > a;

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

  for (int i = 0; i < n; i++) {
    a.emplace_back();
  }

  for (int i = 0; i < q; i++) {
    scanf("%d", &c);
    scanf("%d", &t);
    if (c == 0){
      scanf("%d", &x);
      a[t].push_back(x);
    }else if (c == 1){
      for ( vector<long long int>::iterator itr=begin(a[t]); itr!=end(a[t]); ++itr ) {
        printf("%lld",*itr);
        if (itr!=end(a[t])-1){
          printf(" ");
        }
      }
      printf("\n");
    }else if (c == 2){
      a[t].clear();
    }

  }
  return 0;
}



Measured memory_bytes: 8524
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt();
    int h = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();

    System.out.print((double) w * h / 2);
    System.out.print(" ");
    int multipleWays = (x == (double) w / 2 && y == (double) h / 2) ? 1 : 0;
    System.out.println(multipleWays);
  }
}

Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
using ll=long long;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    for(ll i=0;i<N;i++){
        cin>>A[i];
        A[i]-=i;
    }
    sort(A.begin(), A.end());
    ll ave=A[N/2];
    ll ans=0;
    for(ll i=0;i<N;i++){
        ans+=abs(A[i]-ave);
    }
    cout << ans;
}

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

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

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 25;
int a[N];
int b[N];
int c[N];

int n;

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        cin >> b[i];
    }
    for (int i = 1; i < n; ++i) {
        cin >> c[i];
    }
    int sum = 0;
    int p = -1;
    for (int i = 1; i <= n; ++i) {
        int k = a[i];
        sum += b[k];
        if (k == p + 1)
            sum += c[p];
        p = k;
    }
    cout << sum << endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
ll mod = 1000000007;

int main(){
    ll n, k;
    cin >> n >> k;
    vecll h(n);
    for(auto& i : h) cin >> i;

    ll ans = 0;
    for(ll i = 0; i < n; i++){
        if(h.at(i) >= k) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#define N 36

typedef struct trump{
  char mark;
  int value;
} TRUMP;

TRUMP *bubble(TRUMP *,int);
TRUMP *selection(TRUMP *,int);
void swap(TRUMP *,TRUMP *);
void listprint(TRUMP *,int num);
void JUDGE(TRUMP *,TRUMP *,int);

int main()
{
  int num;
  char tmp[3];
  TRUMP C_in[N],C1[N],C[N];
  TRUMP *bubble_C,*selection_C;

scanf("%d",&num);
for(int i = 0; i < num; i++){
  scanf("%s",tmp);
  C_in[i].mark = tmp[0];
  C_in[i].value = atoi(&tmp[1]);
  C[i] = C_in[i];
  C1[i] = C_in[i];
}

bubble_C = bubble(C,num);
selection_C = selection(C1,num);

listprint(bubble_C,num);
JUDGE(C_in,bubble_C,num);

listprint(selection_C,num);
JUDGE(C_in,selection_C,num);

  return 0;
}

TRUMP *bubble(TRUMP *C,int num){
  for(int i = 0; i < num; i++){
    for(int j = num - 1; j > i; j--){
      if(C[j].value < C[j-1].value) swap(&C[j],&C[j-1]);
    }
  }
  return C;
}

TRUMP *selection(TRUMP *C,int num){
  int minj,i,j;
  for(i = 0; i < num; i++){
    minj = i;
    for(j = i; j < num; j++){
      if(C[j].value < C[minj].value) minj = j;
    }
    swap(&C[i],&C[minj]);
  }
  return C;
}

void swap(TRUMP *x,TRUMP *y){
  TRUMP tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

void listprint(TRUMP *C,int num){
  for(int i = 0;i < num - 1; i++){
    printf("%c%d ",C[i].mark,C[i].value);
  }
  printf("%c%d\n",C[num - 1].mark,C[num-1].value);
}

void JUDGE(TRUMP *in,TRUMP *out,int num){
  int cnt = 0;
  for(int i = 0; i < num; i++){
    for(int j = i + 1; j < num;j++){
      for(int k = 0; k < num; k++){
        for(int l = k + 1; l < num; l++){
          if((in[i].value == in[j].value) && (in[i].value == out[l].value) && (in[j].value == out[k].value) && (in[i].mark == out[l].mark) && (in[j].mark == out[k].mark) && (cnt == 0)){
            printf("Not stable\n");
            cnt++;
          }
        }
      }
    }
  }
  if(cnt == 0) printf("Stable\n");
}



Measured memory_bytes: 2104
#include <iostream>
using namespace std;
int main(void){
    
    int N, gift;;

    
    while(cin >> N, N){
        
        int maxNum = 0, count = 0;
        
        for(int i = 0; i < N; i++){
            cin >> gift;
            if(gift > 0){
                count++;
                if(maxNum < gift) maxNum = gift;
            } 
 
        }
        
        if(maxNum < 2) cout << "NA" << endl;
        else cout << count + 1 << endl;
    }

}



Measured memory_bytes: 3096
n = int(input())
peaple = []
for i in range(n):
  a = int(input())
  tests = []
  for j in range(a):
    x, y = input().split()
    tests.append((int(x) - 1, y))
  peaple.append(tests)
  
maximum = 0
for h_bit in range(1, 1<<n):
  h_str = format(h_bit, '0{}b'.format(n))
  flag = False
  for i in range(n):
    if h_str[i] == '1':
      for test in peaple[i]:
        if h_str[test[0]] != test[1]:
          flag = True
          break
    if flag:
      break
  if not flag:
    maximum = max(maximum, h_str.count('1'))
print(maximum)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        for (int i = 0; i < 2; i++) {
            if (a > b) {
                ans += a;
                a--;
            } else {
                ans += b;
                b--;
            }
        }
        System.out.println(ans);
    }

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


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i <= r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = (119 << 23) + 1, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 1e5 + 5;
int n, a[N];
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	fw (i, 1, n) cin >> a[i];
	sort(a + 1, a + n + 1);
	int ans = 1;
	fw (i, 0, n - 1) ans = 1ll * ans * __gcd(i, a[i + 1]) % mod;
	cout << ans; 
	return 0;
}

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

using namespace std;
#define int long long
int r(int x)
{
    int ans=1;
    while(x%ans==0)
    {
        ans*=2;
    }
    ans/=2;
    return ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    bool h=true;
    if(n>m)
    {
        h=false;
        swap(n,m);
    }
    int sz1=(1<<n)-1;
    int sz2=(1<<m)-1;
    int res[sz1][sz2];
    int pr[sz1+1][sz2];
    for(int i=0;i<sz1;++i)
    {
        pr[i][0]=0;
        for(int j=0;j<sz2;++j)
        {
            int x=r(i+1); // power
            if((j+1) & x)
            {
                res[i][j]=(pr[i][j]+1)%2;
                pr[i][j+1]=1;
            }
            else
            {
                res[i][j]=pr[i][j];
                pr[i][j+1]=0;
            }
        }
    }
    if(h)
    {
        for(int i=0;i<sz1;++i)
        {
            for(int j=0;j<sz2;++j)
            {
                cout<<res[i][j];
            }
            cout<<endl;
        }
    }
    else
    {
        for(int i=0;i<sz2;++i)
        {
            for(int j=0;j<sz1;++j)
            {
                cout<<res[j][i];
            }
            cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 17664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const ll mod = 1e9+7;

struct edge{
    int to;
    ll cost;
};

const int N = 100000;
vector<edge> G[N];

const ll INF = LLONG_MAX/3;

vector<ll> dijk(int start, int n){
    vector<ll> d(n,INF);
    d[start] = 0;

    using P = pair<ll,int>;
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push({0,start});
    while(!pq.empty()){
        P now = pq.top();
        pq.pop();
        int v = now.se;
        if(now.fi > d[v]) continue;
        for(const auto &e:G[v]){
            if(d[e.to] > d[v]+e.cost){
                d[e.to] = d[v]+e.cost;
                pq.push({d[e.to], e.to});
            }
        }
    }
    return d;
}

vector<ll> pat(int start, int n, const vector<ll> &dd){
    vector<ll> ret(n);
    ret[start] = 1;

    using P = pair<ll,int>;
    priority_queue<P, vector<P>, greater<P>> pq;
    vector<bool> vis(n);
    pq.push({0,start});
    while(!pq.empty()){
        P now = pq.top();
        pq.pop();
        int v = now.se;
        if(vis[v]) continue;

        for(const auto &e:G[v]){
            if(dd[e.to] == dd[v]+e.cost){
                (ret[e.to] += ret[v]) %= mod;
                pq.push({dd[e.to], e.to});
            }
        }
        vis[v] = true;
    }
    return ret;
}

int main(){
    int n,m,s,t;
    cin >>n >>m >>s >>t;
    --s;
    --t;

    vector<int> u(m),v(m);
    vector<ll> d(m);
    rep(i,m){
        cin >>u[i] >>v[i] >>d[i];
        --u[i];
        --v[i];
        G[u[i]].pb({v[i],d[i]});
        G[v[i]].pb({u[i],d[i]});
    }

    vector<ll> ds = dijk(s,n), dt = dijk(t,n);
    ll D = ds[t];

    vector<bool> ok(n);
    rep(i,n) ok[i] = (ds[i]+dt[i] == D);

    vector<ll> ps = pat(s,n,ds), pt = pat(t,n,dt);

    ll ans = (ps[t]*ps[t])%mod;
    rep(i,m){
        int a = u[i], b = v[i];
        if(!ok[a] || !ok[b]) continue;
        if(ds[a]>dt[a] && ds[b]<dt[b]) swap(a,b);

        if(ds[a]<dt[a] && ds[b]>dt[b] && ds[a]+d[i]==ds[b]){
            ll sub = (ps[a]*pt[b])%mod;
            sub = (sub*sub)%mod;
            ans = (ans-sub+mod)%mod;
        }
    }
    rep(i,n)if(ok[i] && ds[i]==dt[i]){
        ll sub = (ps[i]*pt[i])%mod;
        sub = (sub*sub)%mod;
        ans = (ans-sub+mod)%mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 22616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Point[] points = new Point[n];

            double sum = 0.0;
            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                double x = double.Parse(input[0]);
                double y = double.Parse(input[1]);
                points[i] = new Point(x, y);

                if (i != 0)
                {
                    sum += (points[i - 1] - points[0]).Cross(points[i] - points[0]);
                }
            }
            Console.WriteLine("{0:f1}", sum / 2);
        }
    }

    class Point : IComparable<Point>
    {
        static readonly double EPS = 1E-10;

        internal double x, y;

        public Point(double x, double y)
        {
            this.x = x;
            this.y = y;
        }

        public double Abs { get { return Math.Sqrt(Norm); } }
        public double Norm { get { return x * x + y * y; } }

        public double Dot(Point p) { return x * p.x + y * p.y; }
        public double Cross(Point p) { return x * p.y - y * p.x; }

        public static Point operator +(Point a, Point b) { return new Point(a.x + b.x, a.y + b.y); }
        public static Point operator -(Point a, Point b) { return new Point(a.x - b.x, a.y - b.y); }
        public static Point operator *(Point p, double d) { return new Point(p.x * d, p.y * d); }
        public static Point operator /(Point p, double d) { return new Point(p.x / d, p.y / d); }
        public static bool operator <(Point a, Point b) { return Math.Abs(a.x - b.x) > EPS ? a.x < b.x : a.y < b.y; }
        public static bool operator >(Point a, Point b) { return Math.Abs(a.x - b.x) > EPS ? a.x > b.x : a.y > b.y; }
        public static bool operator ==(Point a, Point b) { return Math.Abs(a.x - b.x) < EPS && Math.Abs(a.y - b.y) < EPS; }
        public static bool operator !=(Point a, Point b) { return Math.Abs(a.x - b.x) >= EPS || Math.Abs(a.y - b.y) >= EPS; }

        public int CompareTo(Point other)
        {
            return x != other.x ? (int)(x - other.x) : (int)(y - other.y);
        }

        public override bool Equals(object obj)
        {
            Point other = obj as Point;
            return Math.Abs(x - other.x) < EPS && Math.Abs(y - other.y) < EPS;
        }

        public override int GetHashCode()
        {
            return x.GetHashCode() ^ y.GetHashCode();
        }

        public override string ToString()
        {
            return string.Format("{0:f10} {1:f10}", x, y);
        }
    }

    class Segment
    {
        internal Point p1, p2;

        public Segment(Point p1, Point p2)
        {
            this.p1 = p1;
            this.p2 = p2;
        }
    }

    class Circle
    {
        internal Point p;
        internal double r;

        public Circle(Point p, double r)
        {
            this.p = p;
            this.r = r;
        }
    }
}

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

int ecnt[3000030], wcnt[300030];

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

int main(void)
{
    int n, i;
    string s;
    cin >> n >> s;
    wcnt[0] = 0;
    for(i = 1; i <= n; i++) {
        wcnt[i] = wcnt[i-1] + (s[i-1]=='W'?1:0);
    }
    ecnt[n+1] = 0;
    for(i = n; i > 0; i --) {
        ecnt[i] = ecnt[i+1] + (s[i-1]=='E'?1:0);
    }

/*
    REP(j, n+2) cout << wcnt[j] << " ";
    cout << endl;
    REP(j, n+2) cout << ecnt[j] << " ";
    cout << endl;
*/
    int mi = n * 2;
    int m;
    for(i = 1 ; i <= n; i++) {
        m = wcnt[i-1] + ecnt[i+1];
        mi = min(m, mi);
    }
    cout << mi << endl;
}


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

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

    int n;
    cin>>n;

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

    int ans = 0;

    for (int i=0; i<=n; i++)
        if (string(s.begin()+n-i, s.end()) == string(t.begin(), t.begin()+i))
            ans = i;

    cout<<2*n-ans<<endl;
}


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

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

  vector<int> d(n,0);
  for (int i=0; i<n; i++) cin >> d[i];

  sort(d.begin(), d.end());
  d.erase(unique(d.begin(),d.end()), d.end());
  cout << d.size() << endl;

}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H, W;
    cin >> H >> W;
    string s = string((W+2), '#');
    cout << s << endl;
    for (int i = 0; i < H; i++) {
        cout << '#';
        string input;
        cin >> input;
        cout << input;
        cout << '#' << endl;
    }
    cout << s << endl;
    


}

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

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
string s;
ll k;
ll size;

string func(ll i, ll k){
	if(k==0) return s;
	if(i==size-1){
		ll j=k%26;
		if(j > 'z'-s[i] && s[i] !='a'){
			j-='z'-s[i]+1;
			
			s[i]='a';
			s[i]+=j;
			return s;
		}
		else {
			s[i]+=j;
			return s;
		}
	}
	else if(k>'z'-s[i] && s[i]!='a'){
		
		k-=(ll)('z'-s[i]+1);
		s[i]='a';
		i++;
		return func(i,k);
	}
	else {
		i++;
		return func(i,k);
	} 
		
}

void solve(){
	ll i=0;
	size=s.length();
	cout << func(i,k);
}

int main(){
	cin >> s >> k;
	solve();
	return 0;
}

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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int r, d, x;
    cin >> r >> d >> x;
    for (int i = 1; i <= 10; i++) {
        x = r * x - d;
        cout << x << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, q;
string s;
int l, r;
int rui[100001];

signed main() {
	int i;
	
	cin >> n >> q >> s;
	for (i = 0; i < n - 1; i++) {
		if (s[i] == 'A' && s[i + 1] == 'C') rui[i + 1] = 1;
	}
	for (i = 1; i <= n; i++) rui[i] += rui[i - 1];
	
	for (i = 0; i < q; i++) {
		cin >> l >> r;
		l--; r--;
		cout << rui[r] - rui[l] << endl;
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
ll n,x,t;
cin >> n >> x >> t;
ll ans = 0;
ll cnt = -x;
for (ll i = 0; i < 1500000;i+=t){
    cnt += x;
    if(cnt>=n){
        ans = i;
        break;
    }
}
cout << ans << endl;
}

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

//using
using namespace std;


//define static const typedef
#define FOR(i, s, n) for(int i = s; i < int(n); i++)
#define REP(i, n) FOR((i), 0, (n))
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SORT(a) sort(ALL(a))
#define RSORT(a) sort(RALL(a))
#define DUMP(x) cerr << #x << " = " << x << "\n";
#define DEBUG(x) cerr << #x << " = " << x << " (L:" << __LINE__ << ") " << __FILE__ << "\n";
#define F first
#define S second

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;

static const int INF = 1 << 25;
static const int movex[] = {0,0,1,-1};
static const int movey[] = {1,-1,0,0};
//global
static int a, b, c, ans, hp = 1;
static VS mp;
static int sx = INF, sy = INF;
static string str = "";
static char inp[1000];
static vector<VVI> ar;
static queue<pair<int, PII > >  n;
//function
int main(){
  scanf("%d %d %d", &a, &b, &c);
  REP(i, b + 2){
    str = str + "X";
  }
  mp.PB(str);
  REP(i, a){
    scanf("%s", inp);
    mp.PB(inp);
    mp[i + 1] = "X" + mp[i + 1] + "X";
    REP(j, mp[i + 1].size()){
      if(sx != INF){
	break;
      }
      if(mp[i + 1][j] == 'S'){
	sy = i + 1;
	sx = j;
	break;
      }
    }
  }
  ar.resize(c, VVI(a + 2, VI(b + 2)));
  REP(i, c){
    REP(j, a + 2){
      REP(k, b + 2){
	ar[i][j][k] = INF;
	if(!i && sy == j && sx == k){
	  ar[0][j][k] = 0;
	}
      }
    }
  }
  mp.PB(str);
  n.push(pair<int, PII>(hp, PII(sy, sx)));

  while(!n.empty()){
    if(n.front().F != hp){
      n.pop();
      continue;
    }
    if(hp == mp[n.front().S.F][n.front().S.S] - '0'){
      hp++;
      if(hp > c){
	ans = ar[c - 1][n.front().S.F][n.front().S.S];
	break;
      }
      ar[hp - 1][n.front().S.F][n.front().S.S] = ar[hp - 2][n.front().S.F][n.front().S.S];
    }
    int nowy = n.front().S.F, nowx = n.front().S.S;
    n.pop();
    REP(i, 4){
      if(mp[nowy + movey[i]][nowx + movex[i]] != 'X' && ar[hp - 1][nowy + movey[i]][nowx + movex[i]] > ar[hp - 1][nowy][nowx] + 1){
	ar[hp - 1][nowy + movey[i]][nowx + movex[i]] = ar[hp - 1][nowy][nowx] + 1;
	n.push(pair<int, PII>(hp, PII(nowy + movey[i], nowx + movex[i])));
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 42456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 2000000
#define vmax 10000
#define sentinel 2000000000
#define INF (1<<30)
constexpr long long int inf = 1000000000000;
constexpr long long int rinf = -(INT64_MAX);
//cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);

int H,a[MAX+1];

void maxheapify(int i){
    int l=2*i,r=2*i+1,largest;
    if(l<=H&&a[l]>a[i]) largest=l;
    else largest=i;
    if(r<=H&&a[r]>a[largest]) largest=r;

    if(largest!=i){
        swap(a[i],a[largest]);
        maxheapify(largest);
    }
}

int extract(){
    int maxv;
    if(H<1) return -INF;
    maxv=a[1];
    a[1]=a[H];
    H--;
    maxheapify(1);
    return maxv;
}

void increasekey(int i,int key){
    if(key<a[i]) return ;
    a[i]=key;
    while(i>1&&a[i]>a[i/2]){
        swap(a[i],a[i/2]);
        i/=2;
    }
}

void insert(int key){
    H++;
    a[H]=-INF;
    increasekey(H,key);
}

int main() {
    int key;
    char com[10];

    while(1){
        scanf("%s",com);
        if(com[0]=='e'&&com[1]=='n') break;
        if(com[0]=='i'){
            scanf("%d",&key);
            insert(key);
        }else{
            printf("%d\n",extract());
        }
    }
    return 0;
}






Measured memory_bytes: 7040
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/

#define N 200

#define rep(i, n) for(int  i = 0; i < (n); i++)
#define max(a,b) ((a>b)?a:b)
#define ABS(a) (((a)>(0))?a:-(a))

int main(void)
{
  int flag = 0;
  char S[N] = {};
  int n;

  scanf("%d", &n);
  for (size_t i = 1; i <= n; i++) {
    scanf(" %c", &S[i]);
  }
  if (n%2 != 0) {
    printf("No\n" );
    return 0;
  }

    if (strncmp(&S[1],&S[1+n/2],n/2)) {
      flag = 1;
    }

  if (flag == 1) {
    printf("No\n" );
    return 0;
  }else{
    printf("Yes\n" );
    return 0;
  }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MAX=1e18;
ll mod=1e9+7;
#define pb push_back
#define se second
#define fi first
#define maxe max_element
#define mine min_element
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
vector<int> graph[205];
int color[205];
int nCk[100][100];
bool bipartite_jugding(int v, int c){
    color[v] = c;
    for(int i = 0; i < graph[v].size(); ++i){
        if(color[graph[v][i]] == c) return false;
        if(color[graph[v][i]] == 0 && !bipartite_jugding(graph[v][i], -c)){
            return false;
        }
    }
    return true;
}

 void combi() {
	for (int i = 0; i <= 99; ++i) nCk[i][0] = 1;
	for (int i = 1; i <= 99; ++i) for (int j = 1; j <= i; ++j) {
		nCk[i][j] = (nCk[i-1][j] + nCk[i-1][j-1]) % mod;
	}
}

long long expo(ll x,ll n,ll M)
{

    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*expo((x*x)%M,(n-1)/2,M))%M;

}

void solve()
{
   int n,m;
   cin>>n>>m;
   if(n==m)
    cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;

}

int main(){
    boost;
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int nextInt() {
  int x;
  cin >> x;
  return x;
}
int main() {
  int n;
  cin >> n;
  set<int> A;
  while (n--) A.insert(nextInt());
  int m;
  cin >> m;
  set<int> B;
  while (m--) B.insert(nextInt());
  set<int> C;
  for (auto a : A)
    if (B.find(a) == B.end()) C.insert(a);
  for (auto b : B)
    if (A.find(b) == A.end()) C.insert(b);
  for (auto c : C) cout << c << endl;

  return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n,m,x;
    cin >> n >> m >> x;
    vector<map<vector<int32>,int32>> dp(n+1);
    dp[0][vector<int32>(m,0)] = 0;
    REP(i,n){
        int32 c;
        cin >> c;
        vector<int32> a(m);
        REP(j,m)cin >> a[j];
        for(auto [v,prec] : dp[i]){
            if(dp[i+1].find(v) == dp[i+1].end())dp[i+1][v] = prec;
            else dp[i+1][v] = min(dp[i+1][v],prec);
            vector<int32> ky = v;
            REP(j,m)ky[j] = min(x,ky[j]+a[j]);
            if(dp[i+1].find(ky) == dp[i+1].end())dp[i+1][ky] = prec+c;
            else dp[i+1][ky] = min(dp[i+1][ky],prec+c);
        }
    }
    int32 ans = INF;
    for(auto [v,cst] : dp[n]){
        bool flg = true;
        REP(i,m){
            if(v[i] < x){
                flg = false;
                break;
            }
        }
        if(flg)
            ans = min(ans, cst);
    }
    if(ans == INF)ans = -1;
    ANS(ans);
    return 0;
}

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

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  
  int asize = a.size();
  int bsize = b.size();
  int csize = c.size();
  
  string ans = "NO";
  
  if(a.at(asize -1) == b.at(0) && b.at(bsize -1) == c.at(0)){
    ans = "YES";
  }
  
  cout << ans << endl;
}
  
  

Measured memory_bytes: 256
######################
#     _        ____  #
# U  /"\  u U /"___| #
#  \/ _ \/  \| | u   #
#  / ___ \   | |/__  #
# /_/   \_\   \____| #
#  \\    >>  _// \\  #
# (__)  (__)(__)(__) #
# Compro by NULL_CT© #
######################
from sys import stdin
import numpy as np
import math

input = stdin.readline

def divisor(_n):
    result = []
    for i in range(1, int(math.sqrt(_n)) + 1):
        if _n % i == 0:
            result.append(i)
            if _n % (_n / i) == 0:
                result.append(int(_n / i))
    return result

n = int(input())
s = input()

ans = 0

for i in range(0, len(s)-2):
    if s[i] + s[i + 1] + s[i + 2] == "ABC":
        ans+=1

print(ans)



Measured memory_bytes: 27104
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define erep(i, n) for (int i = 0; i <= (n); i++)
#define erep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;


int main() {
    int N;
    int a[3] = {0};
    cin >> N;
    a[0] = N / 100;
    a[1] = (N - a[0] * 100) / 10;
    a[2] = (N - a[0] * 100 - a[1] * 10);
    rep(i,3){
        if(a[i]==7){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

void solve () {
	int x, n;
	cin >> x >> n;

	int a[101];
	memset(a, 0, sizeof(a));
	int it;
	for (int i = 0; i < n; i++) {
		cin >> it;
		a[it] = 1;
	}

	if (a[x] == 0) {
		cout << x << endl;
		return;
	}

	int l = 0, r = 101;
	for (int i = x; i < 101; i++) {
		if (a[i] == 0) {
			r = i;
			break;
		}
	}
	for (int i = x; i >= 1; i--) {
		if (a[i] == 0) {
			l = i;
			break;
		}
	}
	cout << ((r - x) < (x - l) ? r : l) << endl;
}

int main () {
	/*int t;
	cin >> t;
	while (t--) {
		solve();
	}*/
	
	solve();

	return 0;
}


Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
int main() {
	while (1) {
		int a,ans,ace;
		char dum;
		ans = ace = 0;
		while (~fscanf(stdin, "%d%c", &a,&dum)) {
			if (a == 0) return 0;
			if (a > 10) ans += 10;
			else if (a == 1) ace++,ans++;
			else ans += a;
			if (dum == '\n') break;
		}
		if (ans > 21) ans = 0;
		else {
			while (ace) {
				if (ans + 10 <= 21) ans += 10;
				ace--;
			}
		}
		P(d, ans);
	}
	return 0;
}

Measured memory_bytes: 604