akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    ll n, m;
    cin >> n >> m;
    n -= 2;
    m -= 2;
    if (n < 0)
        n = 1;
    if (m < 0)
        m = 1;
    c(n * m);
    return 0;
}

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

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

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int res = (in.nextInt() - 1) / 2;
            out.print(res);
        }

    }
}



Measured memory_bytes: 21588
#include<cstdio>
#include<cmath>
using namespace std;
long long x[1001],y[1001],sol[50];
char s[50];
long long putere2(long long x)
{
    if(x==0)
        return 0;
    long long i=1;
    while(i-1+i<=x-1)
    {
        i*=2;
    }
    return i-1+i;
}

int main()
{
    //freopen("f.in","r",stdin);
    //freopen("f.out","w",stdout);
    long long n,i,j;
    long long ok=1,val;
    scanf("%lld",&n);
    scanf("%lld%lld",&x[1],&y[1]);
    val=((long long)fabs(x[1])+(long long)fabs(y[1]))%2;
    for(i=2; i<=n; ++i)
    {
        scanf("%lld%lld",&x[i],&y[i]);
        if(((long long)fabs(x[i])+(long long)fabs(y[i]))%2!=val)
        {
            ok=0;
            break;
        }
    }
    if(!ok)
        printf("-1\n");
    else
    {
        long long start=0;
        long long maxim=0,nrsol=0;
        if((x[1]+y[1])%2==0)
        {
            start=1;
            for(i=1; i<=n; ++i)
            {
                x[i]--;
            }
        }
        for(i=1; i<=n; ++i)
        {
            if(maxim<putere2((long long)fabs(x[i]))+(long long)fabs(y[i]))
                maxim=putere2((long long)fabs(x[i])+(long long)fabs(y[i]));
        }
        if(start)
            sol[++nrsol]=1;
        long long val=((maxim-1)/2)+1;
        while(val)
        {
            sol[++nrsol]=val;
            val/=2;
        }
        printf("%lld\n",nrsol);
        for(i=1;i<=nrsol;++i)
        {
            printf("%lld ",sol[i]);
        }
        printf("\n");
        long long poz;
        for(i=1; i<=n; ++i)
        {
            poz=start+1;
            while(sol[poz])
            {
                if((long long)fabs(x[i]-sol[poz])+(long long)fabs(y[i])<=sol[poz]-1)
                {
                    s[poz]='R';
                    x[i]-=sol[poz];
                }
                else
                {
                    if((long long)fabs(x[i]+sol[poz])+(long long)fabs(y[i])<=sol[poz]-1)
                    {
                        s[poz]='L';
                        x[i]+=sol[poz];
                    }
                    else
                    {
                        if((long long)fabs(x[i])+(long long)fabs(y[i]-sol[poz])<=sol[poz]-1)
                        {
                            s[poz]='U';
                            y[i]-=sol[poz];
                        }
                        else
                        {
                            if((long long)fabs(x[i])+(long long)fabs(y[i]+sol[poz])<=sol[poz]-1)
                            {
                                s[poz]='D';
                                y[i]+=sol[poz];
                            }
                        }
                    }
                }
                poz++;
            }
            if(start)
                printf("R");
            for(j=start+1;j<=nrsol;++j)
            {
                printf("%c",s[j]);
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int[] b = new int[n-1];
    for (int i=0;i<n-1;i++){
      b[i] = scan.nextInt();
    }
    int sum = b[n-2]+b[0];
    for (int j=n-2;j>=1;j--){
      sum += b[j];
      if (b[j-1] < b[j]){
        sum += b[j-1] - b[j];
      }
    }

    System.out.println(sum);

  }
}


Measured memory_bytes: 35592
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

ll H, W, N;
vector<ll> a, b;
map<ll, set<ll>> mp;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> H >> W >> N;
  a.resize(N);
  b.resize(N);
  for (ll i = 0; i < N; i++) {
    ll ai, bi;
    cin >> ai >> bi;
    ai--;
    bi--;
    a[i] = ai;
    b[i] = bi;
    mp[ai].insert(bi);
  }

  set<pair<ll, ll>> used;
  vector<ll> ans(10, 0);
  for (ll i = 0; i < N; i++) {
    ll ai = a[i], bi = b[i];
    for (ll h = ai - 2; h <= ai; h++) {
      for (ll w = bi - 2; w <= bi; w++) {
        pair<ll, ll> p = make_pair(h, w);
        if (0 <= h && h < H - 2 && 0 <= w && w < W - 2 && used.find(p) == used.end()) {
          used.insert(p);
          ll cnt = 0;
          for (ll j = h; j < h + 3; j++) {
            for (ll k = w; k < w + 3; k++) {
              if (!mp[j].empty() && mp[j].find(k) != mp[j].end()) {
                cnt++;
              }
            }
          }
          ans[cnt]++;
        }
      }
    }
  }

  ll sum = 0;
  for (auto &e : ans) {
    sum += e;
  }
  ans[0] = (H - 2) * (W - 2) - sum;
  for (auto &e : ans) {
    cout << e << endl;
  }
  return 0;
}

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

using namespace std;

long long gcd(long long a, long long b){
 if(a == 0LL || b == 0LL)
   return max(a, b);
 return gcd(b%a, a);
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long A, B, C, D; cin >> A >> B >> C >> D; 
  long long E = (C*D)/gcd(C, D); 
  --A;
  long long res = B/C + B/D - B/E; 
  res -= A/C + A/D - A/E;
  cout << B-A-res << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long int
#define d 1000000007
using namespace std;
int main()
{
    int t;
    t=1;
    while(t--)
    {
        int n,k;
        cin >> n;
        cin >> k;
        int result=1;
        while(n>0)
        {
            result=min(result*2,result+k);
            n--;
        }
        cout << result << endl;
    }
	return 0;
}

Measured memory_bytes: 3604
s = input()
ans = 0

for i in range(len(s)):
    for j in range(len(s) - i):
        t = s[i:-j] if j != 0 else s[i:]
        c = 0
        for k in t:
            if k == 'A' or k == 'T' or k == 'C' or k == 'G':
                c += 1
        if c == len(t):
            ans = max(ans, len(s) - i - j)
            #print(len(s) - i - j,i,j,t)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

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

int m, a, b, tp[50000];
vi p;

int getPrime(int sp){
  int k[3] = {100, 10, 1};
  int w = 0;
  rep(i, 3){
    for(int j = w; j < (int)p.size(); j+=k[i]){
      if(sp < p[j]) break;
      if(p[j]*sp <= m) w = j;
      else break;
    }
  }
  return p[w];
}

int main(){
  tp[0] = tp[1] = 1;
  REP(i, 2, 50000){
    if(tp[i]) continue;
    for(int j = i+i; j < 50000; j += i) tp[j] = 1;
  }

  rep(i, 50000){
    if(tp[i]) continue;
    p.PB(i);
  }

  while(scanf("%d%d%d", &m, &a, &b) && m){
    int resq = 0, resp = 0;
    for(int i = 0; i < p.size() && p[i] * 2 <= m; i++){
      int tq = p[i];
      int tp = getPrime(tq);
      if((double)a/(double)b > (double)tp/(double)tq) continue;
      if(resq * resp > tp * tq) continue;
      resq = tq;
      resp = tp;
    }

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

Measured memory_bytes: 1460
n=int(input())
G=[[0,[],0,-1]]
for i in range(n):
    v=[int(j) for j in input().split(" ")]
    u=v.pop(0)
    k=v.pop(0)
    G.append([k,v,0,-1])





distance=0
dis_list=[1]
G[1][3]=0
G[1][2]=1
while len(dis_list)!=0:
    distance+=1
    dis_list_cash=[]
    for i in dis_list:
        k=G[i][0]
        v=G[i][1]
        for j in range(k):
            if G[v[j]][2]==0:
                G[v[j]][2]=1
                G[v[j]][3]=distance
                dis_list_cash.append(v[j])
    
    dis_list=dis_list_cash



for i in range(1,n+1):
    print(str(i)+" "+str(G[i][3]))

Measured memory_bytes: 7692
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>

using namespace std;

#define sz			size()
#define lgt			length()
#define rep(i,n)	for (int i = 0; i < n; i++)
#define ALL(X)		(X).begin(),(X).end()
#define RALL(X)		(X).rbegin(),(X).rend()
#define pb			push_back
#define SORT(a)		sort(ALL(a));
#define RSORT(a)	sort(RALL(a));
#define mp			make_pair
#define dump(x)		cerr<<#x<<" = "<<(x)<<endl;
#define fir			first
#define sec			second

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<string> vs;

int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
vs form(string a,char s){vs v;string b;rep(i,a.lgt){if(a[i]==s){v.pb(b);b="";}else b+=a[i];}v.pb(b);return v;}
vi formint(string a,char s){vi v;string b;rep(i,a.lgt){if(a[i]==s){v.pb(toInt(b));b="";}else b+=a[i];}v.pb(toInt(b));return v;}

const double EPS=1e-10,PI=acos(-1.0);
const int INF=2100000000;

int main(void)
{
	int n, m, tmp;
	while (cin >> n >> m, n && m){
		int res = 0;
		vi v, v1;
		
		v.pb(0);
		for (int i = 0; i < n; i++){
			cin >> tmp;
			v.pb(tmp);
		}
		for (int i = 0; i < v.sz; i++){
			for (int j = 0; j < v.sz; j++){
				v1.pb(v[i] + v[j]);
			}
		}
		SORT(v1);
		
		for (int i = 0, j = v1.sz - 1; i < v1.sz && 0 <= j;){
			if (m < v1[i] + v1[j]) j--;
			else {
				res = max(res, v1[i] + v1[j]);
				i++;
			}
		}
		
		cout << res << endl;
		v.clear();
	}
	
	return 0;
}

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

static const int INFTY = 100000;
static const int MAX_N = 100000;
static int L[MAX_N / 2 + 2], R[MAX_N / 2 + 2];

int partition(int A[], int p, int r) {
    auto x = A[r];
    int i = p - 1;
    int j = 0;
    int tmp;
    
    for (j = p; j < r; j++) {
        if (A[j] <= x) {
            i += 1;
            tmp = A[j];
            A[j] = A[i];
            A[i] = tmp;
        }
    }  

    tmp = A[r];
    A[r] = A[i + 1];
    A[i + 1] = tmp;
    return i + 1; 
}

int main() {

    int A[MAX_N], N, i = 0;
    cin >> N;
    for(i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    int idx = partition(A, 0, N - 1);

    for(i = 0; i < N; i++)
    {
        if (i > 0) {
            cout << " ";
        }

        if (i == idx) {
            cout << '[' << A[i] << ']';
        } else {
            cout << A[i];
        }
        
    }

    cout << endl;

    return 0;
}



Measured memory_bytes: 3452
package main
 
import (
  "fmt"
)
 
func main() {
  var N, a int
  fmt.Scan(&N)
  
  min := 1000
  max := 0
  for i := 0; i < N; i++ {
    fmt.Scan(&a)
    if min > a {
      min = a
    }
    if max < a {
      max = a
    }
  }
  
  ans := max - min
  fmt.Printf("%d\n", ans)
}

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

int main()
{
  int a, b, c, x, y ;
  cin >> a >> b >> c >> x >> y ;

  int answer = 1000000000 ;
  int max_i = max(x, y) * 2 ;
  for(int i = 0 ; i <= max_i ; i++)
  {
    if(i == 0)
    {
      answer = min(answer, x * a + y * b) ;
    }
    else if(i % 2 == 0)
    {
      int j = x - i / 2 ;
      int k = y - i / 2 ;
      if(j < 0)
      {
        j = 0;
      }
      if(k < 0)
      {
        k = 0 ;
      }
      answer = min(answer, ( j * a + k * b + c * i )) ;
    }
  }

  cout << answer << endl ;
}


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

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define output_to_error freopen("error.txt" , "w" ,stderr)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'

const int N = 2e5+5;
int arr[N];
int main()
{
	#ifdef LOCAL
        input_from_file;
        output_to_file;
        output_to_error;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	long long h , ans = 0 , cnt = 1;
	cin >> h ; 
	while(h>0)
	{
		ans += cnt ;
		cnt <<= 1;
		h >>= 1;
	}
	cout << ans ;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n, m1, m2; cin >> n >> m1 >> m2;
  vector<int> a(n), b(n), c(n);
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i] >> c[i];
  }

  static int dp[51][501][501];
  fill(dp[0][0], dp[50][500] + 500, 1LL << 60);
  dp[0][0][0] = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 500; j++){
      for(int k = 0; k < 500; k++){
        dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
        dp[i+1][j + a[i]][k + b[i]] = min(dp[i+1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
      }
    }
  }

  int ans = 1LL << 60;
  for(int i = 1; i < 500; i++){
    for(int j = 1; j < 500; j++){
      if(i * m2 == j * m1) ans = min(ans, dp[n][i][j]);
    }
  }
  if(ans >= 1LL << 60) ans = -1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 100224
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>
#include <map>
#include <cmath>


using namespace std;

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

vector<ll> fac, inv;

long long pow(const long long &v, const long long &n, const long long &mod)
{
    long long ret = 1;
    long long num = n;
    long long now = v;
    
    while (num > 0)
    {
        if (num & 1)
        {
            ret = ret * now % mod;
        }
        now = now * now % mod;
        num = num >> 1;
    }
    
    return ret;
}

long long calc(const long long &n, const long long &k, const long long &mod)
{
    long long ret;
    if (n < k)
    {
        return 0;
    }
    
    ret = fac[n] * inv[k] % mod * inv[n - k] % mod;
    
    return ret;
}

int main() {

    
    ll n, k;
    cin >> n >> k;
    
    fac = vector<long long>(n + 1, 1);
    inv = vector<long long>(n + 1, 1);
    
    ll mod = 1e9+7;
    
    for (int i = 1; i <= n; ++i)
    {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = pow(fac[i], mod - 2, mod);
    }
    
    for (ll i = 1; i <= k; ++i)
    {
        ll c1 = calc(n - k + 1ll, i, mod);
        ll c2 = calc(k - 1ll, i - 1ll, mod);
        cout << (c1 * c2) % mod << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
dp=[[0]*3 for _ in range(n)]
dp[0]=l[0]
for i in range(n-1):
    for j in range(3):
        dp[i+1][j]=max(dp[i][(j+1)%3],dp[i][(j+2)%3])+l[i+1][j]
print(max(dp[n-1]))

Measured memory_bytes: 50012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll N;
  cin >> N;
  ll ans = 0;
  rep2(i, 1, N+1){
    if(i % 3 != 0 && i % 5 != 0){
      ans += i;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n; cin >> n;

    vector<ll> a(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
    }

    sort(a.rbegin(), a.rend());

    ll mid = a[0] / 2;

    ll t = LINF;

    ll ans;

    for (ll i = 1; i < n; ++i) {
        if (abs(mid - a[i]) < t) {
            t = abs(mid - a[i]);
            ans = a[i];
        }
    }

    cout << a[0] << ' ' << ans << endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll n;cin >>n;
    vector<ll>l(n+1,0);
    vector<ll>r(n+1,0);
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        l[i+1]=__gcd(l[i],a[i]);
    }
    reverse(all(a));
    for (int i = 0; i < n; ++i) {
        r[i+1]=__gcd(r[i],a[i]);
    }
    reverse(all(r));
    ll ans=0;
    for (int i = 1; i <=n; ++i) {
        ans=max(ans,__gcd(r[i],l[i-1]));
//        cout<<l[i-1]<<" "<<r[i]<<endl;
    }
    cout <<ans <<endl;
    return 0;
}


Measured memory_bytes: 2560
q, h, s, d = [int(i) for i in input().split()]
n = int(input())
d = min(min(d, s*2), min(h*4, q*8))
s = min(s, min(h*2, q*4))
h = min(h, q*2)
ans = (n // 2) * d
n %= 2
while n > 0:
    if n >= 1:
        n -= 1
        ans += s
    elif n >= 0.5:
        n -= 0.5
        ans += h
    else:
        n -= 0.25
        ans += q

print(ans)

Measured memory_bytes: 9152
using System;
using System.Linq;

class Program{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int N = int.Parse(input[0]);
    int K = int.Parse(input[1]);
    int Q = int.Parse(input[2]);
    
    var list = Enumerable.Repeat(K - Q, N).ToArray();
    
    for (int q = 0; q < Q; q++)
    {
      int a = int.Parse(Console.ReadLine());
      list[a - 1] = list[a - 1] + 1;
    }
    
    string[] buf = new string[N];
    for (int i = 0; i < N; i++)
    {
      if (list[i] <= 0){
        buf[i] = "No";
      }
      else
      {
        buf[i] = "Yes";
      }
    }
    
    string ans = string.Join("\n", buf);
    
    Console.WriteLine(ans);
    
  }
}

Measured memory_bytes: 18784
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <bits/stdc++.h>
//#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
#define rt0 return 0
#define LL long long

using namespace std;

int main()
{
	string s;
	int k;
	vector<string> buf;
	
	cin>>s;
	cin>>k;
	int len=s.size();
	for(int i=0;i<len;i++) {
		for(int j=1;j<=5;j++) {
			if(i+j>len) break;
			string temp=s.substr(i,j);
			buf.push_back(temp);
		}
	}
	sort(buf.begin(),buf.end());
	
	int tt=atoi(s.c_str());
	
	int count=1;
	if(k==1){
		cout<<buf[0];
		rt0;
	}
	for(int j=1;j<buf.size();j++){
		if(buf[j]==buf[j-1]) continue;
		if(++count==k){
			cout<<buf[j];
			rt0;
		}		
	}
	
	
    rt0;
}


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

int main(void) {
    string s;
    int count = 0;
    cin >> s;
    int len = s.length();
    int max = len / 2;
    for(int i =0; i < max;i++) {
        if (s.at(i) != s.at(len - i - 1)) {
            count++;
        }       
    }

    cout << count;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007



int main() {
  int N, L;
  cin >> N >> L ;
  vector<string> S(N);
  rep(i, N) {
    cin >> S.at(i);
  }

  sort(all(S));

  string t = "";
  rep(i, N) {
    t += S.at(i);
  }

  cout << t << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,n) (int i=a;i<n;i++)
#define per(i,a,n,s) (int i=n-1;i>=a;i--)
#define range(...) _overload3(__VA_ARGS__,per,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vecin(x) for(auto&youso_: (x) ) cin >>  youso_
#define vecout(x) for(auto&youso_: (x) ) cout << youso_ << " " ; cout << endl
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int inf = 1e9+10;
const int mod = 1e9+7;
const long long llinf = 1e18;
#define _GLIBCXX_DEBUG
// head

struct UnionFind {
    vector<int> data;
    UnionFind(int sz) : data(sz, -1) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x;
        return true;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
};

int main(){
    int n,q;
    char com;
    int x,y;
    cin >>n>>q;
    UnionFind uf(n);
    for range(i,q){
        cin >>com >>x>>y;
        if (com=='0') { uf.unionSet(x,y); }
        else if (com=='1') { cout << int(uf.findSet(x,y)) << endl; }
    }
}


Measured memory_bytes: 3144
/*input
6
30 10 60 10 60 50
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

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

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    vector<ll> h(n);
    vector<ll> dp(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++) dp[i] = min(dp[i - 1] + abs(h[i] - h[i -1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    cout << dp[n - 1];

    return 0;
}

Measured memory_bytes: 1792
unittest
{
//	assert( [ "4 2 3" ].parse.expand.solve == "1 2 3 4" );
//	assert( [ "5 3 100" ].parse.expand.solve == "50 50 50 30 70" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nks = input.front.split.to!( long[] );
	return tuple( nks[ 0 ], nks[ 1 ], nks[ 2 ] );
}

auto solve( long n, long k, long s )
{
	auto anss = new long[ n ];
	auto t = 10L ^^ 9 - ( s == 10L ^^ 9 );
	foreach( i, ref ans; anss )
	{
		ans = ( i < k ) ? s : t;
	}
	return anss.to!( string[] ).join( ' ' );
}


Measured memory_bytes: 8700
#include <stdio.h>
#define min(a,b) ((a) < (b) ? (a) : (b))
#define A(i) ((i) < n && (i) >= 0 ? a[(i)] : min+2)

int main(void) {
	int n, k, a[100000], min = 100001, cnt = 0, ans = 0, i;
	
	scanf("%d %d", &n, &k);
	
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		min = min(a[i], min);
	}
	
	for (i = 0; i < n; i++) {
		if (a[i] != min) {
			if (A(i-2) != min || A(i-1) != min || A(i+1) != min || A(i+2) != min) {
				cnt++;
			} else if (cnt) {
				ans += cnt / (k-1) + (cnt % (k-1) ? 1 : 0);
				cnt = 0;
			} else {
			}
		}
	}
	
	if (cnt) {
		ans += cnt / (k-1) + (cnt % (k-1) ? 1 : 0);
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
    int N;
    int ans=0;
    cin>>N;
    vector<int> a(N),b(N);
    rep(i,N)cin>>a[i];
    rep(i,N)b[i]=a[i];
    sort(RALL(a));
    rep(i,N){
        if(a[0]==b[i])
            Out(a[1]);
        else
            Out(a[0]);
    }  
    return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<vector>
#include<map>
#include<cassert>
#include<algorithm>
using namespace std;

struct Record{
  int s;
  int t;
  int n;
  int m;
  Record(int s,int t,int n,int m) : s(s), t(t), n(n), m(m) {;}
};

bool operator<(const Record &l, const Record &r) {
  return (r.t != l.t) ? l.t < r.t : l.m < r.m;
}

int main() {
  int N,M,r,q;
  while(cin>>N>>M, N|M) {
    cin>>r;
    int t,n,m,s,ts,te;
    vector<Record> in;
    for(int i=0; i<r; ++i) {
      cin>>t>>n>>m>>s;
      in.push_back(Record(s,t,n,m));
    }
    cin>>q;
    sort(in.begin(), in.end());

    for(int i=0; i<q; ++i) {
      cin>>ts>>te>>m;
      int use = 0,start = -1,fans = 0;
      vector<pair<int,int> > v;
      for(int j=0; j<in.size(); ++j) {
	if(in[j].m != m) continue;
	if(in[j].s == 1) {
	  if(use == 0 && start == -1)
	    start = in[j].t;
	  use++;
	}
	if(use > 0 && in[j].s == 0) {
	  use--;
	  if(use == 0) {
	    v.push_back(pair<int,int>(start,in[j].t));
	    start = -1;
	  }
	}
      }
      assert(use == 0);
      for(int j=0; j<v.size(); ++j) {
	if(v[j].first >= te || v[j].second <= ts) continue;
	if(v[j].first <= ts && v[j].second >= te) fans += te - ts;
	else if(v[j].first <= ts) fans += v[j].second - ts;
	else if(v[j].second >= te) fans += te - v[j].first;
	else fans += v[j].second - v[j].first;
      }
      cout<<fans<<endl;
    }

  }
}

Measured memory_bytes: 0
#include <stdio.h>

int main()
{
	int i, N;
	char s[100001];
	scanf("%d", &N);
	scanf("%s", s);
	
	int j;
	char t[4][100001] = {"SS", "SW", "WS", "WW"};
	for (i = 1; i < N - 1; i++) {
		for (j = 0; j < 4; j++) {
			if (s[i] == 'o') {
				if (t[j][i] == 'S') t[j][i+1] = t[j][i-1];
				else if (t[j][i-1] == 'S') t[j][i+1] = 'W';
				else t[j][i+1] = 'S';
			} else if (t[j][i] == 'W') t[j][i+1] = t[j][i-1];
			else if (t[j][i-1] == 'S') t[j][i+1] = 'W';
			else t[j][i+1] = 'S';
		}
	}
	
	for (j = 0; j < 4; j++) {
		t[j][N] = 0;
		if (s[0] == 'o' && t[j][0] == 'S' && t[j][1] != t[j][N-1]) continue;
		else if (s[0] == 'o' && t[j][0] == 'W' && t[j][1] == t[j][N-1]) continue;
		else if (s[0] == 'x' && t[j][0] == 'S' && t[j][1] == t[j][N-1]) continue;
		else if (s[0] == 'x' && t[j][0] == 'W' && t[j][1] != t[j][N-1]) continue;
		else if (s[N-1] == 'o' && t[j][N-1] == 'S' && t[j][0] != t[j][N-2]) continue;
		else if (s[N-1] == 'o' && t[j][N-1] == 'W' && t[j][0] == t[j][N-2]) continue;
		else if (s[N-1] == 'x' && t[j][N-1] == 'S' && t[j][0] == t[j][N-2]) continue;
		else if (s[N-1] == 'x' && t[j][N-1] == 'W' && t[j][0] != t[j][N-2]) continue;
		else break;
	}
	if (j < 4) printf("%s\n", t[j]);
	else printf("-1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>

int main(void){

    char S[4], T[4];
    int count = 0;
    int i;

    scanf("%s",S);
    scanf("%s",T);

    for(i=0; i<3; i++){
        if(S[i] == T[i]) count++;
    }

    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 128
//AtCoder ABC084 Contest
#include<bits/stdc++.h>
using namespace std;
typedef long long lld;

int main(){
    lld t;
    t=1;
    while(t--){
        lld a,b;
        cin>>a>>b;
        string s;
        cin>>s;
        int f=0;
        for(lld i=0;i<a;i++){
            if(!isdigit(s[i])){
                f=1;
                break;
            }
        }
        if(s[a]!='-'){
            f=1;
        }
        for(lld i=a+1;i<a+b;i++){
            if(!isdigit(s[i])){
                f=1;
                break;
            }
        }
        if(f==0){
            cout<<"Yes\n";
        }   
        else{
            cout<<"No\n";
         }
    }
}

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

int main (void) {
  int N;
  int ans=0;
  int a=0;
  cin >> N;
  for (int i=0; i<N ;i++ ){
    cin >> a;
    if  ( a%2 !=0) {
      ans +=1;
    }
  }

  if (ans%2==0) {
    cout << "YES";
  }
  else {
    cout << "NO";
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>

#define d_flag 0
#define MAX 100000

typedef struct{
  int b;
  int c;
}data;

int C(const void* a,const void* b){
  return (*((int *)a))-(*((int *)b));
}

int C_data(const void* x,const void* y){
  return( ((data*)y)->c-((data*)x)->c );
}

int main(){
  int n,m;
  scanf("%d%d",&n,&m);
  int a[MAX];
  int i;
  for(i=0;i<n;i++)
    scanf("%d",a+i);
  qsort(a,n,sizeof(int),C);
  
  data d[MAX];
  for(i=0;i<m;i++)
    scanf("%d%d",&(d[i].b),&(d[i].c));
  qsort(d,m,sizeof(data),C_data);

  if(d_flag){
    for(i=0;i<n;i++)
      printf(" %d",a[i]);
    printf("\n");

    for(i=0;i<m;i++)
      printf(" %d(%dtimes)",d[i].c,d[i].b);
    printf("\n");
  }

  int k,j,flag=0;
  i=0;

  for(j=0;j<m;j++){
    for(k=0;k<d[j].b;k++){
      if(a[i]<d[j].c)a[i++]=d[j].c;
      else{
	flag=1;
	break;
      }
    }
    if(flag)break;
  }
  if(d_flag){
    for(i=0;i<n;i++)
      printf(" %d",a[i]);
    printf("\n");
  }
  long int ans=0;
  for(i=0;i<n;i++)
    ans+=a[i];
  printf("%ld",ans);
}


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

using namespace std;

int check(vector <string> &, vector <string> &, int, int, int);

int main()
{
	int N, M;
	cin >> N >> M;
	
	vector < string > A(N);
	vector < string > B(M);	
	
	for (int i = 0; i < N; i++)
		cin >> A[i];

	for (int i = 0; i < M; i++)
		cin >> B[i];

	for (int i = 0; i <= (N - M); i++)
		for (int j = 0; j <= (N - M); j++)
			if (check(A, B, i, j, M)) {
				cout << "Yes" << endl;

				return 0;
			}

	cout << "No" << endl;

	return (0-0);	
}

int check(vector <string> &A, vector <string> &B, int x, int y, int M)
{
	for (int i = 0; i < M; i++)
		for (int j = 0; j < M; j++)
			if (A[i + x][j + y] != B[i][j])
				return 0;

	return 1;
}

Measured memory_bytes: 256
//do not think about past and stay in this moment
//organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PB push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define rf(i,x,n) for(int i=x-1;i>=n;--i)
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end() 
void print(int arr[],int n){
	for(int i=0;i<n;++i)
	cout<<arr[i]<<" ";
	cout<<endl;
}
int fre[10];
int32_t main()
{
	
	int n; cin>>n; fre[n]++;
	cin>>n; fre[n]++;
	cin>>n; fre[n]++;
	cin>>n; fre[n]++;
	if(fre[1]==1 && fre[9]==1 && fre[7]==1 && fre[4]==1)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
def main():
  S = list(input())
  T = list(input())
  
  if len(S) < len(T):
    print("UNRESTORABLE")
    return 0

  restorable = False
  LT = len(T)
  LS = len(S)
  for i in range(LS - LT + 1):
    if check_char(S[LS - LT - i : LS - i], T):
      restorable = True
      for j in range(LT):
        S[LS - LT - i + j] = T[j]
      break
  print("".join(["a" if s == "?" else s for s in S])) if restorable else print("UNRESTORABLE")

def check_char(A, B): # same length
  for i in range(len(B)):
    if A[i] not in [B[i], "?"]:
      return False
  return True

main()

Measured memory_bytes: 9096
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = sorted(LIST())
i = bisect_left(a[:-1], a[-1]/2)
if abs( a[-1]/2 - a[max(0,i-1)] ) <= abs( a[i] - a[-1]/2 ):
    print(a[-1], a[max(0,i-1)])
else:
    print(a[-1], a[i])

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

const int N = 4000, mod = 998244353;
typedef std::bitset<N> bitset;

bitset X, G, A, now;
int g, n, x, ans, p[N];

void up(int &x, int y) {x += y - mod, x += x >> 31 & mod;}
int length(const bitset &a) {
	for (int i = N - 1; ~i; --i) if (a.test(i)) return i;
	return -1;
}
void poly_mod(bitset &a, const bitset &g, int &lena, int leng) {
	for (int i = lena; i >= leng; --i) if (a.test(i))
		a ^= g << i - leng;
	while (lena >= 0 && !a.test(lena)) --lena;
}
void poly_gcd(bitset &g, bitset &a, int &leng, int &lena) {
	if (g.none()) {g = a, leng = lena; return;}
	poly_mod(a, g, lena, leng), poly_gcd(a, g, lena, leng);
}
void read(bitset &b) {
	b.reset(); std::string s; std::cin >> s, std::reverse(s.begin(), s.end());
	for (int i = 0; i < s.size(); ++i) b.set(i, s[i] & 1);
}
bool leq(const bitset &a, const bitset &b) {
	for (int i = N - 1; ~i; --i)
		if (a.test(i) != b.test(i))
			return a.test(i) < b.test(i);
	return 1;
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n, read(X), x = length(X);
	for (int i = 0, a; i < n; ++i)
		read(A), poly_gcd(G, A, g, a = length(A));
	p[0] = 1; for (int i = 1; i <= x; ++i) up(p[i] = p[i - 1], p[i - 1]);
	for (int i = x; i >= g; --i) {
		if (X.test(i)) up(ans, p[i - g]);
		if (now.test(i) != X.test(i)) now ^= G << i - g;
	}
	up(ans, leq(now, X)), std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String line;
		while ((line = reader.readLine()) != null) {
			if (line.isEmpty())
				break;
			String result = getNum(line);
			System.out.println(result);
		}
	}

	private static String getNum(String line) {
		if (line.length() == 1) {
			return line;
		}
		char[] a = line.toCharArray();
		char[] b = new char[line.length() - 1];
		for (int i = 0; i < b.length; i++) {
			b[i] = (char) ((a[i] - '0' + (a[i + 1] - '0')) % 10 + '0');
		}
		return getNum(String.valueOf(b));
	}
}

Measured memory_bytes: 16872
A,B,C,D = map(int, input().split())
count_a = 0
count_c = 0
while A>D:
  A -= D
  count_a += 1
while C>B:
  C -= B
  count_c += 1
count_a = (count_a+1)*2
count_c = (count_c*2)+1
if count_a>=count_c:
  print('Yes')
else:
  print('No')
  

Measured memory_bytes: 9072
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 15;
ll n;
vector< vpii > a(N, vpii ());
ll ans = 0;
void fun(ll mask)
{
	vi honest;
	vi not_h;
	rep(i,0,n) if(((mask>>i)&1)==1)
	{
		honest.pb(i);
		rep(j,0,sz(a[i])) if(a[i][j].S==1) honest.pb(a[i][j].F); else not_h.pb(a[i][j].F);
	} 
	ll f=1;
	rep(i,0,sz(honest)) if(((mask>>honest[i])&1)!=1) f=0;
	rep(i,0,sz(not_h)) if(((mask>>not_h[i])&1)!=0) f=0;
	set<ll> s(honest.begin(), honest.end());
	if(f) ans=max(ans,sz(s));
}

int solve()
{
	cin>>n;
	rep(i,0,n)
	{
		ll m;cin>>m;
		rep(j,0,m)
		{
			ll x,y;cin>>x>>y;
			x--;
			a[i].pb(mp(x,y));
		}
	}

	rep(i,0,1<<n) fun(i);
	cout<<ans<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	
	int i,a;
	scanf("%d",&a);
	int num[a];
	for(i = 1;i<=a;i++){
		num[i] = i;
	
		if(num[i] % 3 == 0){
			printf(" %d",num[i]);
		}
		else if( num[i] % 10 == 3){
			printf(" %d",num[i]);
		}
		else if(num[i]/10 % 10 == 3){
			printf(" %d",num[i]);
		}
		else if(num[i]/100 % 10 == 3){
			printf(" %d",num[i]);
		}
		else if(num[i]/1000 % 10 == 3){
			printf(" %d",num[i]);
		}

		
	
	}
		printf("\n",num[i]);
	return 0;
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<string> v;
    for(int i = 0; i < N; i++){
        string S;
        cin >> S;
        sort(S.begin(), S.end());
        v.push_back(S);
    }
    sort(v.begin(), v.end());
    
    ll ans = 0;
    ll tmp = 1;
    for(int i = 1; i < N; i++){
        if(v[i] == v[i-1]){
            tmp++;
        }else{
            ans += (((tmp)*(tmp-1))/2);
            tmp = 1;
        }
    }
    ans += (((tmp)*(tmp-1))/2);
    cout << ans << "\n";
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int,int> tii;

int main() {
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC";
    else cout<<"ABC";
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 10100;

int len, n, arr[MAXN];
char str[MAXN];

int main(){
	scanf("%d", &n);
	scanf("%s", str + 1);
	len = strlen(str + 1);
	for(int i = 1; i <= len; i++) arr[i] = str[i] - 'A';
	for(int i = 1; i <= len; i++) printf("%c", (arr[i] + n) % 26 + 'A');
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
import java.awt.Point;
import java.io.FileInputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static int r, n;
	static int[] xl, xr, h;
	
	private static void start()
	{
		int i, j;
		
		Point[] height = new Point[41];
		for(i = 0;i < 41;i++)
			height[i] = new Point(0, 0);
		
		for(i = 0;i < n;i++)
			for(j = xl[i];j <= xr[i];j++)
			{
				if(j != xl[i]) height[j].x = Math.max(height[j].x, h[i]);
				if(j != xr[i]) height[j].y = Math.max(height[j].y, h[i]);
			}
		
		double min = Double.MAX_VALUE;
		for(i = (20-r);i <= (20+r);i++)
		{
			if(i != (20-r))
			{
				double w = Math.abs(i - 20);
				double p = Math.sqrt(r*r - w*w);
				double t = (double)height[i].x - p + (double)r;
				min = Math.min(min, t);
			}
			
			if(i != (20+r))
			{
				double w = Math.abs(i - 20);
				double p = Math.sqrt(r*r - w*w);
				double t = (double)height[i].y - p + (double)r;
				min = Math.min(min, t);
			}
		}
		
		System.out.printf("%.04f\n", min);
	}
	
	public static void main(String[] args)
	{
		
		Scanner sca = new Scanner(System.in);
		
		while(true)
		{
			r = sca.nextInt();
			n = sca.nextInt();
			if(r == 0) break;
			
			xl = new int[n];
			xr = new int[n];
			h = new int[n];
			for(int i = 0;i < n;i++)
			{
				xl[i] = sca.nextInt() + 20;
				xr[i] = sca.nextInt() + 20;
				h[i] = sca.nextInt();
			}
			
			start();
		}
	}
}

Measured memory_bytes: 29668
using System;
using System.Linq;

namespace _0227
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x[0] == 0 && x[1] == 0)
                {
                    break;
                }
                int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                int b = a.Sum();
                Array.Sort(a);
                Array.Reverse(a);
                for (int i = 0; i < x[0] / x[1]; i++)
                {
                    b -= a[x[1] * (i + 1) - 1];
                }
                Console.WriteLine(b);
            }
        }
    }
}

Measured memory_bytes: 10032
from bisect import bisect_right

A , B , Q = map(int,input().split())
INF = 10**20

s = [0] * A
t = [0] * B
x = [0] * Q

for i in range(A) :
    s[i] = int(input())
for i in range(B) :
    t[i] = int(input())
for i in range(Q) :
    x[i] = int(input())

s = [-INF] + s + [INF]
t = [-INF] + t + [INF]

for p in x :
    rightS = bisect_right(s,p)
    rightT = bisect_right(t,p)

    dist = INF

    for ss in [s[rightS - 1], s[rightS]] :
        for tt in [t[rightT - 1], t[rightT]] :
            dist1 = abs(ss - p) + abs(ss - tt)
            dist2 = abs(tt - p) + abs(tt - ss)
            dist = min(dist, dist1, dist2)

    print(dist)


Measured memory_bytes: 16708
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
using namespace std;

int main(){
    //input
    long long N;
    long long x[8], y[8];
    long long i;
    cin >> N;
    for(i = 0; i < N; i++){
        cin >> x[i] >> y[i];
    }

    //calculate
    long long kaijo = 1;
    for(i = 1; i <= N; i++){
        kaijo *= i;
    }
    long long a[N];
    for(i = 0; i <N; i++){
        a[i] = i;
    }
    double ave = 0;
    double sum;
    do{
        sum = 0;
        for(i = 1; i < N; i++){
            sum += sqrt((x[a[i-1]]-x[a[i]])*(x[a[i-1]]-x[a[i]]) + (y[a[i-1]]-y[a[i]])*(y[a[i-1]]-y[a[i]]));
        }
        ave += sum/kaijo;
    }while(next_permutation(a, a+N));

    //answer
    cout << fixed << setprecision(10) << ave << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

int main(){
    ll N,K; cin >> N >> K;
    vector<pair<int,int>> p(N);
    for(int i = 0; i < N; i++){
        cin >> p[i].first >> p[i].second;
    }
    
    sort(p.begin(),p.end());
    int ans;
    for(int i = 0; i < N; i++){
        K -= p[i].second;
        if(K <= 0){
            ans = p[i].first;
            break;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 1024
#include<iostream>

using namespace std;

typedef long long ll;

int N;
ll A, B, h[100000 + 10];

bool f(ll x) {
	ll cnt = 0;
	for (int i = 0; i < N; i++) {
		ll tmp = h[i] - B * x;
		if (tmp > 0) {
			cnt += (tmp + A - B - 1) / (A - B);
		}
	}
	if (cnt <= x)return true;
	return false;
}

int main() {
	cin >> N >> A >> B;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	ll l = 1, u = 1e9 * 4;
	while (u - l > 1) {
		ll mid = (u + l) / 2;
		if (f(mid)) u = mid;
		else l = mid;
	}
	if (f(l))cout << l << endl;
	else cout << u << endl;
	return 0;
}

Measured memory_bytes: 1024
n,k = input().split()
mon = input().split()
mon = list(map(int,mon))

if(int(n)<=int(k)):
    print(0)
elif(int(k)==0):
    print(sum(mon))
else:    
    mon.sort(reverse=True)
    for i in range(0,int(k)):
        mon[i] = 0
        
    print(sum(mon))

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

int main() {
    int N, M; cin >> N >> M;
    vector<int> H(N);
    for(auto &e : H) cin >> e;
    vector<vector<int>> G(N);
    for(int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    int ans = 0;
    for(int i = 0; i < N; ++i) {
        bool ok = true;
        for(auto &to : G[i]) {
            if(H[to] >= H[i]) {
                ok = false;
                break;
            }
        }
        if(ok) ans++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 8804
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#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 pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int a, b, c, ans = 0;
    cin >> a >> b >> c;
    FOR(i,a,b) ans += (c % i == 0);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int N;
int K;
int h[100005];
int dp[100005];

int solve(int idx)
{
    int &ret = dp[idx];
    if(~ret)
        return ret;
    ret = 0;
    if(idx<N-1)
        ret = abs(h[idx+1]-h[idx])+solve(idx+1);
    for(int i=2; i<=K; i++)
        if(idx<N-i)
            ret = min(ret,abs(h[idx+i]-h[idx])+solve(idx+i));
    return ret;
}



int main()
{

    memset(dp , -1 , sizeof(dp));
    cin>>N>>K;
    for(int i=0; i<N; i++)
    {
        cin>>h[i];
    }

    cout<<solve(0);

    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll n; cin >> n;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];
    sort(l.rbegin(), l.rend());
    ll cnt = 0;
    rep(i, n){
        for(ll j = i+1; j < n; ++j){
            ll a1 = l[i] - l[j], a2 = l[j] - l[i], a3 = l[i] + l[j];
            for(ll k = j+1; k < n; ++k){
                if(a1 < l[k] && a2 < l[k] && l[k] < a3) cnt++;
                else break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>

using namespace std;

int main()
{
    int N,D,x,y,counter ;
    double result;

    cin>>N>>D;
    counter=0;
    for(int i=1;i<=N;i++)
    {

        cin>>x>>y;
        result=sqrt(pow(x,2)+pow(y,2));
        if(result<=D)
            counter++;
    }
    cout<<counter<<endl;

}


Measured memory_bytes: 3676