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

int reversed_number(int n) {
  int x = 1;
  int reversed=0;
  vector<int> numbers = {};
  while(n != 0) {
    numbers.push_back(n % 10);
    n /= 10;
  }
  
  for(int i= numbers.size()-1;i>=0;i--) {
    reversed += numbers.at(i) * x;
    x *= 10;
  }
 
  
  return reversed;
}

int main() {

 int N,M;
  int sum = 0;
  cin >> N;
  cin >> M;
  
  for(int i=N; i<=M;i++) {
    if(i == reversed_number(i) ) {
      sum+=1;
      
    }
  }
  
  cout << sum << endl;
  
  return 0;
}
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef std::pair<ll,ll> P;

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

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

const ll mod = 1000000007;

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

ll inv_mod(ll a) { return mpow(a, mod - 2); }


int main() {
	ll n;
	cin >> n;
	ll all = mpow(10, n);
	ll d1 = mpow(9, n) * 2;
	ll d2 = mpow(8, n);
	ll a = all - d1 + d2 + 2 * mod;
	a %= mod;
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n,m,a[10000],b[10000],col[10000],cnt,ret;
vector<int>x[100];
void dfs(int pos)
{
	if(col[pos]>=1)return;
	col[pos]=cnt;
	for(int j=0;j<x[pos].size();j++)
	dfs(x[pos][j]);
} 
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	cin>>a[i]>>b[i];
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<=n;j++)
		{
			x[j].clear();
			col[j]=0;
		}
		for(int j=0;j<m;j++)
		{
			if(i!=j)
			{
				x[a[j]].push_back(b[j]);
				x[b[j]].push_back(a[j]);
			}
		}
		cnt=0;
		for(int j=1;j<=n;j++)
		{
			if(col[j]>=1)continue;
			cnt++;
			dfs(j);
		} 
		if(cnt>=2)ret++;
	}
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
struct data{
	int to,nxt;
}mp[500500];
int head[100100],cnt;
void link(int x,int y)
{
	mp[++cnt].to=y;
	mp[cnt].nxt=head[x];
	head[x]=cnt;
}
int dis[100100],la[100100];
queue<int>q;
void bfs()
{
	dis[1]=1;
	q.push(1);
	int u,v;
	while(!q.empty())
	{
		u=q.front();q.pop();
		for(int i=head[u];i;i=mp[i].nxt)
			if(!dis[mp[i].to])
			{
				v=mp[i].to;
				dis[v]=dis[u]+1;
				la[v]=u;
				q.push(v);
			}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	int xx,yy;
	for(int i=1;i<=m;++i)
	{
		scanf("%d%d",&xx,&yy);
		link(xx,yy);link(yy,xx);
	}
	bfs();
	puts("Yes");
	for(int i=2;i<=n;++i)printf("%d\n",la[i]);
	return 0;
}


Measured memory_bytes: 8184
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> l(n-1), r(n-1);
	l[0] = a[0];
	r[n-2] = a[n-1];
	rep(i, n - 2) l[i + 1] = gcd(l[i], a[i+1]);
	rep(i, n - 2) r[n-3-i] = gcd(r[n-2-i], a[n - 2 - i]);
	int ans = 0;
	rep(i, n) {
		if (i == 0) ans = max(ans, r[0]);
		else if (i == n - 1) ans = max(ans, l[n-2]);
		else ans = max(ans, gcd(l[i-1], r[i]));
	}
	cout << ans << endl;
}

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

using namespace std;
 
#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  f              first                 
#define  s              second
#define  endl           "\n"
#define  pb             push_back  
#define  mset(a,x)      memset(a,x,sizeof(a))
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;            
          
 
typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  unordered_map<ll,ll>  um;
typedef  vector<pll>           vpll;
 
const ll   N     =  5e5+5;
const ll   mod   =  998244353;
const ll   INF   =  1e18;
const int  INFi  =  0x7f7f7f7f;

ll test = 1, n;
char s;

void solve(){
    cin>>s;
    if('a' <= s and s <= 'z') cout<<"a"<<endl;
    else cout<<"A"<<endl;
}

int main(){
    fastio;
    //cin>>test;
    for(int i = 1; i <= test; i++){
        solve();
    }

}

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

