akhauriyash/Code-Regression huggingface dataset:
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n, m;
	cin >> n >> m;
	ll a = -LINF, b = LINF;
	rep(i, m){
		ll l, r;
		cin >> l >> r;
		chmax(a, l);
		chmin(b, r);
	}
	ll ans = max(b-a+1, 0LL);
	co(ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int x,n;
    cin >> x >> n;
    if(n == 0) {
        cout << x << endl;
        return 0;
    }
    vector<int> p(102);
    rep(i,n){
        int a;
        cin >> a;
        p[a] = 1;
    }
    int min_abs = 1000;
    int ans =-1;
    rep(i,int(p.size())){
        if(p[i] == 0){
            int now = abs(x-i);
            if(min_abs>now && now < abs(x+1)) {
                min_abs = abs(x-i);
                ans =i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
n = int(input())
h = list(map(int,input().split()))

a,b = 0, abs(h[0]-h[1])

for i in range(len(h)):
    if i > 1:
        a,b = b, min(abs(h[i-2]-h[i])+a, abs(h[i-1]-h[i])+b)
    
print(b)

Measured memory_bytes: 13980
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int n, a, b;
	
	scanf("%d %d %d", &n, &a, &b);
	if (n == 2)
		printf("Borys\n");
	else if (abs(a - b) % 2 == 0)
		printf("Alice\n");
	else
		printf("Borys\n");
	
	return 0;
}

Measured memory_bytes: 128
n, m = map(int, input().split())
s = [[] for i in range(n)]
for i in range(m):
    p, S = input().split()
    s[int(p) - 1] += [S]
print(sum('AC' in si for si in s), end=' ')
print(sum(si[:si.index('AC')].count('WA') if 'AC' in si else 0 for si in s))

Measured memory_bytes: 25620
#include <algorithm>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <fstream>
#include <math.h>

using namespace std;

int main(void)
{
	int a, b, t;
	cin >> a >> b >> t;
	int c = t/a;
	cout << b * c << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
const int loose = 0;
const int tight = 1;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


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

	ll h, n;
	cin >> h >> n;
	Array a(n, 0);
	REP(i, n) cin >> a[i];


	REP(i, n) {
		h -= a[i];
	}

	if (h <= 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main() {
	long long int n, a[200005] = {}, result = 0;
	scanf("%lld", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}
	for (int i = 0; i < n-1; i++) {
		if (a[i] % 2 == 1&&a[i+1]>0) { a[i]--; a[i + 1]--; result++; }
		result += a[i] / 2;
	}
	result += a[n-1] / 2;
	printf("%lld", result);
}

Measured memory_bytes: 1664
def f(x):
    if x==2:
        return 1
    if x<2 or x%2==0:
        return 0
    i=3
    while i<=x**(1/2):
        if x%i==0:
            return 0
        i+=2
    return 1

while True:
    n=int(input())
    if n==0:
        break
    else:
        s=0
        for i in range(2,n//2+1):
            m=n-i
            if f(m)==1 and f(i)==1:
                s+=1
        print(s)


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

using namespace std;

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

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

   int a;
   cin >> a;
   if(a <= 999){
      cout << "ABC" << endl;
   }
   else{
      cout << "ABD" << endl;
   }

   return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int[] input = sc.intarr;
            int n = input[0];
            int a = input[1];
            int b = input[2];

            int ans = 0;

            for(int i=0; i<=n; i++)
            {
                int k0 = i / 10000;
                int k1 = (i - (10000 * k0)) / 1000;
                int k2 = (i - (10000 * k0) - (1000 * k1)) / 100;
                int k3 = (i - (10000 * k0) - (1000 * k1) - (100 * k2)) / 10;
                int k4 = i % 10;

                int keta_sum = k0 + k1 + k2 + k3 + k4;

                if(keta_sum >= a && keta_sum <= b)
                {
                    ans += i;
                }
            }

            wr.wri(ans);
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

bool query(int x){
	cout << x << endl;
	string s;
	cin >> s;
	if(s[0] == 'V'){
		exit(0);
	}
	return s[0] == 'F';
}

int main(){
	int N;
	cin >> N;
	bool I = query(0), J = query(N-1);
	int i = 0, j = N-1;
	while(true){
		int m = (i+j)/2;
		bool M = query(m);
		if( ((m-i)%2==0) ^ (M == I) ) j = m, J = M;
		else i = m, I = M; 
	}
}


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

using namespace std;

main(){
	char w[100];
	cin>>w;
	int a=0;
	while(true){
		char t[1000];
		cin>>t;
		if (strcmp(t , "END_OF_TEXT" )==0){
			break;
		}
		if(strcasecmp(w,t) ==0){
			a=a+1;
		}
	}
	printf("%d\n",a);
}


Measured memory_bytes: 3256
#include "bits/stdc++.h"
using namespace std;
int a[111];

int main(int argc, char const *argv[])
{
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++) {
		for(int j = i + 1; j < s.size(); j++) {
			string t = "";
			for(int x = 0; x <= i; x++) t += s[x];
			for(int x = j; x < s.size(); x++) t += s[x];
			if(t == "keyence") {
				cout << "YES" << endl;
				exit(0);
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a_lst, b_lst = [], []
    for i in range(n):
        a, b = map(int, input().split())
        a_lst.append(a)
        b_lst.append(b)

    a_lst.reverse()
    b_lst.reverse()

    p = 0
    for i in range(n):
        if (a_lst[i]+p) % b_lst[i]:
            p += (a_lst[i]+p+b_lst[i]-1) // b_lst[i] * b_lst[i] - (a_lst[i]+p)

    print(p)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11052
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e9

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll x[100001], d[100001], n, t, q, cnt;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x[i];
		t+=x[i];
	}
	if(t%(n*(n+1)/2)!=0){
		cout << "NO";
	}
	else{
		q=t/(n*(n+1)/2);
		cnt=q;
		for(int i = 0; i < n; i++){
			d[i] = x[(i+1)%n]-x[i];
		}
		bool pos = 1;
		for(int i = 0; i < n; i++){
			if((q-d[i])%n!=0 || q-d[i]<0){
				pos=0;
			}
		}
		if(pos){
			cout<<"YES";
		}
		else{
			cout<<"NO";
		}
	}
	
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import static java.lang.System.out;
import static java.lang.Math.*;

class Main{
    class P implements Comparable<P>{
        int fr,sc;
        public P(int fr,int sc){
            super();
            this.fr = fr;
            this.sc = sc;
        }
        public int compareTo(P p){
            return sc - p.sc;
        }
    }
    void run(){
        Scanner scan = new Scanner(System.in);
        int n;
        while((n = scan.nextInt()) != 0){
            P p[] = new P[n];
            for(int i=0;i<n;i++){
                int a = scan.nextInt();
                int b = scan.nextInt();
                p[i] = new P(a,b);
            }
            Arrays.sort(p);
            boolean ok = true;
            for(int i=0,sum=0;i<n;i++){
                sum += p[i].fr;
                if(p[i].sc < sum) ok = false;
            }
            out.println( ( ok ? "Yes" : "No" ) );
        }
    }
    public static void main(String args[]){
        new Main().run();
    }
}

Measured memory_bytes: 24292
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
#define MOD 1000000007
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

  string S,T; cin>>S>>T;
  T.pop_back();
  if(S==T)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 3656
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

N = int(input())

ans = 0
ba = 0
a = 0
b = 0
for _ in range(N):
    s = input()
    ans += s.count("AB")
    if s[0] == 'B' and s[-1] == 'A':
        ba += 1
    elif s[0] == 'B':
        b += 1
    elif s[-1] == 'A':
        a += 1


if ba > 0:
    ans += ba - 1
    if b > 0:
        b -= 1
        ans += 1
    if a > 0:
        a -= 1
        ans += 1

ans += min(a, b)
print(ans)


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

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 0; i < N-2; i++){
        if(S.substr(i, 3) == "ABC"){
            ans++;

        }
    }
    cout << ans << endl;
    

}

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

int main()
{
	long long n;
	cin>>n;
	int ans = 0;
	int tmp=0;
	vector<int> a;
	
	for(long long i=2;i<=n;i++){
		if(n<i*i){
			ans++;
			break;
		}
		if(n%i==0){
            int cnt = 0;
			while(n%i==0){
				cnt++;
				n/=i;	 	
			}
          a.push_back(cnt);
          tmp++;
		}
	}
	for(int i=0;i<tmp;i++){
		int k = 0;
		for(int j=1;j*(j+1)/2<=a[i];j++){
			k = j;	
		}
		ans += k;
	}
	cout<<ans<<endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<pair<string, int> > song;
    rep (i, n) {
        string s;
        int t;
        cin >> s >> t;
        song.emplace_back(s, t);
    }
    string x;
    cin >> x;
    int res = 0;
    bool start = false;
    rep (i, n) {
        if (start) res += song[i].second;
        if (x == song[i].first) start = true;
    }
    cout << res << endl;
    
    return 0;
}



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

#define roop(p,q) for(p=1;p<=q;q++)

int main(){

 long long int N;
  scanf("%lld",&N);

/*
  char A[];
  scanf("%s",A);
  */

  
  long long int A[N+1];
  long long int i;
  for(i=1;i<=N;i++){
   scanf("%lld",&A[i]);
   }
  long long int wa,ans;
  long long int j;

 //  roop(j,N){
  wa = 0;
   for(j=1;j<=N;j++){
     wa += (A[j]-A[1])*(A[j]-A[1]);
   }
     ans = wa;

  for(i=1;i<=100;i++){
  wa = 0;
   //roop(j,N){
   for(j=1;j<=N;j++){
     wa += (A[j]-i)*(A[j]-i);
   }
   if (wa <= ans){
     ans = wa;
   }
  }
  printf("%lld",ans);
     








 return(0);
 }


Measured memory_bytes: 128
fun main(args : Array<String>) {
    val left = -1000000
    val right = 1000000
    val (K, X) = readLine()!!.split(" ").map { it.toInt() }


    val l = Math.max(X - (K - 1), left)
    val r = Math.min(X + (K - 1), right)

    (l..r).forEach {
        print(it)
        print(' ')
    }
}

Measured memory_bytes: 37944
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//  Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);
    int a = cin.nextInt();
    int b = cin.nextInt();
    int min = b*10;
    int max = (b+1)*10;
    for (int i=min;i<max;i++) {
      // System.out.println((int)i*0.08);
      if (Math.floor(i*0.08)==a){
        System.out.println(i);
        return;
      }
    }
    System.out.println(-1);
  }

}

Measured memory_bytes: 23892
import java.util.*;
import static java.lang.System.*;
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        long a=sc.nextLong();
        long b=sc.nextLong();
        if(a*b<=0)out.println("Zero");
        else if(b<0&&(b-a+1)%2==0)out.println("Positive");
        else if(b<0&&(b-a+1)%2==1)out.println("Negative");
        else out.println("Positive");
    }
}

Measured memory_bytes: 22868
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define mp make_pair
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const long long MXN = 1e5 + 1;
const long long MNN = 1e3 + 1;
const long long MOD = 998244353;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, m, Q, ans[MXN], u[MXN], col[MXN], d[MXN], D[MXN];
vector<int> q[MXN];

void dfs(llong x, llong C, llong d){
	if(ans[x] == 0) ans[x] = C;
	D[x] = d;
	if(d == 0) return ;
	for(int i = 0; i < q[x].size(); i++){
		int to = q[x][i];
		if(ans[to] == 0) dfs(to, C, d - 1);
		if(D[to] < d - 1){
			dfs(to, C, d - 1);
		}
	}
}

int main(){
	ios;
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		int l, r;
		cin >> l >> r;
		q[l].pb(r);
		q[r].pb(l);
	}cin >> Q;
	for(int i = 1; i <= Q; i++){
		cin >> u[i] >> d[i] >> col[i];
	}
	for(llong i = Q; i >= 1; i--){
		if(ans[u[i]] == 0 || D[u[i]] < d[i]){
			dfs(u[i], col[i], d[i]);
		}
	}
	for(int i = 1; i <= n; i++){
		cout << ans[i] << nl;
	}
	return 0;
}
/*
 5 0
 5
 3
 3
 6
 1
 3
 4
 0
 3
 
 5
 5
 3
 3
 6
 1
 3
 4
 5
 3
 
 
 */


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

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;

int main(){

  ll N;
  ll ans = 0;
  cin >> N;

  vector<ll> A(N);

  for (ll i = 0; i < N;++i)
    cin >> A[i];

  for (ll i = 1; i < N;++i){

    if(A[i-1] > A[i]){
      ans += A[i - 1] - A[i];
      A[i] += A[i - 1] - A[i];
    }
  }

  cout << ans << endl;

  return 0;

}   


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	for(int i=0;3000;i++){
		int u=in(),v=in();
		if(!u && !v) break;
		out(min(u,v),max(u,v));
	}
	
	return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define EPS 1e-15

int s(int n){
	int s = 0;
	while(n){
		s += n % 10;
		n /= 10;
	}
	
	return s;
}

int main() {
	int n;
	cin >> n;
	int a, b;
	cin >> a >> b;
	int r = 0;
	for(int i = 1; i <= n; i++){
		int sum = s(i);
		if(sum >= a && sum <= b){
			r += i;
		}
	}
	cout << r << endl;
	return 0;
}






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

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

int main(void) {
    string s_a, s_b, s_c;
    char card, flg = 'Z';
    int length = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s_a;
    cin >> s_b;
    cin >> s_c;

    card = s_a[0];
    s_a.erase(0, 1);
    length = s_a.length() + s_b.length() + s_c.length();
    REP(i, length) {
        switch(card) {
            case 'a':
                if (s_a.length() > 0) {
                    card = s_a[0];
                    s_a.erase(0, 1);
                } else {
                    flg = 'A';
                }
                break;
            case 'b':
                if (s_b.length() > 0) {
                    card = s_b[0];
                    s_b.erase(0, 1);
                } else {
                    flg = 'B';
                }
                break;
            case 'c':
                if (s_c.length() > 0) {
                    card = s_c[0];
                    s_c.erase(0, 1);
                } else {
                    flg = 'C';
                }
                break;
        }
        if (flg != 'Z') {
            cout << flg << "\n";
            break;
        }
    }

    return 0;
}

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

int Check(string s){
	string s1 = s;
	reverse(s.begin(),s.end());
	if(s == s1){
		return 1;
	}
	return 0;
}

int main(){
	string S;
	cin >> S;
	
	string S1, S2;
	int l = S.length();
	S1 = S.substr(0,(l-1)/2);
	S2 = S.substr((l+3)/2-1);
	//cout << S1 << endl;
	//cout << S2 << endl;
	if(Check(S)&&Check(S1)&&Check(S2)){
		cout << "Yes"<< endl;
	}
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np


def read():
    return sys.stdin.readline().rstrip()


def main():
    h, w = map(int, read().split())
    s = np.array([[i == "." for i in read()] for _ in range(h)], dtype=int)
    left = np.zeros((h, w), dtype=int)
    right = np.zeros((h, w), dtype=int)
    up = np.zeros((h, w), dtype=int)
    down = np.zeros((h, w), dtype=int)
    left[:, 0] = s[:, 0]
    right[:, -1] = s[:, -1]
    for i in range(w - 1):
        left[:, i + 1] = (left[:, i] + 1) * s[:, i + 1]
        right[:, -i - 2] = (right[:, -i - 1] + 1) * s[:, -i - 2]
    up[0] = s[0]
    down[-1] = s[-1]
    for i in range(h - 1):
        up[i + 1] = (up[i] + 1) * s[i + 1]
        down[-i - 2] = (down[-i - 1] + 1) * s[-i - 2]
    print((left + right + up + down).max() - 3)


if __name__ == '__main__':
    main()


Measured memory_bytes: 222892
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split(" "),t=Number(r[0]),n=Number(r[1]),o=[],u=n-t+1;u<=n+t-1;u++)o.push(u);console.log(...o)}},function(e,r){e.exports=require("fs")}]);

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

