akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Rahul Raj
 */
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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            Map<Integer, Integer> map = new HashMap<Integer, Integer>();
            for (int i = 0; i < 3; i++) {
                int num = in.nextInt();
                if (map.size() == 0) {
                    map.put(num, 1);
                } else if (map.get(num) == null) {
                    map.put(num, 1);
                } else {
                    map.put(num, map.get(num) + 1);
                }
            }

            for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
                if (entry.getValue() == 1) {
                    out.println(entry.getKey());
                    break;
                }
            }

        }

    }
}



Measured memory_bytes: 21972
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	if( a==1 && b!=1 )
		cout <<"Alice"<<endl;
	else if( b==1 && a!=1 )
		cout <<"Bob"<<endl;
	else if( a>b )
		cout <<"Alice"<<endl;
	else if( a<b )
		cout <<"Bob"<<endl;
	else
		cout <<"Draw"<<endl;
	return 0;
}

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

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	int cnt=0;
	
	for(int i=1;i<=n/2;i++)
	{
		int temp=n-i;
		if(temp!=i) cnt++;
	}
	
	cout<<cnt;
					                                				
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;
string st;
int main(){
	cin>>st;
	printf("%c%d%c\n",st[0],st.length()-2,st[st.length()-1]);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
using namespace std;

int main(){
	int num,cnt;
	cin>>num;
	for(int i=1;i<=num;i++){
		int tmp;
		cin>>tmp;
		if(tmp!=i)cnt++;
	}
	if(cnt<=2){
		cout<<"YES";
	}else{
		cout<<"NO";
	}
	return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
D=0
zcnt=0
fcnt=0
m=10**9
for i in range(N):
  D+=abs(A[i])
  m=min(m,abs(A[i]))
  if A[i]<0:
    fcnt+=1
  elif A[i]==0:
    zcnt+=1

if ((fcnt%2)==1) and (zcnt==0):
  print(D-2*m)  
else:
  print(D)

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

#define infi            5e9
#define infl            5e18
#define MX              100005
#define pi              2*acos(0.0)
#define ll              long long int
#define rr              read()
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define ms(a,b)         memset(a, b, sizeof(a))
#define loop(i,n)       for(register int i=0;i<n;i++)
#define pool(i,n)       for(register int i=n-1;i>=0;i--)
#define loop1(i,n)      for(register int i=1;i<=n;i++)
#define pool1(i,n)      for(register int i=n;i>0;i--)

using namespace std;

inline ll read(){char c=getchar();ll num,sign=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;for(num=0;c>='0'&&c<='9';){c-='0';num=num*10+c;c=getchar();}return num*sign;}
inline ll pw(ll b, ll p){ll ans=1;while(p>0){if(p&1)ans*=b;p>>=1;b*=b;}return ans;}
// inline bool isPrime(ll n){if(n==1)return false;if(n==2)return true;if(!(n%2))return false;for(ll i=3;i<=sqrt(n);i+=2)if(!(n%i))return false;return true;}
// inline ll gcd(ll a, ll b){if(a==0)return b;return gcd(b%a,a);}

// //*************************************  Bitmask Opereations  **********************************//
// int Set(int N,int pos){return N=N | (1<<pos);}
// int reset(int N,int pos){return N= N & ~(1<<pos);}
// bool check(int N,int pos){return (bool)(N & (1<<pos));}
// //********************************************************************************************//


int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //#ifdef rid.dle
    //freopen("in.txt", "r", stdin);//#endif
    
    ll n=rr;

    ll ans=n/11;
    ans<<=1;

    if(n%11){
        if((n%11) > 6)ans+=2;
        else ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,M,Q = map(int,input().split())
LR = [list(map(int,input().split())) for _ in [0]*M]
PQ = [list(map(int,input().split())) for i in range(Q)]

c = [[0]*N for _ in [0]*N]

for l,r in LR:c[l-1][r-1] +=1

S = [[0]*(N+1) for _ in [0]*(N+1)]
for i in range(N):
    for j in range(N):
        S[i+1][j+1] = S[i+1][j] + c[i][j]
for i in range(N):
    for j in range(N):
        S[i+1][j+1] += S[i][j+1]

for p,q in PQ:print(S[q][q] + S[p-1][p-1] - S[p-1][q] - S[q][p-1])

Measured memory_bytes: 79124
#include <bits/stdc++.h>
#define int long long
#define gcd            __gcd
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x,y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main()
{
    nitin;
    int n;
    cin>>n;
    string s;
    cin>>s;
    int red=0;
    int white=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
            red++;
        if(s[i]=='W')
            white++;
    }
    int a=0;
    int b=0;
    for(int i=0;i<red;i++)
    {
        if(s[i]=='W')
            a++;
    }
    for(int i=red;i<n;i++)
    {
        if(s[i]=='R')
        {
            b++;
        }
    }
    cout<<max(a,b)<<endl;
    return 0;

}

Measured memory_bytes: 3776
#include<stdio.h>
 
int main(){
  int length,A[100],i=0,j=0,flag=0,key;
 
  scanf("%d",&length);
 
  while(i < length){
    scanf("%d",&A[i]);
    i++;
  }
 
  for(i = 0;i < length-1;i++){
    for(j = length-1;j >= 1;j--){
 
      if(A[j] < A[j-1]){
    key = A[j-1];
    A[j-1] = A[j];
    A[j] = key;
    flag++;
      }
    }
  }
 for(i = 0;i < length-1;i++){
      printf("%d ",A[i]);
    }
    printf("%d\n",A[i]);
    printf("%d\n",flag);
    return 0;
}

Measured memory_bytes: 600
import heapq
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[0])

hq = []
ans, j = 0, 0

for i in range(1, M + 1):
    while (j < N) and (X[j][0] <= i):
        heapq.heappush(hq, -X[j][1])
        j += 1
    if len(hq):
        ans += -heapq.heappop(hq)

print(ans)


Measured memory_bytes: 31956
#include <stdio.h>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, a, b, ans = 0, n, m;
  scanf("%lld%lld", &a, &b);
  n = a & 3, m = b & 3;
  m++;
  n >>= 1, m >>= 1;
  n &= 1, m &= 1;
  if(n ^ m) ans = 1;
  for(i = 1; (1ll << i) <= b; ++i) {
    ll tmp = 1ll << (i + 1);
    bool s = false;
    tmp--;
    n = a & tmp, m = b & tmp;
    if(n > (1ll << i)) s = ((1ll << (i + 1)) - n) & 1;
    if(m >= (1ll << i)) s = s ^ ((m + 1) & 1);
    if(s) ans += (1ll << i);
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 128
down = []		# 下り坂の開始地点のスタック
lake = []			# 湖の面積のスタック
distance = 0		# 左端から数えた水平距離

gets.chomp.chars do |road|
	if road == "\\"
		down.push(distance)
	elsif road == "/"
		next if down.empty?	# すべての下り坂より高い地点への上昇は計算しない
		temp_area = distance - down.pop	# 一時的に算出した湖の面積
		
		if lake[down.length + 1] != nil
			temp_area += lake.pop.inject(:+)	# 低い位置の湖の面積を合算する
		end
		
		if lake[down.length] == nil
			lake[down.length] = [temp_area]	# nil ならば、要素1の"配列"を代入
		else
			lake[down.length].push(temp_area)
		end
	end

	distance += 1
end

if lake.empty?
	print "0\n0\n"
else
	lake = lake.compact.flatten!
	puts lake.inject(:+)
	puts "#{lake.length} #{lake.join(" ")}"
end


Measured memory_bytes: 7144
import itertools
def op(x,y,i):
    if i=="+": return x+y
    elif i=="-": return x-y
    elif i=="*": return x*y

e0 = '((({0} {1} {2}) {3} {4}) {5} {6})'
e1 = '(({0} {1} {2}) {3} ({4} {5} {6}))'
def check(A, n):
    w,x,y,z = A
    S="+-*"
    for i in S:
        a = op(w,x,i)
        for j in S:
            b = op(a,y,j)
            for k in S:
                if op(b,z,k)==n: return e0.format(w,i,x,j,y,k,z)
            b = op(y,z,j)
            for k in S:
                if op(a,b,k)==n: return e1.format(w,i,x,k,y,j,z)
    return ''

n=10
while 1:
    x = map(int,raw_input().split())
    if x==[0,0,0,0]: break
    x =[map(int,list(e)) for e in itertools.permutations(x)]
    for e in x:
        s = check(e,n)
        if s!="": break
    else: s = "0"
    print s

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

using namespace std;
typedef long long int ll;

const int MAXN = 310;
int n, m, l;
ll dp[MAXN][MAXN], dist[MAXN][MAXN];
vector <pair<ll,ll>> adj[MAXN];
set <pair<ll, ll>> s;

void dij(ll r)
{
	s.clear();
	s.insert({0, r});
	dist[r][r] = 0;
	for(int i = 0; i < n; i++)
	{
		if(i == r)
			continue;
		dist[r][i] = LLONG_MAX / 4;
		s.insert({dist[r][i], i});
	}
	for(int i = 0; i < n; i++)
	{
		ll mn = s.begin()->second;
		s.erase(*s.begin());
		for(int i = 0; i < (int)adj[mn].size(); i++)
		{
			ll u = adj[mn][i].first, w = adj[mn][i].second;
			if(dist[r][u] > dist[r][mn] + w)
			{
				s.erase({dist[r][u], u});
				dist[r][u] = dist[r][mn] + w;
				s.insert({dist[r][u], u});
			}	
		}
	}
	return;
} ///////////////

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m >> l;
	for(int i = 0; i < m; i++)
	{
		int a, b, c;
		cin >> a >> b >> c;
		if(c > l)
			continue;
		a--, b--;
		adj[a].push_back({b, c});
		adj[b].push_back({a, c});
	}
	for(int i = 0; i < n; i++)
		dij(i);
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			if(dist[i][j] > l && i != j)
				dp[i][j] = LLONG_MAX / 2;
	for(int k = 0; k < n; k++)
		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + 1);
	int q;
	cin >> q;
	while(q--)
	{
		int a, b;
		cin >> a >> b;
		a--, b--;
		if(dp[a][b] > n)
			cout << -1 << endl;
		else
			cout << dp[a][b] << endl;
	}
	return 0; 
}