int main() {
  int N;
  int n1, n2, n3, n4;
  cin >> N;
  n1 = N / 1000;
  n2 = (N - n1 * 1000) / 100;
  n3 = (N - n1 * 1000 - n2 * 100) / 10;
  n4 = N - n1 * 1000 - n2 * 100 - n3 * 10;
  if ((n1 == n2 && n2 == n3) || (n2 == n3 && n3 == n4)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
 
using namespace std;
 
int main()
{
  int a,b,c,d;
  
  cin >>a >> b >> c >> d;
  
  if ( abs(a-b) <= d && abs(c-b) <= d || abs(c-a) <= d ) cout << "Yes\n";
  else cout << "No\n";
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int main(){
	while(1){
		int n;
		cin>>n;
		if(!n)break;
		int a[n];
		rep(i,n)cin>>a[i];
		sort(a,a+n);
		int ans=1000000;
		rep(i,n-1)ans=min(ans,a[i+1]-a[i]);
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3068
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int N;
        int M;
        int[] Si = null;
        int[] Ci = null;
        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            M = sc.nextInt();
            if (M != 0) {
                Si = new int[M];
                Ci = new int[M];
                for (int i = 0; i < M; i++) {
                    Si[i] = sc.nextInt();
                    Ci[i] = sc.nextInt();
                }
            }
        }
        int[] num = new int[N];
        Arrays.fill(num, -1);

        for (int i = 0; i < M; i++) {
            int s = Si[i];
            int c = Ci[i];
            if (num[s - 1] == -1) {
                num[s - 1] = c;
            } else if (num[s - 1] == c) {
                continue;
            } else {
                System.out.println(-1);
                return;
            }
        }
        if (N != 1) {
            if (num[0] == 0) {
                System.out.println(-1);
                return;
            }
            if (num[0] == -1) {
                num[0] = 1;
            }
        } else {
            if (num[0] == -1) {
                num[0] = 0;
            }
        }

        for (int i = 1; i < N; i++) {
            if (num[i] == -1) {
                num[i] = 0;
            }
        }
        int result = 0;
        //System.out.println(Arrays.toString(num));
        for (int i = 0; i < N; i++) {
            result = (result * 10) + num[i];
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 21844
#include <iostream> 

using namespace std;


int main() {
    int n;
    int b,f,r,v;
    int x_1[4][3][10] = {{{0}}};
    cin >> n;

    for (int x = 0; x < n; ++x){
        cin >> b >> f >> r >> v;
        x_1[b-1][f-1][r-1] += v;
    }

    for (int i = 0; i < 4; ++i){
        for (int j = 0; j < 3; ++j){
            for (int x = 0; x < 10; ++x){
                cout << " " << x_1[i][j][x];
            }
                cout << endl;
        }
        if ( i != 3){
        cout <<"####################" <<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3116
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {

    public static void main(String args[]) throws IOException {
        FastReader in = new FastReader();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        Task.solve(in, out);
        out.close();
    }

    static class Task {

        public static void solve(FastReader in, PrintWriter out) {
            long n = in.nextLong(), m = in.nextLong();
            long[] a = new long[(int)m];
            for(int i=0;i<m;i++){
                a[i] = in.nextLong();
            }
            if(n>=m){
                System.out.println(0);
                return;
            }
            Arrays.sort(a);
            long[] b = new long[(int)m-1];
            for(int i=0;i<m-1;i++){
                b[i] = a[i+1]-a[i];
            }
            Arrays.sort(b);
            long sum=0;
            for(int i=0;i<(m-n);i++){
                sum+=b[i];
            }
            System.out.println(sum);
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 36524
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
/*lcm(gcd(N1, M), gcd(N2, M), ..., gcd(Nk, M)) = gcd(lcm(N1, ..., Nk), M)
gcd(lcm(N1, M), lcm(N2, M), ..., lcm(Nk, M)) = lcm(gcd(N1, ..., Nk), M).

If gcd(N1, N2) = 1, then
gcd(N1·N2, M) = gcd(N1, M)·gcd(N2, M)
lcm(N1·N2, M) = lcm(N1, M)·lcm(N2, M)/M.

lcm(M, N, P) · gcd(M, N) · gcd(N, P) · gcd(P, M) = NMP · gcd(N, M, P).
*/
////////////////////////////////////////////////////////////////////
int a[26];
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    int n;
    cin>>n;
    string s;
    cin>>s;
    REP(i,n)
    {
        a[s[i]-'a']++;
    }
    ll ans=1;
    REP(i,26)
    {
        ans*=(a[i]+1);
        ans%=MOD;
    }
    cout<<ans-1;
  }  
  return 0;
}
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (int vs ll?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

const int MAX_N = 400000;

ll inv[MAX_N], fac[MAX_N], fiv[MAX_N];
void COMinit() {
    inv[1] = fac[1] = fiv[1] = inv[0] = fac[0] = fiv[0] = 1;
    for (ll i = 2; i < MAX_N; i++) {
        fac[i] = fac[i - 1] * i % MOD; // n!
        inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; // n^-1
        fiv[i] = fiv[i - 1] * inv[i] % MOD; // (n!)^-1
    }
}

ll com(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * fiv[k] % MOD * fiv[n-k] % MOD;
}

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

    ll n, m, K;
    cin >> n >> m >> K;

    ll X = n * m;

    ll tate = 0;
    for (ll i = 1; i < m; i++) {
        tate += i * (m - i);
        tate %= MOD;
    }
    tate = 2 * n * n % MOD * tate % MOD;

    ll yoko = 0;
    for (ll i = 1; i < n; i++) {
        yoko += i * (n - i);
        yoko %= MOD;
    }
    yoko = 2 * m * m % MOD * yoko % MOD;

    ll ans = (yoko + tate) % MOD;

    COMinit();
    ans = ans * com(X - 2, K - 2) % MOD;
    if (ans % 2 == 0) ans /= 2;
    else ans = (ans + MOD) / 2;

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    vector<int> S = A;
    sort(ALL(S));

    vector<vector<int>> ranges;
    ranges.push_back(A);
    int ans = INF;
    for (int i = 0; i < N; i++) {
        int min_a = S[i];
        vector<vector<int>> new_ranges;
        for (auto range : ranges) {
            int n = (int)range.size();
            for (int l = 0; l < n; l++) {
                int r = l;
                for (; r < n && range[r] >= min_a; r++) {};
                if (r == l) { continue; }
                vector<int> new_range;
                for (int j = l; j < r; j++) {
                    new_range.push_back(range[j]);
                }
                new_ranges.push_back(new_range);
                l = r - 1;
            }
        }
        ranges = new_ranges;

        vector<int> tmp;
        for (auto range : ranges) {
            int n = (int)range.size();
            sort(ALL(range));
            for (int j = 0; j < n - K + 1; j++) {
                tmp.push_back(range[j]);
            }
        }
        sort(ALL(tmp));
        if ((int)tmp.size() >= Q) chmin(ans, tmp[Q - 1] - min_a);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

const int N = 10000;

typedef long long lli;

lli gcd(lli a, lli b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

main(){
  lli n;
  lli d[N];
  lli v[N];
  lli ans[N];
  while(cin >> n && n){
    for(int i=0;i<n;i++){
      cin >> d[i] >> v[i];
    }
    for(int i=0;i<n;i++){
      int tmp = gcd(d[i], v[i]);
      d[i] /= tmp;
      v[i] /= tmp;
    }
    lli c = lcm(d[0], d[1]);
    for(int i=2;i<n;i++){
      c = lcm(c, d[i]);
    }
    for(int i=0;i<n;i++){
      ans[i] = c/d[i]*v[i];
    }
    c = gcd(ans[0], ans[1]);
    for(int i=2;i<n;i++){
      c = gcd(c, ans[i]);
    }
    for(int i=0;i<n;i++){
      cout << ans[i] / c << endl;
    }
  }
  return 0;
}

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


int main(){
  int n;
  cin >> n;
  long long p = 1;
  bool isOver = false;
  while (n--){
    long long a;
    cin >> a;
    if (a == 0){
      puts("0");
      return 0;
    }
    if (!isOver and 1000000000000000000LL / p < a){
      isOver = true;
    }
    p *= a;
  }
  cout << (isOver ? -1 : p) << endl;
}


Measured memory_bytes: 3600
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		int s = -n;
		for (int i = 1; i * i <= n; ++i)
		{
			if (n % i == 0)
			{
				s += i;
				if (i * i != n)
					s += n / i;
			}
		}
		if (n > s)
			puts("deficient number");
		else if (n == s)
			puts("perfect number");
		else
			puts("abundant number");
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>

using namespace std;

namespace {

int InsertionSort(int* a, int n, int g) {
  int cnt = 0;
  for (int i = g; i < n; ++i) {
    const int v = a[i];
    int j = i - g;
    while (j >= 0 && a[j] > v) {
      a[j + g] = a[j];
      j -= g;
      cnt++;
    }
    a[j + g] = v;
  }
  return cnt;
}

int ShellSort(int* a, int n) {
  int cnt = 0;
  int m = 0;
  int G[100];
  G[0] = 1;
  for (int i = 0; i < 100; ++i) {
    G[i + 1] = 3 * G[i] + 1;
    ++m;
    if (G[i + 1] >= n) {
      break;
    }
  }

  cout << m << endl;
  for (int i = m - 1; i >= 0; --i) {
    if (i < m - 1) printf(" ");
    printf("%d", G[i]);
  }
  printf("\n");

  for (int i = 0; i < m; ++i) {
    cnt += InsertionSort(a, n, G[m - i - 1]);
  }

  return cnt;
}

}  // namespace

int main() {
  int n;
  int a[1000000];

  cin >> n;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  const int cnt = ShellSort(a, n);

  cout << cnt << endl;
  for (int i = 0; i < n; ++i) {
    cout << a[i] << endl;
  }
  return 0;
}

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

int main()
{
    int i, n, l;
    cin >> n >> l;
    int a[n+1]={0};
    for( int i=1; i < n+1; i++) a[i] = l+i-1;
    int sum = 0;
    int m = 0;
    for( int i=1; i < n+1; i++){
        sum +=a[i];
        if(a[i]==0) m++;
    }

    int summin = 0;
    if( m > 0 ){
        summin = sum;
    }
    else{
        for( int i=1; i < n+1; i++){
            if( summin <= abs( sum-a[i] ) ){
                summin = sum - a[i];
            }
        }
    }

    cout << summin << endl;

    return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	s = readline() |> chomp
	k = readline() |> parseInt
	l = length(s)
	fx = 0
	for i in 2:l
		if s[i]!=s[i-1]
			fx = 1
		end
	end
	if l==1
		println(k>>1)
	elseif fx == 0
		println((l*k)>>1)
	else
	h = 0
	b = 0
	x = 0
	f = 0
	tmp = 1
	for i in 2:l
		if s[i]!=s[i-1]
			if f==0
				f = 1
				h = i-1
			else
				x += tmp>>1
			end
			tmp = 1
		else
			tmp += 1
		end
	end
	b = tmp
	if s[1]!=s[l]
		x += h>>1
		x += b>>1
		println(x*k)
	else
		x=x*k
		x += ((h+b)>>1)*(k-1)
		x += h>>1
		x += b>>1
		println(x)
	end
end
end
main()

Measured memory_bytes: 111240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for (int i=0;i<N;i++) {
			int temp = sc.nextInt();
			A[temp]++;
		}
		for (int i=0;i<N;i++) {
			if (N%2==0) {
				if (i%2==1&&A[i]!=2) {
					System.out.println(0);
					return;
				}
				if (i%2==0&&A[i]!=0)  {
					System.out.println(0);
					return;
				}
			} else {
				if (i==0&&A[i]!=1) {
					System.out.println(0);
					return;
				}
				if (i%2==1&&A[i]!=0) {
					System.out.println(0);
					return;
				}
				if (i>0&&i%2==0&&A[i]!=2)  {
					System.out.println(0);
					return;
				}
			}
		}
		long count =1;
		for (int i=0;i<N/2;i++) {
			count = (count*2)%1000000007;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 59152
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>

using namespace std;

// unsigned int e[101];
// unsigned int d[101];
char e[101][2];
char d[101][2];

unsigned int bublesort(unsigned int n)
{
	unsigned int num = 0;

	bool flag = true;
	while (flag) {
		flag = false;
		for (unsigned int i = n-1; i > 0; --i) {
			if (e[i][1] < e[i-1][1]) {
				char x = e[i-1][1];
				char y = e[i-1][0];
				e[i-1][0] = e[i][0];
				e[i-1][1] = e[i][1];
				e[i][0] = y;
				e[i][1] = x;
				flag = true;
				++num;
			}
		}
	}

	return num;
}

unsigned int selectionsort(unsigned int n)
{
	unsigned int num = 0;
	for (unsigned int i = 0; i < n; ++i) {
		unsigned int minj = i;
		for (unsigned int j = i+1; j < n; ++j) {
			if (d[j][1] < d[minj][1]) {
				minj = j;
			}
		}
		if (i != minj) {
			char s = d[i][0];
			char t = d[i][1];
			d[i][0] = d[minj][0];
			d[i][1] = d[minj][1];
			d[minj][0] = s;
			d[minj][1] = t;
			++num;
		}
	}

	return num;
}

int main()
{
	unsigned int n;
	unsigned int num;
	cin >> n;
	for (unsigned int i = 0; i < n; ++i) {
		string c;
		cin >> c;
		d[i][0] = e[i][0] = c[0];
		d[i][1] = e[i][1] = c[1];
	}

	num = bublesort(n);
	for (unsigned int i = 0; i < n - 1; ++i) {
		cout.write(e[i], 2);
		cout.put(' ');
	}
	cout << e[n-1] << "\n";
	cout << "Stable"<< endl;

	num = selectionsort(n);
	for (unsigned int i = 0; i < n - 1; ++i) {
		cout.write(d[i], 2);
		cout.put(' ');
	}
	cout << d[n-1] << "\n";
	bool bStable = true;
	for (unsigned int i = 0; i < n - 1; ++i)
		if (d[i][0] != e[i][0] || d[i][1] != e[i][1])
			bStable = false;

	if (bStable)
		cout << "Stable"<< endl;
	else
		cout << "Not stable"<< endl;

		
	return 0;
}



Measured memory_bytes: 3152
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		long n=scanner.nextLong();
		long t=scanner.nextLong();

		long a = scanner.nextLong();
		long count=0;
		for(int i=0;i<n-1;i++){
			long b = scanner.nextLong();
			if(b-a<=t){
				count+=b-a;
			}else{
				count+=t;
			}
			a=b;
		}
		count+=t;
		System.out.println(count);
	}
}

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

int main(){
  int N,K;
  cin >> N >> K;
  
  int result = 1;
  for(int i = 0; i < N; i++)
    result = ((result > K) ? result+K : result*2);
  
  cout << result << endl;
  
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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

int main() {
    ll n;
    string s;

    cin >> n;
    cin >> s;

    ll ans = 0;

    rep(i, n-2) {
        if (s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C') {
            ++ans;
        }
    }

    cout << ans << endl;


}



Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9 + 7

factorial = [1]
inverse = [1]
for i in range(1, n+1):
    factorial.append(factorial[-1] * i % mod)
    inverse.append(pow(factorial[-1], mod - 2, mod))

def comb(n, r, mod):
    if n < r or r < 0: return 0
    elif r == 0: return 1
    return factorial[n] * inverse[r] * inverse[n - r] % mod

a.sort()
mini = 0
for i in range(n-1):
    mini += a[i] * comb(n-i-1, k-1, mod)
    mini %= mod

a.sort(reverse=True)
maxi = 0
for i in range(n-1):
    maxi += a[i] * comb(n-i-1, k-1, mod)
    maxi %= mod

print((maxi-mini)%mod)

Measured memory_bytes: 71208
n = int(input())
s = input()

# R, G, B が文字列中にそれぞれいくつあるか数える
rcnt = s.count('R')
gcnt = s.count('G')
bcnt = s.count('B')

# 1 つ目の条件だけの通り数
ans = rcnt * gcnt * bcnt

# 2 つ目の条件を引く
# s[i], s[j], s[k] が全て違い、j - i = k - j となる場合を ans から引く事を考える
sub = 0
for i in range(n):
    for j in range(i+1, n):

        # j - i = k - j となる
        k = j + (j - i)
        if n <= k: break

        # s[i], s[j], s[k] が全て違うとき、len(alp) == 3 になる
        alp = set()
        alp.add(s[i])
        alp.add(s[j])
        alp.add(s[k])

        if len(alp) == 3: sub += 1

ans -= sub

print(ans)

Measured memory_bytes: 73968
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int X; cin >> X;
    cout << 360/gcd(X,360) << endl;
    
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define ll long long int
#define sci(x) scanf("%d",&x);
#define scl(x) scanf("%lld",&x);
#define scd(x) scanf("%lf",&x);
#define pb(x) push_back(x)
#define FasterIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mkp(x,y) make_pair(x,y)
#define pii pair<int , int>

int main()
{
    int n,k,cnt=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>k;
        if(i&1 && k&1)
            cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3592
#include<stdio.h>

long long ru(int a){
	int i;
	long long r=1;
	for(i=0;i<a;i++)r=r*2;
	return r;
}

int main(){
	int n,i;
	long long k,a[100000],ans=0,keta[100]={0},tmp2=0;
	scanf("%d%lld",&n,&k);
	for(i=0;i<n;i++)scanf("%lld",&a[i]);
	for(i=0;i<n;i++){
		int j=0;
		long long tmp=a[i];
		while(tmp>0){
			if(tmp%2==1){
				keta[j]++;
				tmp--;
			}
			tmp=tmp/2;
			j++;
		}
	}
	long long nokori=k;
	for(i=50;i>=0;i--){
		//printf("%lld,",keta[i]);
		if((keta[i]<=(n/2))&&(nokori>=ru(i))){
		//printf("%lld\n",nokori);
			tmp2+=ru(i);
			nokori=nokori-ru(i);
		}
	}
	for(i=0;i<n;i++)ans+=tmp2^a[i];
	printf("%lld\n",ans);
//	printf("%lld\n",ru(50));
	return 0;
}


Measured memory_bytes: 896
import java.util.*;
    import java.io.*;
    import java.math.BigInteger;
     
    public class Main {
     
     
    	
    	public static void main(String[] args)throws IOException
    	{
    		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    		PrintWriter out = new PrintWriter(System.out);
    		
    		StringTokenizer st1 = new StringTokenizer(br.readLine());
    		
    		int n = Integer.parseInt(st1.nextToken());
    		int k = Integer.parseInt(st1.nextToken());
    		int q = Integer.parseInt(st1.nextToken());
    		
    		int arr[] = new int[n];
    		
    		for(int i = 0 ; i < q ; i++)
    		{
    			arr[Integer.parseInt(br.readLine())-1]++;
    		}
    		
    		for(int i = 0 ; i < n ; i++)
    		{
    			if(k-(q-arr[i]) > 0)
    			{
    				out.println("Yes");
    			}
    			else
    			{
    				out.println("No");
    			}
    		}
    		
    		
    		out.flush();
    		out.close();
    	}
    	
    	
    	
     
     
    }

Measured memory_bytes: 30152
//Keep Working Hard
  // I__Like__Food  
  #include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 200005
  #define INF 1000000000000
  #define eps 1e-6
  #define int long long
  #define pie 3.1415926535897932384626433832795028

  int arr[N];

int32_t main()
{



    int n;
    cin >> n;
    
    for(int i = 1; i <= n-1; i++)
    {
      int x;
      cin >> x;
      arr[x]++;
    }

    for(int i = 1; i <= n; i++)
    {
      cout << arr[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 5192
from math import inf
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)


def dfs(v,par):
    global cur
    vis[v]=1 ; disc[v]=cur ;low[v]=cur ; child=0 
    cur+=1
    for i in g[v]:
        if vis[i]==0:
            child+=1
            dfs(i,v)
            low[v]=min(low[i],low[v])
            if par==-1 and child>1:
                apts.add(v)
            if par!=-1 and low[i]>=disc[v]:
                apts.add(v)

        elif i!=par: low[v]=min(disc[i],low[v])
   
def articulation_pts():
    global apts,disc,low,vis
    disc=[0]*n ; low=[inf]*n ; vis=[0]*n ; par=[-1]*n ; apts=set()  
    for i in range(n):
        if vis[i]==0:
            dfs(i,-1)

n,e=map(int,input().split())
cur=0
g=[[] for i in range(n)]
for i in range(e):
    x,y=map(int,input().split())
    g[x].append(y)
    g[y].append(x)
articulation_pts()
apts=sorted(apts)
for i in apts:
    print(i)


    




Measured memory_bytes: 19596
# coding: utf-8

# In[3]:


import numpy as np


# In[38]:


n,k = map(int, input().split())
h = []
for _ in range(n):
    h.append(int(input()))


# In[43]:


h = np.array(h)
sorted_h = np.sort(h)
print(min(sorted_h[k-1:] - sorted_h[:-k+1]))



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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

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

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair

/* function */
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int n, a, b, sum, tmp;
    vector<int> v;
    cin >> n >> a >> b;
    rep(i, n + 1)
    {
        sum = 0;
        tmp = i;
        while (tmp != 0)
        {
            sum += tmp % 10;
            tmp /= 10;
        }
        if (a <= sum && sum <= b)
        {
            v.push_back(i);
        }
    }
    cout << accumulate(all(v), 0) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <utility>
#include <set>
#include <tuple>

int main() {
  int A, B, C;
  scanf("%d %d %d", &A, &B, &C);

  printf("%d\n", std::max(0, C-(A-B)));
}


Measured memory_bytes: 128
import sys
input = sys.stdin.readline

N, T = map(int, input().split())
d = []
for _ in range(N):
  d.append(list(map(int, input().split())))
d.sort(key = lambda x: x[0])
dp = [[0] * (T + 1) for _ in range(N + 1)]
res = 0
for i in range(N):
  for j in range(T):
    dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
    if j + d[i][0] <= T: dp[i + 1][j + d[i][0]] = max(dp[i + 1][j + d[i][0]], dp[i][j] + d[i][1])
    else: dp[i + 1][T] = max(dp[i + 1][T], dp[i][j] + d[i][1])
  #print(dp[i])
for i in range(N + 1):
  res = max(max(dp[i]), res)
print(res)

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

using namespace std;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    while( true ){

        int n, a, b, c, x;
        
        cin >> n >> a >> b >> c >> x;

        if(n == 0 && a == 0 && b == 0 && c == 0 && x == 0)
            break;

        vector<int> y(n);
        for( auto &x : y )
            cin >> x;

        int index = 0;

        for(int i = 0;i < 10001; i++) {

            if( y[index] == x )
                index++;

            if(index == n){
                cout << i << endl;
                break;
            }

            x = (a * x + b) % c;

        }

        if(index != n)
            cout << -1 << endl;

    }

    return 0;

}


Measured memory_bytes: 3100
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		
		String[] s = new String[n];
		
		for(int i = 0; i < n; i++) {
			s[i] = sc.next();
		}
		
		Arrays.sort(s);
		
		for(String t : s) {
			System.out.print(t);
		}

		System.out.println();
	}

}


Measured memory_bytes: 23764
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(int i=0;i<n;i++){cin>>a[i];}
    sort(a.begin(),a.end());
    ll ans=E;
    for(ll i=k-1;i<n;i++){
        ans=min(ans,a[i]-a[i-k+1]);
    }
    cout<<ans<<endl;
    
    
    
    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
  ll N; cin >> N;
  ll K; cin >> K;
  double ans = 0.0;
  for (ll j=0; j < N; ++j) {
    double q = 0;
    ll now = j+1;
    while (now < K) {
      now *= 2;
      q += 1;
    }
    ans += (1.0/N) * pow(0.5, q);
  }
  printf("%.10lf\n", ans);
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define EPS (1e-10)
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b; cin >> a >> b;
	int now = 1;
	if (b == 1) {
		cout << 0 << endl; return 0;
	}
	for (int i = 0; i < b; i++) {
		now -= 1;
		now += a;
		if (now  >= b) {
			cout << i + 1 << endl;
			break;
		}
	}
	return 0;
}

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

int main(){
    char b;
    cin >> b;

    if(b == 'A'){
        cout << 'T' << endl;
    }
    else if(b == 'T'){
        cout << 'A' << endl;
    }
    else if(b == 'G'){
        cout << 'C' << endl;
    }
    else if(b == 'C'){
        cout << 'G' << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	
	ll n,k;
	cin>>n>>k;
	priority_queue<ll> see;
	for( ll i=0;i<n;i++){
		ll x;
		cin>>x;
		see.push(x);
	}
	ll count = 0;
	while(!see.empty()){
		if(see.top() >= k) {count++; see.pop();}
		else break;
		
	}
	cout<<count;
	return 0;
}


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

int main() {
    int a, b ,c;
    cin >> a >> b >> c;
    if ((a == b && b != c) || (a == c && b != c) || (b == c && a != b))
    cout << "Yes" << endl;
    else 
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int c[3][3];
    REP(i,3) REP(j,3) cin>>c[i][j];
    REP(a0,101) REP(a1,101) REP(a2,101){
        int a[3]={a0,a1,a2};
        bool ok=true;
        int b[3]={c[0][0]-a0,c[1][1]-a1,c[2][2]-a2};
        REP(i,3) REP(j,3) if(c[i][j]!=a[i]+b[j]) ok=false;
        if(ok){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
using System;

namespace AOJ.Volume1
{
    public class MagicalTiles
    {
        public static void Main()
        {
            while (true)
            {
                var h_w = Console.ReadLine().Split(' ');
                int height = int.Parse(h_w[0]);
                int width = int.Parse(h_w[1]);
                if (height == 0 && width == 0) { break; }

                var room = new string[height, width];
                var check = new bool[height, width];
                for (int i = 0; i < height; i++)
                {
                    string line = Console.ReadLine();
                    for (int j = 0; j < width; j++)
                    {
                        room[i, j] = line.Substring(j, 1);
                        check[i, j] = false;
                    }
                }

                int x = 0;
                int y = 0;
                while (true)
                {
                    if (check[x, y])
                    {
                        Console.WriteLine("LOOP");
                        break;
                    }
                    string tile = room[x, y];
                    check[x, y] = true;

                    if (tile == ">") { y++; }
                    else if (tile == "<") { y--; }
                    else if (tile == "^") { x--; }
                    else if (tile == "v") { x++; }
                    else
                    {
                        Console.WriteLine(string.Format("{0} {1}", y, x));
                        break;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 9800
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	ll n, cntt = 0, cnt[5] = {}, cmp[5] = {}, sum = 0;
	bool f[5];
	for (int i = 0; i < 5; i++) {
		f[i] = false;
	}
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s[0] == 'M') {
			cnt[0]++;
		} else if (s[0] == 'A') {
			cnt[1]++;
		} else if (s[0] == 'R') {
			cnt[2]++;
		} else if (s[0] == 'C') {
			cnt[3]++;
		} else if (s[0] == 'H') {
			cnt[4]++;
		}
	}
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			for (int k = j + 1; k < 5; k++) {
				sum += cnt[i] * cnt[j] * cnt[k];
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
# s = input()
# n,m = map(int, input().split())
# x = list(map(int, input().split))

count = 0
for i in range(1,n+1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    else: 
        count+= i
print(count)

Measured memory_bytes: 64596
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
		int n,k,temp;
		cin >> n >> k;
		vector<int> v(n,0);
		for(int i=0;i<n;i++){
			cin >> temp;
			v[temp-1]++;
		}
		vector<int> v2;
		for(int i=0;i<n;i++){
			if(v[i] != 0){
				v2.push_back(v[i]);
			}
		}
		sort(v2.begin(),v2.end());
		int ans = 0;
		if(v2.size() <= k){
			ans = 0;
		}else{
			for(int i=0;i<v2.size()-k;i++){
				ans += v2[i];
			}
		}
		cout << ans << endl;
}

Measured memory_bytes: 2168
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = 1;
        int b = 1;
            for (int t = 0;t !=9; t++) {

            for (int i = 0;i != 9; i++) {
                System.out.println(a + "x" + b + "=" + a * b);

                b++;

            }
            b = 1;
            a++;
        }
    }
}


Measured memory_bytes: 25840
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)
const ll INF = (1LL << 50);
typedef pair<int, int>P;

bool cmp(const P& a, const P& b) {
	return a.first > b.first;
}

int main() {

	int n;
	cin >> n;

	vector<int>v(n);

	REP(i, n) cin >> v[i];

	map<int, int> mp1, mp2;
	for (int i = 0; i < n; i += 2) mp1[v[i]]++;

	for (int i = 1; i < n; i += 2) mp2[v[i]]++;

	vector<P> num1, num2;
	for (auto& p : mp1) num1.emplace_back(p.second, p.first);//頻度,数
	for (auto& p : mp2) num2.emplace_back(p.second, p.first);
	

	sort(num1.begin(), num1.end(), cmp);
	sort(num2.begin(), num2.end(), cmp);

	if (num1[0].second == num2[0].second) {
		int n1 = n - num1[0].first - num2[1].first;
		int n2 = n - num2[0].first - num1[1].first;
		cout << min(n1, n2) << endl;
	}
	else {
		cout << n - num1[0].first - num2[0].first << endl;
	}



	return 0;

}

Measured memory_bytes: 6520
l = input().split()
N = int(l[0])
X = int(l[1])

l = input().split()
L = [int(x) for x in l]

# print(N, X, L)

pos = 0
for i in range(N):
    pos += L[i]
    if pos > X:
        print(i + 1)
        exit()

print(N + 1)


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


int main()
{
    int n,x,k;
    cin >> n >> k;
    int dp[n];
    memset(dp, 9999999, sizeof dp);
    int L[n];
    cin >> x;
    dp[0]=0;
    L[0]=x;

    for (int i=1;i<n;i++) cin >> L[i];

    for (int i=1;i<n;i++){
        x=L[i];
        for (int j=1;j<k+1;j++){
            if (i-j>=0) dp[i]=min(dp[i], dp[i-j]+abs(x-L[i-j]));
        }
    }
    //for (auto e:dp) cout << e << " " << endl;
    cout << dp[n-1];
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
from collections import Counter
from itertools import chain
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, a: "List[int]"):
    ctr = Counter(chain.from_iterable(
        (ai - 1, ai, ai + 1)
        for ai in a
    ))
    print(ctr.most_common(1)[0][1])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25808