using namespace std;

int main()
{
	int n, w, d;
	while (cin >> n >> w >> d, w)
	{
		vector<pair<int, int> >data;
		data.push_back(pair < int, int > {w, d});
		int a, b;
		for (size_t i = 0; i < n; i++)
		{
			cin >> a >> b;
			a--;
			b %= (data[a].first + data[a].second);
			if (b>data[a].first)
			{
				b -= data[a].first;
				if (b < data[a].second - b)
				{
					data.push_back(pair < int, int > {data[a].first, b});
					data.push_back(pair < int, int > {data[a].first, data[a].second - b});
				} else
				{
					data.push_back(pair < int, int > {data[a].first, data[a].second - b});
					data.push_back(pair < int, int > {data[a].first, b});
				}
			} else
			{
				if (b < data[a].first-b)
				{
					data.push_back(pair < int, int > {b, data[a].second});
					data.push_back(pair < int, int > {data[a].first - b, data[a].second});
				} else
				{
					data.push_back(pair < int, int > {data[a].first - b, data[a].second});
					data.push_back(pair < int, int > {b, data[a].second});
				}
			}
			data.erase(data.begin() + a);
		}
		sort(data.begin(), data.end(), [](const pair<int, int>a, const pair<int, int>b)->bool {return a.first*a.second < b.first*b.second; });
		auto ite = data.begin();
		for (; ite != data.end() - 1; ite++)
		{
			cout << ((*ite).first)*((*ite).second) << " ";
		}
		cout << ((*ite).first)*((*ite).second) << endl;
	}
}