Measured memory_bytes: 4352
#include <iostream>
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i, 0, n)
using namespace std;
int a[81], b[81];
int main()
{
    int n; cin >> n;
    while (n--) {
        rep(i, 81) a[i] = b[i] = 0;
        string s, t;
        cin >> s >> t;
        rep(i, s.size()) a[i] = s[s.size()-i-1]-'0';
        rep(i, t.size()) b[i] = t[t.size()-i-1]-'0';

        int c = 0;
        rep(i, 81) {
            a[i] = a[i] + b[i] + c;
            if (a[i] >= 10) { a[i] -= 10; c = 1; }
            else c = 0;
        }
        if (a[80] != 0)
            cout << "overflow" << endl;
        else {
            int k = 80; while (k > 0 && a[k] == 0) k--;
            for (int i = k; i >= 0; --i) cout << a[i];
            cout << endl;
        }
    }
    return 0;
}

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

long long n, a[100009], b[100009], s, minx = (1LL << 60); bool flag = false;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
		if (a[i] != b[i]) flag = true;
		s += a[i];
		if (a[i] > b[i]) minx = min(minx, b[i]);
	}
	if (flag == false) cout << "0" << endl;
	else cout << s - minx << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int min = 100;
		for (int i = 0;i < N; i++) {
			int sum = 0;
			int a = sc.nextInt();
			while(a % 2 == 0) {
				a = a/2;
				sum = sum + 1;
			}
			if(min > sum) {
				min = sum;
			}
		}
		System.out.println(min);
		sc.close();
	}
}

Measured memory_bytes: 23124
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(){

    long long int a, max_div = -1, sub = -1;
    scanf("%lld", &a);

    for(int i = 1; i <= sqrt((double)a); ++i){
        if (a%i == 0){
            max_div = i;
            sub = a/i;
        }
    }
    //printf("%lld %lld\n", max_div, sub);
    printf("%lld\n", max_div + sub -2);


    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
using namespace std;
int b[1407][1407], dp[1407][1407];
int main() {
    int h, w, maxa = 0;
    scanf("%d%d", &h, &w);
    for (int i = 1; i <= h; i++) {
    	for (int j = 1; j <= w; j++) {
    		scanf("%d", &b[i][j]);
		}
	}
	for (int i = 1; i <= h; i++) {
    	for (int j = 1; j <= w; j++) {
    		if (b[i][j] == 1) dp[i][j] = 0;
			else {
				dp[i][j] = min(min(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1]) + 1;
				maxa = max(maxa, dp[i][j]);
			}
		}
	}
	printf("%d\n", maxa * maxa);
	return 0;
}


Measured memory_bytes: 18140
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;

const ll MOD = 998244353;
int K, N;

const int SIZE = 5010;
ll fact[SIZE], finv[SIZE];

ll mod_pow(ll N, ll K) {
    ll ret = 1;
    for(; K>0; K>>=1) {
        if(K & 1) (ret *= N) %= MOD;
        (N *= N) %= MOD;
    }
    return ret;
}

void init_array() {
    fact[0] = 1;
    for(int i=1; i<SIZE; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
    }

    finv[SIZE-1] = mod_pow(fact[SIZE-1], MOD-2);
    for(int i=SIZE-1; i>=0; i--) {
        finv[i-1] = (finv[i] * i) % MOD;
    }
}

ll comb(int n, int r) {
    ll ret = (n-r < 0 ? 0 : fact[n] * finv[n-r] % MOD * finv[r] % MOD);
    // fprintf(stderr, "comb(%d, %d) = %lld\n", n, r, ret);
    return ret;
}

ll solve(int x) {
    int pair_cnt = 0, corner = 0;
    for(int i=x-K; i<x; i++) {
        if(1 <= i and i <= K) {
            if(i != x - i) {
                if(i < x - i) pair_cnt++;
            }
            else {
                corner++;
            }
        }
    }

    // fprintf(stderr, "x = %d, pair_cnt = %d, corner = %d\n", x, pair_cnt, corner);
    ll ans = 0;
    for(int k=0; k<2; k++) {
        int whole = N - k, rest = K - 2 * pair_cnt - corner;
        if(corner < k or rest < 0) continue;
        // fprintf(stderr, "whole = %d, rest = %d\n", whole, rest);
        // ペアから何種類持ってくるか
        for(int i=0; i<=pair_cnt; i++) {
            if(i > whole or rest + i == 0) continue;
            int cur_whole = whole - i;
            // fprintf(stderr, "cur_whole = %d, i = %d\n", cur_whole, i);
            (ans += comb(pair_cnt, i) * comb(cur_whole + rest + i - 1, cur_whole) % MOD * mod_pow(2, i) % MOD) %= MOD;
        }
    }
    return ans;
}

int main() {
    init_array();
    cin >> K >> N;
    for(int x=2; x<=2*K; x++) {
        cout << solve(x) << endl;
    }
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

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

// Problem Specific Parameter:

char res[4];

bool query(string s1,string s2){
	printf("%s\n%s\n", s1.c_str(), s2.c_str());
	fflush(stdout);
	scanf("%s",res);
	return (res[0]=='e');
}

int main(void){
	int n;
	scanf("%d",&n);

	string all[2]={"",""};
	
	rep(i,n){
		bool ok=false;
		rep(mask,4){
			string t0=string(1,((mask&2)?'#':'.'));
			string t1=string(1,((mask&1)?'#':'.'));			
			if(query(all[0]+t0,all[1]+t1)) return 0;
			if(res[0]=='T'){
				all[0]=all[0]+t0,all[1]=all[1]+t1;
				ok=true;
				break;
			}
		}
		if(ok==false) break;
	}

	rep(i,n){
		bool ok=false;
		rep(mask,4){
			string t0=string(1,((mask&2)?'#':'.'));
			string t1=string(1,((mask&1)?'#':'.'));			
			if(query(t0+all[0],t1+all[1])) return 0;
			if(res[0]=='T'){
				all[0]=t0+all[0],all[1]=t1+all[1];
				ok=true;
				break;
			}
		}
		if(ok==false) break;
	}

	return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;
    
    int k, i, j, n;
    k  = 0;
    
    cin >> s;
    
    n = s.size();
    
    for(i = 0, j = n - 1; i < j; ++i, --j)
    {
        if (s[i] != s[j])
        {
            ++k;
        }
    }
    
    cout << k;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    if (a+W < b) {
        cout << abs(a+W-b) << endl;
    } else if (b+W < a) {
        cout << abs(b+W-a) << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N =int(input())
A =[int(i)for i in input().split()]
A =sorted(A,key=lambda x:abs(x))
M =A.pop(0)
ans = []
while len(A)!=0:
    num =len(A)
    for n in range(num):
        n = num -1 - n
        if A[n]*M <= 0:
            foo =A.pop(n)
            ans.append([M,foo])
            M = M - foo
    if len(ans)==0:
        foo =A.pop(0)
        ans.append([M,foo])
        M = M -foo
    else:
        a,b = ans[-1]
        ans[-1] = [b,a]
        M = -M

if M < 0:
    a,b = ans[-1]
    ans[-1] = [b,a]
    M = -M

print(M)
prans = "\n".join(["{} {}".format(i,j) for i,j in ans])
print(prans)

Measured memory_bytes: 29476
#include <iostream>
#define INF 1000000001
using namespace std;
int arr[100001];
int state[100001];
int n;
int dp(int ind) {
	if (ind == n - 1)
		return 0;
	else if (ind == n)
		return INF;
  	if (state[ind] == -1) {
    	state[ind] = min(dp(ind + 1) + abs(arr[ind + 1] - arr[ind]), dp(ind + 2) + abs(arr[ind + 2] - arr[ind]));
  	}

	return state[ind];
}

int main() {
	cin >> n;
  	for (int i = 0; i < n; i++) {
        state[i] = -1;
      	cin >> arr[i];
    }
  	cout << dp(0) << '\n';
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define REP(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 15;

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);

    string s; cin >> s;
    int n = s.length();
    int cnt = 0;

    int right = 0;

    stack<char> stk;

    while(right < n){

        if(stk.empty()){
            stk.push(s[right]);
            right++;
            continue;
        }

        if(s[right] == stk.top()){
            stk.push(s[right]);
            right++;
        } else {
            while(!stk.empty() && right < n && stk.top() != s[right]){
                cnt += 2;
                right++;
                stk.pop();
            }
        }
    }

    cout << cnt << endl;



    return 0;
}


Measured memory_bytes: 512
use proconio::marker::*;
use proconio::*;

#[derive(Debug)]
#[allow(non_snake_case)]
struct Input {
    D: usize,
    c: Vec<i64>,
    s: Vec<Vec<i64>>,
    t: Vec<usize>,
    lasts: Vec<usize>,
    d: usize,
}

#[allow(non_snake_case)]
impl Input {
    fn new(D: usize, c: Vec<i64>, s: Vec<Vec<i64>>) -> Input {
        Input {
            D,
            c,
            s,
            t: vec![0; D],
            lasts: vec![0; 26],
            d: 0,
        }
    }

    fn proc(&mut self) -> i64 {
        self.lasts[self.t[self.d]] = self.d + 1;
        let res = self.calc();
        self.d += 1;
        res
    }

    fn calc(&self) -> i64 {
        let mut score = self.s[self.d][self.t[self.d]];

        for i in 0..26 {
            score -= (self.d + 1 - self.lasts[i]) as i64 * self.c[i];
        }

        score
    }
}

#[allow(non_snake_case)]
fn main() {
    input! {
        D: usize,
        c: [i64; 26],
        s: [[i64; 26]; D],
    };
    input! {
        t: [Usize1; D],
    };
    let mut obj = Input::new(D, c, s);
    obj.t = t;
    let mut score = 0;

    for _ in 0..D {
        score += obj.proc();
        println!("{}", score);
    }
}


Measured memory_bytes: 2264
# -*- coding:utf-8
while True:
    A = list(map(str,input().split()))
    a = int(A[0])
    b = int(A[2])

    if A[1] == '+':
        print(a + b)
    elif A[1] == '-':
        print(a - b)
    elif A[1] == '*':
        print(a * b)
    elif A[1] == '/':
        print(a // b)
    elif A[1] == '?':
        break


Measured memory_bytes: 5596
# include <bits/stdc++.h>
# define INF 1e9 + 1
using namespace std;

int main(){

  long int N, M, L;
  cin >> N >> M >> L;
  long int d[N][N];
  for(int i=0; i<N; i++) for(int j=0; j<N; j++) d[i][j] = INF;
  for(int i=0; i<N; i++) d[i][i] = 0;
  for(int i=0; i<M; i++){
    long int a, b, c;
    cin >> a >> b >> c;
    if (c <= L){
      d[a-1][b-1] = c;
      d[b-1][a-1] = c;
    }
  }

  for(int k=0; k<N; k++){
    for(int i=0; i<N; i++){
      for(int j=0; j<N; j++){
        long int v = d[i][k]+d[k][j];
        d[i][j] = min(d[i][j], v);
      }
    }
  }

  // for(int i=0; i<N; i++){
  //   for(int j=0; j<N; j++){
  //     cout << d[i][j] << endl;
  //   }
  // }

  long int g[N][N];
  for(int i=0; i<N; i++) for(int j=0; j<N; j++) g[i][j] = INF;
  for(int i=0; i<N; i++) g[i][i] = 0;

  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      // cout << d[i][j] << endl;
      if(d[i][j] <= L) g[i][j] = 1;
    }
  }

  for(int k=0; k<N; k++){
    for(int i=0; i<N; i++){
      for(int j=0; j<N; j++){
        long int v = g[i][k]+g[k][j];
        g[i][j] = min(g[i][j], v);
      }
    }
  }


  int Q;
  cin >> Q;
  // cout << Q << endl;
  for(int i=0; i<Q; i++){
    int s, t;
    cin >> s >> t;
    if(g[s-1][t-1] == INF) cout << -1 <<endl;
    else cout << g[s-1][t-1]-1 << endl;
  }
}

Measured memory_bytes: 1920
#include<stdio.h>
int main(void)
{
    int h,m,s,S;
    scanf("%d",&S);
     
    h=S/3600;
    m=S%3600/60;
    s=S%3600%60;
    
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


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

using namespace std;
using ll = long long;
using Pll = pair<ll, ll>;
constexpr int MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; ++i) {
    int a, b;
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }
  vector<ll> fact(N), factinv(N), inv(N);
  fact[0] = fact[1] = 1;
  factinv[0] = factinv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < N; ++i) {
    fact[i] = fact[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    factinv[i] = factinv[i - 1] * inv[i] % MOD;
  }
  function<ll(ll)> modinv = [&](ll x) {
    ll b = MOD, u = 1, v = 0;
    while (b) {
      ll t = x / b;
      x -= t * b;
      u -= t * v;
      swap(x, b);
      swap(u, v);
    }
    return (u + MOD) % MOD;
  };
  vector<map<int, Pll>> dp(N);
  function<Pll(int, int)> dfs = [&](int u, int par) {
    if (!dp[u].count(par)) {
      Pll ret = {1, 1};
      if (!dp[u].count(-1)) {
        for (int v : G[u]) {
          if (v != par) {
            Pll t = dfs(v, u);
            ret.first += t.first;
            ret.second = ret.second * t.second % MOD;
            ret.second = ret.second * factinv[t.first] % MOD;
          }
        }
        ret.second = ret.second * fact[ret.first - 1] % MOD;
      } else {
        ret = dp[u][-1];
        Pll t = dfs(par, u);
        ret.second = ret.second * factinv[ret.first - 1] % MOD;
        ret.second = ret.second * fact[t.first] % MOD;
        ret.first -= t.first;
        ret.second = ret.second * fact[ret.first - 1] % MOD;
        ret.second = ret.second * modinv(t.second) % MOD;
      }
      dp[u][par] = ret;
    }
    return dp[u][par];
  };
  vector<ll> id(N), ans(N);
  iota(id.begin(), id.end(), 0);
  sort(id.begin(), id.end(),
       [&](const int &l, const int &r) { return G[l].size() > G[r].size(); });
  for (int i = 0; i < N; ++i) ans[id[i]] = dfs(id[i], -1).second;
  for (int i = 0; i < N; ++i) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 68596
/* ****mittal21**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define endl        '\n'
#define pii         pair<long long int,long long int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define hell        1000000007
#define jell        998244353
#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 DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
#define N  4005
ll fac[N];
ll binpow(ll a,ll b,ll mod)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}
void solve()
{
   fac[0]=1;
   for(ll i=1;i<=4001;i++)
   {
   	  fac[i]=(fac[i-1]*i)%hell;
   }
   ll s;
   cin>>s;
   ll ans=0;
   for(ll i=1;i<=2000;i++)
   {
        if(s<i*3)
        	continue;
        ll cnt=1;
        ll o=s-i*3;
        cnt=fac[o+i-1];
        cnt=(cnt*binpow(fac[i-1],hell-2,hell))%hell;
        cnt=(cnt*binpow(fac[o],hell-2,hell))%hell;
        ans=(ans+cnt)%hell;

   }
   cout<<ans<<endl;
   return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <math.h>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);

	int minNum = INT_MAX, minIdx = 0;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
		if (abs(A[i]) < minNum)
		{
			minNum = abs(A[i]);
			minIdx = i;
		}
	}

	for (int i = 0; i < minIdx; ++i)
	{
		if (A[i] < 0)
		{
			A[i] = -A[i];
			A[i + 1] = -A[i + 1];
		}
	}
	for (int i = N - 1; i > minIdx; --i)
	{
		if (A[i] < 0)
		{
			A[i] = -A[i];
			A[i - 1] = -A[i - 1];
		}
	}

	long long int ans = 0;
	for (int i = 0; i < N; ++i)
	{
		ans += A[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
x=int(input())
def ans():
  if x<100:
    print(0)
    return
  s=str(x)
  sl=len(s)
  m=int(s[sl-2]) #十の位
  n=int(s[sl-1]) #一の位
  sum=0
  sum+=105*((m*10)/5) #105円を複数買って十の位満たす
  while n>0:
    if n>=5:#105円を買う
      sum+=105
      n-=5
    else:#101,2,3,4円を買う
      sum+=100+n
      n-=n
  if x-sum>=0:#残りで100円を買う
    print(1)
    return
  print(0)
ans()

Measured memory_bytes: 38704
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath> 
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
const int maxn = 1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
int n;
int main()
{
	double r;
	cin>>r;
	cout<<2*r*PI<<endl;
	return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

struct BIT{
    ll n;
    vector<ll> d;
    BIT(ll n=0): n(n),d(n+1) {}

    void add(ll i, ll x=1){
        for(i++; i<=n; i+=i&-i){
            d[i]+=x;
        }
    }

    ll sum(ll i){
        ll x=0;
        for(i++; i; i-=i&-i){
            x+=d[i];
        }
        return x;
    }
};

int main(){
    ll n,q;
    cin>>n>>q;
    vector<ll> c(n);
    for(ll i=0;i<n;i++) cin>>c[i];
    vector<ll> pi(n+1,-1);
    vector<vector<ll> > ps(n);
    for(ll i=0;i<n;i++){
        ll l=pi[c[i]];
        if(l != -1){
            ps[l].push_back(i);
        }
        pi[c[i]]=i;
    }

    vector<vector<P> > qs(n);
    vector<ll> ans(q,0);

    for(ll i=0;i<q;i++){
        ll l,r;
        cin>>l>>r;
        l--; r--;
        qs[l].emplace_back(make_pair(r,i));
        ans[i]=r-l+1;
    }

    struct BIT d(n);
    for(ll x=n-1;x>=0;x--){
        for(ll y:ps[x]) d.add(y,1);
        for(P q:qs[x]){
            ll r=q.first;
            ll i=q.second;
            ans[i]-=d.sum(r);
        }
    }

    for(ll i=0;i<q;i++){
        cout<<ans[i]<<endl;
    }

}

Measured memory_bytes: 70852
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val V = Array(N) { mutableListOf<Pair<Int, Int>>() }
    repeat(M) { m ->
        val py = listOfInt()
        V[py[0] - 1].add(py[1] to m)
    }
    fun d6(n: Int) = "%06d".format(n)
    fun d12(p: Int, y: Int) = d6(p) + d6(y)
    val ans = Array(M) { "" }
    V.forEachIndexed { m, v ->
        v.sortedBy { it.first }.forEachIndexed { n, p -> ans[p.second] = d12(m + 1, n + 1) }
    }
    println(ans.joinToString(separator = "\n"))
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 140584
import string

N = int(input())
S = list(input())

lis = list(string.ascii_uppercase)
answer = []

for s in S:
    index = lis.index(s)
    slide_index = index + N
    if slide_index > 25:
        slide_index -= 26
    new_s = lis[slide_index]
    answer.append(new_s)

answer = ''.join(answer)

print(answer)


Measured memory_bytes: 3768
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
inline int mex(unordered_set<int> st)
{
    int m = 0;
    while (st.find(m) != st.end())
    {
        m += 1;
    }
    return m;
}
inline int calculateGrundy(int n)
{
    if (n == 1)
        return 0;
    unordered_set<int> mexi;
    for (int i = 1; i <= sqrt(n); i += 1)
    {
        if (n % i == 0)
        {
            if (n / i != n)
                mexi.insert(calculateGrundy(n / i));
            mexi.insert(calculateGrundy(i));
        }
    }
    return mex(mexi);
}
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> red(a, 0);
    vector<ll> green(b, 0);
    vector<ll> less(c, 0);
    f(i, 0, a)
    {
        cin >> red[i];
    }
    f(i,0,b)
    {
        cin >> green[i];
    }
    f(i, 0, c)
    {
        cin >> less[i];
    }
    sort(all(red), greater<ll>());
    sort(all(green), greater<ll>());
    sort(all(less), greater<ll>());
    vector<ll> fina(x + y, 0);
    f(i, 0, x)
    {
        fina[i] = red[i];
    }
    f(i, x, x+y)
    {
        fina[i] = green[i-x];
    }
    sort(all(fina));
    ll sum = 0;
    f(i, 0, x+y)
    {
        if ((i<c) && fina[i] < less[i])
            sum += less[i];
        else
            sum += fina[i];
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
int main() {
  int d;
  cin >> d;
  cout << "Christmas ";
  if(d != 25) {
    for(int i = 0;i < 25 - d - 1;i++) {
      cout << "Eve ";
    }
    cout << "Eve" << endl;
  }
}

Measured memory_bytes: 256
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-30:23:34:37
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

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

  double w, h, x, y; cin >> w >> h >> x >> y;
  cout << setprecision(15) << w * h / 2 << " ";
  if (w == x * 2 && h == y * 2) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, L;
    cin >> n >> L;

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    ll maxLen = -1;
    ll pos = -1;
    rep(i, n-1) {
        if(maxLen < a[i] + a[i+1]) {
            maxLen = a[i] + a[i+1];
            pos = i;
        }
    }

    if(maxLen < L) {
        out("Impossible");
        re0;
    }

    out("Possible");

    rep(i, pos) {
        out(i+1);
    }
    for(ll i = n-2; i > pos; i--) {
        out(i+1);
    }
    out(pos+1);

    re0;
}

Measured memory_bytes: 1664
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut a: [i64; n],
    };
    a.sort();
    let s = std::iter::once(0)
        .chain(a.iter().scan(0, |acc, a_i| {
            *acc += a_i;
            Some(*acc)
        }))
        .collect::<Vec<_>>();
    let c = a
        .iter()
        .zip(s.iter())
        .rposition(|(&a_i, &s_i)| s_i * 2 < a_i)
        .unwrap_or(0);
    let ans = n - c;
    println!("{}", ans);
}


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

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  if (s=="RSS") cout << 1 << endl;
  else {
  if (s[0]=='R') cnt++;
  if (s[1]=='R') cnt++;
  else cnt=0;
  if (s[2]=='R') cnt++;
  cout << cnt << endl;
  }
}

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

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

  sort(d.begin(), d.end());
  int half = N / 2;
  int ans = d[half] - d[half-1];
  
  cout << ans << endl;
  return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


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

    map<ll,ll> A;
    map<ll,ll> B;
    REP(i,N){
        ll a;
        cin >> a;
        A[i+a]++;
        B[i-a]++;
    }
    ll ans = 0;
    for(auto x: A){
        ans += x.second * B[x.first];
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
  int n,t = 0,min = 10000, i = 0, j = 0, k = 0,sum_1 = 0,sum_2 = 0,re = 0;
  int w[100];
  cin >> n;
  for( i = 0; i < n; i++ ){
    cin >> w[i];
  }
  for( i = 0; i < n; i++ ){
    sum_1 = 0;
    sum_2 = 0;
    re = 0;
    for( j = 0; j <= t; j++ ){
      sum_1 = sum_1 + w[j];
    }
    for( k = t + 1; k < n; k++ ){
      sum_2 = sum_2 + w[k];
    }
    re = sum_2 - sum_1;
    if( re < 0 ){
      re = (-1)*re;
    }

    if( re < min )
    {
      min = re;
    }
    t++;
  }
  cout << min << endl;
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  int Ans=0;
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  for(int i=0; i<N; i++){
    for(int j=1; j<=30; j++){
      if(A.at(i)%(int)pow(2, j)==0){
        Ans++;
      }
      else{
        break;
      }
    }
  }
  cout << Ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;

int main(){
    int N;cin>>N;
    vector<pair<pair<string, int>, int>> q(N);
    REP(i, N){
        string s;
        int p;
        cin >> s >> p;
        q[i] = make_pair(make_pair(s, -p), i);
    }

    sort(q.begin(), q.end());
    REP(i, N){
        cout << q[i].second+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        a: usize,
    );
    
    println!("{}", 3 * a * a);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

int main(){
  string S;
  cin>>S;
  bool flg=true;
  for(int i=0;i<3;i++){
          if(S[i]==S[i+1]){
              flg=false;
          }
      }
  if(flg){
      cout<<"Good"<<endl;
  }
  else{
      cout<<"Bad"<<endl;
  }
} 

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

int main() {
	int n,a,b,pa,pb;
	while(pa=pb=0,cin>>n,n){
		for(;n;--n){
			cin>>a>>b;
			if(a>b)pa+=(a+b);
			else if(a<b)pb+=(a+b);
			else pa+=a,pb+=b;
		}
		cout<<pa<<" "<<pb<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
from collections import deque

N, M = map(int, input().split())

if N < M : 

    X = sorted(list(map(int, input().split())))
    
    move = []
    
    for i in range(len(X)-1) : 
        move.append(X[i+1] -X[i])
        
    # print(move)

    move = sorted(move)    

    # print(move)
    
    sum = 0
    
    for i in range(M-N) : 
        sum += move[i]

else : 
    sum = 0
    
print(sum)

Measured memory_bytes: 14216
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

#define ff          first
#define ss          second
#define ll          int64_t
#define ld          long double
#define nl          cout<<"\n"
#define dbg(x)      cerr<<#x<<" = "<<x<<"\n"
#define dbg2(x,y)   cerr<<#x<<" = "<<x<<"   "<<#y<<" = "<<y<<"\n"
#define all(v)      v.begin(),v.end()
#define mset(a,v)   memset((a),(v),sizeof(a))
#define forn(i,a,b) for(int64_t i=int64_t(a);i<int64_t(b);++i)
#define forb(i,a,b) for(int64_t i=int64_t(a);i>=int64_t(b);--i)
#define fastio()    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> 

#define mod         1000000007
#define mod2        998244353 
#define inf         1000000000000007
#define pi          3.14159265358979323846

template<typename T,typename U> static inline void amin(T &x,U y)                   {if(y<x)x=y;}
template<typename T,typename U> static inline void amax(T &x,U y)                   {if(x<y)x=y;}  
template<class L,class R> ostream& operator<<(ostream& out,pair<L,R> &p)            {return out<<"("<<p.ff<<", "<<p.ss<<")";}
template<class T> ostream& operator<<(ostream& out,vector<T> &v)                    {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,deque<T> &v)                     {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,set<T> &s)                       {out<<"{";for(auto it=s.begin();it!=s.end();++it){if(it!=s.begin())out<<", ";out<<*it;}return out<<"}";}
template<class L,class R> ostream& operator<<(ostream& out,map<L,R> &m)             {out<<"{";for(auto it=m.begin();it!=m.end();++it){if(it!=m.begin())out<<", ";out<<*it;}return out<<"}";}

ll count_digits(ll n)   {ll dig=floor(log10(n)+1);return dig;}
ll mpow(ll x,ll y,ll p) {ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;} 
string dec_bin_32(ll n) {string s;for(ll i=31;i>=0;i--){ll k=n>>i;s+=(k&1)?'1':'0';}return s;} 
string dec_bin_64(ll n) {string s;for(ll i=63;i>=0;i--){ll k=n>>i;s+=(k&1)?'1':'0';}return s;} 
ll mod_inv(ll a,ll m)   {ll m0=m,y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;} 
/* const ll MAXN=10000007;ll spf[MAXN+5];vector<ll> prime; */
/* void sieve(ll n)        {forn(i,2,MAXN+1)spf[i]=i;for(ll i=2;i*i<=n;i++)if(spf[i]==i)for(ll j=i*i;j<=n;j+=i)if(spf[j]==j)spf[j]=i;forn(i,2,MAXN+1)if(spf[i]==i)prime.push_back(i);} */

//-------------------------------L_I_Erq34-------------------------------

int main()
{
	fastio();
	ll z,n,m,t,k,i,j,l,d,h,r;
	cin>>n>>d;
	ll ans=0;
	forn(i,0,n)
	{
		cin>>l>>r;
		if(l*l+r*r<=d*d)
			ans++;
	}
	cout<<ans<<"\n";
	cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
	return 0;
}


Measured memory_bytes: 3676
#include <stdio.h>

int x[50][50] = { 0 };
int ab[50][2] = { 0 };
int cnt[50] = { 0 };

void check(int n,int N) {
	cnt[n] = 1;

	for (int i = 0; i < N; i++) {
		if ((x[n][i] == 1) && (cnt[i] == 0)&&(i!=n)) {
			check(i, N);
		}
	}
}

int main(void) {
	int N, M;
	int ans = 0;

	scanf("%d %d", &N, &M);
	for (int i = 0; i < M; i++) {
		scanf("%d %d", &ab[i][0], &ab[i][1]);
	}
	
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) x[j][k] = 0;
		}

		for (int j = 0; j < M; j++) {
			int a = ab[j][0] - 1;
			int b = ab[j][1] - 1;
			if (j != i) {
				x[a][b] = 1;
				x[b][a] = 1;
			}
		}

		for (int j = 0; j < N; j++) {
			for (int k = 0; k < N; k++) cnt[k] = 0;
			check(j, N);
			int cn = 0;
			for (int k = 0; k < N; k++) {
				if (cnt[k] == 1) cn++;
			}
			if (cn < N) {
				ans++;
				break;
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define len(x) ((int)(x).size())
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;

  if (N < 3) {
    cout << 0 << endl;
    return 0;
  }

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

  int ans = 0;

  // for (size_t i = 0; i < N; i++) {
  //   for (size_t j = i + 1; j < N; j++) {
  //     for (size_t k = j + 1; k < N; k++) {
  //       int a = l[i], b = l[j], c = l[k];
  //       if(a!=b && b != c && c != a) {
  //         if(abs(a-b) < c && c < a + b) {
  //           ans++;
  //         }
  //       }
  //     }
  //   }
  // }

  for (size_t i = 0; i < N; i++) {
    for (size_t j = i + 1; j < N; j++) {
      for (size_t k = j + 1; k < N; k++) {
        int a = l[i];
        int b = l[j];
        int c = l[k];
        if (a == b || a == c || b == c) continue;
        if(abs(a-b) < c && c < a + b) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int t = sc.nextInt();
		int times = t / a;
		
		
			System.out.println(b * times);
	}
}

Measured memory_bytes: 22996