Measured memory_bytes: 1196
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let mut a: Vec<usize> = vec(n + 1, |_| scan(tokens));
    let mut ans: usize = 0;
    for i in 0..n {
        let mut bi: usize = scan(tokens);
        let tmp = std::cmp::min(a[i], bi);
        ans += tmp;
        a[i] -= tmp;
        bi -= tmp;
        if bi >= a[i + 1] {
            ans += a[i + 1];
            a[i + 1] = 0;
        } else {
            ans += bi;
            a[i + 1] -= bi;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 10232
H, W = gets.split.map(&:to_i)
M = H.times.map{gets.chomp}
G = Array.new(H * W) { [] }
W.times.each_cons(2) do |x1,x2|
  H.times do |y|
    if M[y][x1] == '.' && M[y][x2] == '.'
      G[y * W + x1] << y * W + x2
      G[y * W + x2] << y * W + x1
    end
  end
end
H.times.each_cons(2) do |y1,y2|
  W.times do |x|
    if M[y1][x] == '.' && M[y2][x] == '.'
      G[y1 * W + x] << y2 * W + x
      G[y2 * W + x] << y1 * W + x
    end
  end
end

def bfs(s)
  used = Array.new(H * W)
  q = [s]
  used[s] = 0
  until q.empty?
    u = q.shift
    G[u].each do |v|
      if !used[v]
        used[v] = used[u] + 1
        q << v
      end
    end
  end
  used.compact.max
end

puts (H * W).times.map{|s| bfs(s)}.max


Measured memory_bytes: 3836
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <list>
#include <bitset>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
//sum, 累積和
// 負のときの割り算に注意
#if 1
#include <array>
#include <unordered_set>
#include <unordered_map>
template<class T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

//#include "Union_Find.h"

LL S, C;
int main() {
	cin >> S >> C;
	cout << min((S * 2 + C) / 4, C / 2) << endl;
	return 0;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())

for i in range(K):
    if i%2==0:
        if A%2==1:
            A -= 1
        tmp = A//2
        A //= 2
        B += tmp
    else:
        if B%2==1:
            B -= 1
        tmp = B//2
        B //= 2
        A += tmp

print(A, B)

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

long A[500010];
long N;

int main() {
    cin >> N;
    for (long i = 0; i < N; ++i) cin >> A[i];
    for (long i = 0; i < N; ++i) A[i] -= i + 1;
    sort(A, A + N);
    long median = A[N / 2];
    long sum = 0;
    for (long i = 0; i < N; ++i){
        sum += abs(A[i] - median);
    }
    cout << sum << endl;
}

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

int cal(string &s,int &i){
  int res=0;
  while(1){
    if(isdigit(s[i]))res=s[i++]-'0';
    else if(s[i]=='('){res=cal(s,++i),i++;}
    else if(s[i]=='+')res+=cal(s,++i);
    else if(s[i]=='-')res-=cal(s,++i);
    else break;
  }
  return res;
}

int calc(string s){
  vector<int> v;
  for(int i=0;i<s.size();i++){
    int n = (int)v.size()-1;
    if(s[i]=='+')v.push_back(0);
    if(s[i]=='-')v.push_back(1);
    if(s[i]=='(')v.push_back(0),v.push_back(0);
    if(s[i]==')'){
      if(v.size()<3)continue;
      v[n-2]+=v[n-1]? -v[n]:v[n];
      v.pop_back(),v.pop_back();
    }

    if(isdigit(s[i])){
      int num=s[i]-'0';
      if(v.size()>=2){
	v[n-1]+=v[n]? -num:num;
	v.pop_back();
      }
      else v.push_back(num);
    }
  }
  return v[0];
}

map<string,int> mem[2];
int dfs(string s,int f){
  if(s.size()==1) return s[0]-'0';
  if(mem[f].count(s))return mem[f][s];

  int j=0;  
  int n=s.size(),res=cal(s,j),d=-1;
  for(int i=0;i<n;i++) d+=(s[i]=='+'||s[i]=='-');
  
  for(int i=0,c=0,cnt=0;i<n;i++,cnt++,d--){
    while(i<n){
      while(s[i]=='('||s[i]==')')c+=(s[i]=='(')-(s[i]==')'),i++;
      if(s[i]=='+'||s[i]=='-') break;
      i++;
    }
    if(i>=n||(cnt&&s[i-2]=='(')||(d&&s[i+2]==')'))continue;
    string a=s.substr(0,i),b=s.substr(i+1,n-i-1);
    int t=c,ch=s[i];
    while(t--)a+=')',b='('+b;
    int mxa=dfs(a,0),mna=dfs(a,1);
    int mxb=dfs(b,0),mnb=dfs(b,1);
    if(f==0&&ch=='+') res=max(res, mxa+mxb);
    if(f==0&&ch=='-') res=max(res, mxa-mnb);
    if(f==1&&ch=='+') res=min(res, mna+mnb);
    if(f==1&&ch=='-') res=min(res, mna-mxb);
  }
  return mem[f][s]=res;
}

int main(){
  string S;
  cin>>S;
  cout <<dfs(S,0)<<endl;
  return 0;
}

Measured memory_bytes: 4832
def solve(n, m, s):
    f = s[0]
    MOD = 10 ** 9 + 7
    INF = 10 ** 6

    p = None
    seq = 0
    min_seq = INF
    for c in s:
        if c == p:
            seq += 1
        else:
            if p == f and (min_seq == INF or seq % 2 == 1):
                min_seq = min(min_seq, seq)
            seq = 1
            p = c

    if min_seq == INF:
        a, b = 1, 0
        for _ in range(n - 2):
            a, b = (a + b) % MOD, a
        return (3 * a + b) % MOD

    if n % 2 == 1:
        return 0

    n2 = n // 2
    ms = min(n2, min_seq // 2 + 1)

    dp = [0] * (n2 + 1)
    dp[0] = 1
    acc, reject = 1, 0
    for i in range(1, n2 + 1):
        dp[i] = (acc - reject) % MOD
        acc = (acc + dp[i]) % MOD
        if i >= ms:
            reject = (reject + dp[i - ms]) % MOD

    ans = 0
    for d in range(1, ms + 1):
        ans = (ans + dp[n2 - d] * d * 2) % MOD

    return ans


n, m = map(int, input().split())
s = input()

print(solve(n, m, s))


Measured memory_bytes: 7256
//
//  main.cpp
//  AutoAnswerSheets
//
//  Created by Niko@LOS on 2017/03/07.
//
//

#include <iostream>

using namespace std;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int main() {
    // insert code here...
    int a,b;
    cin>>a>>b;
    cout<<gcd(a,b)<<endl;
    return 0;
}

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

#define int         long long
#define mp          make_pair
#define pb          push_back
#define vi          vector<int>
#define vii         vector<pair<int,int>>
#define mi          map<int,int>
#define mii         map<pair<int,int>,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define hellhsh     444440583533
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i];
#define si(x)       cin>>x;
#define sii(x,y)    cin>>x>>y;
#define ahell   998244353
#define p(x)   printf("%I64d",x)
#define aut(x,u) for(auto x:u)
#define pri     queue<pii>
#define forn(k) for(int i=0;i<k;i++)
#define N 200007
#define fl 1.0000000000
#define ms(a,n) memset(a,n,sizeof(a))
#define INF 10000000000007
using namespace std;
int x,y,m,k;
int n;
vii list[1006];
void solve()
{
int q=0,i,j;
int x,y=0,ct=0;
cin>>n>>x>>y;
mi m1;
for(i=1;i<=n;i++)
{
  for(j=i+1;j<=n;j++)
  {
    if(i<=x)
    {
      if(j<=x)
      {
        m1[j-i]++;
      }
      else if(j<=y)
      {
        m1[min(j-i,x-i+1+y-j)]++;
      }
      else m1[j-y+1+x-i]++;
    }
    else if(i>=x&&i<=y)
    {
      if(j>=x&&j<=y)
        m1[min(j-i,y-j+1+i-x)]++;
      else m1[min(j-i,i-x+1+j-y)]++;
    }
    else m1[j-i]++;
  }
}
for(i=1;i<n;i++)
cout<<m1[i]<<"\n";


}
main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int i,j,k,test=1;

  //cin>>test;
  while(test--)
  {
      solve();
      //cout<<"\n";
 }

}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

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

    li n;
    cin >> n;
    vector<li> xs(n + 1);
    for (int i = 0; i < n + 1; ++i) {
        cin >> xs[i];
    }

//    n = 100000;
//    xs = vector<li>(n + 1, 0);
//    xs[n] = 1e8;

    vector<li> ubs(n + 1);
    ubs[0] = 1 - xs[0];
    for (int i = 1; i <= n; ++i) {
         ubs[i] = min(ubs[i - 1] * 2 - xs[i], (li) 1e17);
    }

    li leaves = 0, nonleaves = 0, ans = 0;
    for (li i = n; i >= 0; --i) {
        nonleaves += leaves;
        leaves = xs[i];
        if (ubs[i] < (nonleaves + 1) / 2) {
            cout << -1 << endl;
            return 0;
        } else {
            nonleaves = min(ubs[i], nonleaves);
        }
        ans += leaves + nonleaves;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4784
package main

import "fmt"

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var n, T int
	fmt.Scan(&n, &T)

	var ans, pre int
	for i := range make([]struct{}, n) {
		var ti int
		fmt.Scan(&ti)
		ans += T
		if i != 0 {
			diff := ti - pre
			ans -= max(0, T-diff)
		}
		pre = ti
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
import fractions
from functools import reduce

def gcd(l):
    return reduce(fractions.gcd, l)
    
n, k = map(int, input().split())
a = list(map(int, input().split()))

x = gcd(a)
if k%x == 0 and k <= max(a):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 88172
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>

#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#include <utility>
#include <list>

#include <cmath>
#include <algorithm>
#include <cassert>
#include <bitset>
#include <complex>
#include <climits>
#include <functional>
#include <unordered_set>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back

#define debug(x) cerr << #x << " = " << x << " "
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> cnt(4, 0);
    int n; cin >> n;
    string s;
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> s;
        for (int i = 1; i < s.size(); ++i)
            ans += s[i-1] == 'A' && s[i] == 'B';
        int bit = ((s.front() == 'B') << 0) | ((s.back() == 'A')<<1);
        ++cnt[bit];
    }
    if (cnt[3])
    {
        ans += cnt[3]-1;
        for (int i = 1; i <= 2; ++i) if (cnt[i]) --cnt[i], ++ans;
    }
    ans += min(cnt[1], cnt[2]);
    cout << ans << endl;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
h = Hash.new(0)
m.times do
  u, v = gets.split.map(&:to_i)
  h[v] += u
end
i = 0
h.sort_by{|k, v| -k}.each do |x, y|
  break if a[i] >= x
  y.times do
    a[i] = x
    i += 1
    break if i >= n
    break if a[i] >= x
  end
  break if i >= n
end
puts a.inject(:+)

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

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define pb push_back
#define endl "\n"
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007

const int mxn = 123;
ll w[mxn],val[mxn];
ll dp[mxn][100001];
ll n,W;

ll solve(){

	for(ll i=1;i<=n;i++){
		for(ll j=0;j<=W;j++){
			if(j>=w[i-1])
				dp[i][j] = max(dp[i-1][j], val[i-1] + dp[i-1][j-w[i-1]]);
			else 
				dp[i][j] = dp[i-1][j];
		}
	}

	return dp[n][W];
}

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

	fo(i,n) cin >> w[i] >> val[i];

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 79360
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (a, v) = input!(i64, u64);
    let (b, w) = input!(i64, u64);
    let (t,) = input!(u64);

    if (v < w && a != b) || (v - w) * t < (a - b).abs() as u64 {
        println!("NO");
    } else {
        println!("YES");
    }
}

fn main() {
    solve();
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 998244353;

int main() {
    Int n;
    cin >> n;
    vector<string> s(n);
    for (Int i = 0; i < n; i++) cin >> s[i];
    map<string, Int> mp;
    for (Int i = 0; i < n; i++) {
        vector<char> x;
        for (Int j = 0; j < (Int)s[i].size(); j++) {
            x.push_back(s[i][j]);
        }
        sort(x.begin(), x.end());
        string t = "";
        for (Int j = 0; j < (Int)s[i].size(); j++) t = t + x[j];
        //dump(t);
        mp[t]++;
    }
    Int res = 0;
    for (auto i : mp) {
        for (Int j = 1; j < i.se; j++) {
            res += j;
        }
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 18176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a==b && a==c) {
			System.out.println("1");
		}
		else if(a==b && a!=c) {
			System.out.println("2");
		}
		else if(b==c && b!=a) {
			System.out.println("2");
		}
		else if(a==c && a!=b) {
			System.out.println("2");
		}
		else {
			System.out.println("3");
		}
	}
}

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

int main()
{
	int H, W;


	while (1)
	{
		cin >> H >> W;
		
		if (H == 0 && W == 0)
		{
			break;
		}

		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (j > 0 && j < W-1 && i > 0 && i < H-1)
				{
					cout << ".";
				}
				else
				{
					cout << "#";
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

class Main {
	public static void main(String a[]){
		double INTEREST = 0.05;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int debt = 100000;
		for(int i = 0; i<n;i++){
			debt *= (1+INTEREST);
			debt = normalization(debt);
		}
		System.out.println(debt);
		sc.close();
	}

	static int normalization(int num){
		if(num % 1000 != 0)
			num = num - num%1000 + 1000;
		return num;
	}

}



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

int main() {
	long long int A, B, C;
	long long int K;

	cin >> A >> B >> C >> K;

	int ans = 0;

	if (A < K) {
		ans += A;
		if (B < (K - A)) {
			if (C < (K - A - B)) {
				ans -= C;
			} else {
				ans -= (K - A - B);
			}
			cout << ans << endl;
		} else {
			cout << ans << endl;
		}
	} else {
		ans += K;
		cout << ans << endl;
	}

}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i,n) cin >> l[i];
	sort(l.begin(), l.end());
	ll ans = 0;
	for(int a = 0; a < n; a++){
		for(int b = a+1; b < n; b++){
			for(int c = b+1; c < n; c++){
				if(l[a] + l[b] > l[c]) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

main() {
  string S[3];
  for (int i = 0; i < 3; i++) {
    cin >> S[i];
    reverse(S[i].begin(), S[i].end());
  }

  int turn = 0;
  while (!S[turn].empty()) {
    for (int i = 0; i < 3; i++) {
      if (S[turn].back() == "abc"[i]) {
        S[turn].pop_back();
        turn = i;
        break;
      }
    }
  }
  cout << "ABC"[turn] << endl;
}


Measured memory_bytes: 256
object Main extends App {
  var input = readLine
  val N = input.length()
  val lese = input.take((N-1) / 2)
  val rise = input.takeRight((N-1) / 2)
  
  //println(s"lese = $lese, rise = $rise")
  
  if( lese == lese.reverse && rise == rise.reverse && input == input.reverse) {
    println("Yes")
  }else {
    println("No")
  }
  
}

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

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N,M;cin >> N >> M;
    priority_queue<long long> q;
    long long sum = 0;

    for(long long i=0;i<N;i++){
        long long x;cin >> x;
        q.push(x);
    }

    for (long long _ = 0; _ < M; _++){
        long long top = q.top();
        q.pop();
        top /= 2;
        q.push(top);
    }

    long long q_size = q.size();
    for (long long _ = 0; _ < q_size; _++){
        sum += q.top();
        q.pop();
    }

    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) ((flag)?1:0)
#define YN(flag) cout<<(flag?"YES":"NO")<<endl;
#define Yn(flag) cout<<(flag?"Yes":"No")<<endl;
#define yn(flag) cout<<(flag?"yes":"no")<<endl;
#define Cout(v) cout<<(v)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ===================

// Template End =========================

int main(void){
  int a,b; cin>>a>>b;
  Cout(a+b/2);
}












Measured memory_bytes: 256
import           Control.Monad

solve :: Int -> String
solve = f 0
  where
    f i n
      | i * i < n = f (i + 1) n
      | i * i > n = "No"
      | otherwise = "Yes"

main :: IO ()
main = do
  n <- read . concat . words <$> getLine :: IO Int
  putStrLn $ solve n


Measured memory_bytes: 508
#include <stdio.h>
int main(void){
	int n,x,a;
	int i;
	int p=0;
	long int count=0;
	scanf("%d %d",&n,&x);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		if(p+a>x){
			count += a+p-x;
			p = x-p;
		}
		else p = a;
	}
	printf("%ld\n",count);
	return 0;
}

Measured memory_bytes: 128