akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

template <class T> using Tree = tree <T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(bool a) {
  return a ? "T" : "F";
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = long long;
using ld = long double;

void run() {
  int a, b, c, x, y;
  cin >> a >> b >> c;
  cin >> x >> y;
  int mn = min(x, y);
  int ab = mn;
  int ab_cost = a + b;
  mini(ab_cost, c * 2);
  mini(a, ab_cost);
  mini(b, ab_cost);
  
  debug(ab, ab_cost, a, b);

  cout << ab * ab_cost + (x - ab) * a + (y - ab) * b << endl;
}


int main() {
  run();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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 n;
ll h, a[1010], b[1010];
ll dp[10100];

int main() {
    cin >> h >> n;
    rep(i, n) cin >> a[i] >> b[i];

    rep(i, 10100) dp[i] = LLINF;
    dp[0] = 0;
    for (int sum_a = 0; sum_a < 10100; sum_a++) {
        rep(i, n) {
            if (sum_a + a[i] <= 10100) chmin(dp[sum_a + a[i]], dp[sum_a] + b[i]);
        }
    }

    ll ans = LLINF;
    for (int sum_a = h; sum_a < 10100; sum_a++) chmin(ans, dp[sum_a]);
    cout << ans << endl;
}


Measured memory_bytes: 384
#c
n = int(input())
count=0
dic={}
for i in range(n):
    #文字列を追加するか
    b=list(input())
    b.sort()
    mojiretu = ''.join(b)
    if mojiretu not in dic:
        dic[mojiretu] =1
    else:
        dic[mojiretu] +=1
for v in dic.values():
    count += v*(v-1)//2
print(count)

Measured memory_bytes: 17808
#include <stdio.h>
int selectionSort(int A[], int N) {
    int i, j, t, sw =0, minj;
    for(i=0;i<N-1;i++) {
        minj = i;
        for(j=i;j<N;j++) {
            if(A[j]<A[minj]) minj = j;
        }
        t=A[i]; A[i]=A[minj]; A[minj]=t;
        if(i!=minj) sw++;
    }
    return sw;
}

int main(void) {
    int A[100], N, i, sw;

    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = selectionSort(A,N);

    for(i=0;i<N;i++) {
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",sw);

    return 0;
}



Measured memory_bytes: 2104
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){for(var e=t.inr(),r=e.length+1,n=new Array(r).fill(0),i=[],s=1;s<=r-2;s++)">"==e[s-1]&&"<"==e[s]&&i.push(s);"<"==e[0]&&i.push(0),">"==e[r-2]&&i.push(r-1);for(var o=i.length,u=0;u<o;u++){var c=i[u];n[c]=0;for(var f=c;f>=1&&">"==e[f-1]&&n[f-1]<=n[f];)n[f-1]=n[f]+1,f--;for(var a=c;a<r-1&&"<"==e[a]&&n[a]>=n[a+1];)n[a+1]=n[a]+1,a++}for(var l=0,p=0;p<r;p++)l+=n[p];console.log(l)}}]);

Measured memory_bytes: 15692
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;

int n;

void solve(){
  vl w(n);
  rep(i,n)cin>>w[i];
  vvl dp(n+5,vl(n+5));
  REP(W,2,n+1){
    rep(i,n){
      int j=i+W;
      if(j>n)continue;
      if((dp[i+1][j-1]==j-i-2)&&(abs(w[i]-w[j-1])<=1))dp[i][j]=dp[i+1][j-1]+2;
      for(int k=i+1;k<j;++k)chmax(dp[i][j],dp[i][k]+dp[k][j]);
    }
  }
  out(dp[0][n]);
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  while(1){
    cin>>n;
    if(n==0)return 0;
    solve();
  }
  //solve();
	return 0;
}



Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
    int s1lenth, s2lenth;
    char s1[10], s2[10], s3[10];
    scanf("%s%s%s", s1, s2, s3);

    for (s1lenth = 0; s1[s1lenth] != '\0'; s1lenth++);
    for (s2lenth = 0; s2[s2lenth] != '\0'; s2lenth++);

    if (s1[s1lenth - 1] == s2[0] && s2[s2lenth - 1] == s3[0]) printf("YES");
    else printf ("NO");
}


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

#define DEBUG(C) std::cerr << #C << " = " << C << std::endl;

using namespace std;

/**
* Binary_Indexed_Tree(BIT)
* Fenwick Tree
* 0-indexed!!!
* O(log N)
*/
template<typename T = int>
class binary_indexed_tree {
private:
    const int N;
    std::vector<T> bit;
public:
    binary_indexed_tree() : N(-1) {}
    binary_indexed_tree(int n) : N(n), bit(n, 0) {}
    // bit[point]にnum追加
    void add(int point, T val) {
        point++;

        for (int i = point; i - 1 < N; i += i & (-i)) {
            bit[i - 1] += val;
        }
    }
    // [0, point)
    T sum(int point) {
        T res = 0;
        for (int i = point; i > 0; i -= i & (-i)) {
            res += bit[i - 1];
        }

        return res;
    }
    // [left, right)
    T sum(int left, int right) {
        return this->sum(right) - this->sum(left);
    }
};

 
 
int main() {
    int N, Q;
    cin >> N >> Q;
    binary_indexed_tree<int> bit(N);
    while (Q--) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            bit.add(x - 1, y);
        } else {
            cout << bit.sum(x - 1, y) << endl;
        }
    }
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int>vi;
#define pb push_back
#define sc(n) scanf("%d",&n)
#define lsc(n) scanf("%lld",&n)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define rev1(i,n) for(i=n;i>0;i--)
#define in insert
#define pr(n) printf("%d\n",n)
#define lpr(n) printf("%lld\n",n);


int main()
{
	int x,t;
	cin >> x >> t;
	cout << max(0,x-t);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int N,A,B,C;
int l[8];
int ans = 100000000;
void dfs(int depth,int a,int b,int c,int cost){
    if(depth == N){
        if(a != 0 && b != 0 && c != 0)
            ans = min(ans,cost + (abs(A-a) + abs(B-b) + abs(C-c) - 30));
    return ;
    }
    dfs(depth+1,a+l[depth],b,c,cost+10);
    dfs(depth+1,a,b+l[depth],c,cost+10);
    dfs(depth+1,a,b,c+l[depth],cost+10);
    dfs(depth+1,a,b,c,cost);
}
int main(){
    cin >> N >> A >> B >> C;
    for(int i = 0; i < N; i++) cin >> l[i];
    dfs(0,0,0,0,0);
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a, b;
		String s1, s2, s3;

		while (true) {
			s1 = sc.next();
			if (s1.equals("0")) {
				break;
			}
			s2 = sc.next();
			s3 = sc.next();
			
			a = 0;
			b = 0;
			for (int i = 1; i < s1.length(); i++) {
				if (s1.charAt(i) == 'A') {
					a++;
				} else {
					b++;
				}
			}
			if (s2.charAt(0) == 'A') {
				a++;
			} else {
				b++;
			}
			System.out.println(a + " " + b);
			
			a = 0;
			b = 0;
			for (int i = 1; i < s2.length(); i++) {
				if (s2.charAt(i) == 'A') {
					a++;
				} else {
					b++;
				}
			}
			if (s3.charAt(0) == 'A') {
				a++;
			} else {
				b++;
			}
			System.out.println(a + " " + b);
			
			a = 0;
			b = 0;
			for (int i = 1; i < s3.length(); i++) {
				if (s3.charAt(i) == 'A') {
					a++;
				} else {
					b++;
				}
			}
			if (b < a) {
				a++;
			} else {
				b++;
			}
			System.out.println(a + " " + b);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
#define ll long long int


int main(){
    string s; cin >> s;
    int n = s.size();
    bool flag = true;
    for(int i=0;i<n;i++){
        if(s[i] != s[n-i-1]){
            flag = false;
            break;
        }
    }
    for(int i=0;i<(n-1)/2;i++){
        if(s[i]!=s[(n-1)/2-i-1]){
            flag = false;
            break;
        }
    }
    for(int i=(n+3)/2-1;i<n;i++){
        if(s[i]!=s[n+(n+3)/2-i-2]){
            flag = false;
            break;
        }
        
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}


const int N = 200005;
int n, cc, BIT[N];
ll k, arr[N];
map<ll, int> compress;


void update(int idx, int val){
	while(idx <= n+1){
		BIT[idx] += val;
		idx += idx & (-idx);
	}
}


int query(int idx){
	int ans = 0;
	while(idx){
		ans += BIT[idx];
		idx -= idx & (-idx);
	}
	return ans;
}

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

    cin>>n>>k;
    compress[0];
    for(int i=1;i<=n;i++){
    	cin>>arr[i];
    	arr[i] -= k;
    	arr[i] += arr[i-1];
    	compress[arr[i]];
    }
 	
 	cc = 0;
 	for(auto &it : compress)
 		it.ss = ++cc;

 	for(int i=0;i<=n;i++)
 		arr[i] = compress[arr[i]];

 	update(arr[0], 1);
 	ll ans = 0;
 	for(int i=1;i<=n;i++){
 		ans += query(arr[i]);
 		update(arr[i], 1);
 	}

 	cout<<ans;
    return 0;
}
 
 
 



Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {
  
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = -1 * LINF;
  ans = max(ans, a * c);
  ans = max(ans, a * d);
  ans = max(ans, b * c);
  ans = max(ans, b * d);
  cout << ans << endl;  

  return 0;
}

Measured memory_bytes: 3632
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)

P = [x for x in A if x >= 0]
M = [x for x in A if x < 0]

if not len(P):
    P.append(A[0])
    M = M[1:]
elif not len(M):
    P.pop()
    M.append(A[-1])

print(sum(P) - sum(M))
# -
x = M[0]
for i in range(1, len(P)):
    print(x, P[i])
    x -= P[i]

# +
y = P[0]
for i in range(1, len(M)):
    print(y, M[i])
    y -= M[i]
print(y, x)


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

int main(){
  int N;
  string ans = "No";
  cin>>N;
  for(int i =0;i<10;i++){
    for(int j =0;j<10;j++){
      if(N==(i*j)){
        ans = "Yes";
        break;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int main(void) {

    int x;
    std::cin >> x;

    //    int res = x*x*x;
    int res2 = std::pow(x, 3);
    //    std::cout << res << std::endl;
    std::cout << res2 << std::endl;
    //    return res;
}

Measured memory_bytes: 3272
import sys,queue,math,copy,itertools,bisect,collections,heapq
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

H,W,D = LI()
A = [_LI() for _ in range(H)]
Q = NI()
LR = [_LI() for _ in range(Q)]

dist =  [[0 for _ in range(math.ceil(H*W/D))] for _ in range(D)]
S  = []
for i in range(H):
    for j in range(W):
        S.append((A[i][j],i,j))
S.sort()

for a,i,j in S[D:]:
    dist[a%D][a//D] = dist[a%D][a//D-1] + abs(S[a-D][1]-i) + abs(S[a-D][2]-j)

for l,r in LR:
    ans = dist[r%D][r//D] - dist[l%D][l//D]
    print(ans)

Measured memory_bytes: 86616
import sys
input = sys.stdin.buffer.readline
import copy
 
def main():
    N,A,B,K = map(int,input().split())
    
    MOD = 998244353
    fac = [0 for _ in range(N+1)]
    fac[0],fac[1] = 1,1
    inv = copy.deepcopy(fac)
    invfac = copy.deepcopy(fac)
    
    for i in range(2,N+1):
        fac[i] = (fac[i-1]*i)%MOD
        inv[i] = MOD-(MOD//i)*inv[MOD%i]%MOD
        invfac[i] = (invfac[i-1]*inv[i])%MOD
 
    def coef(x,y):
        num = (((fac[x]*invfac[y])%MOD)*invfac[x-y]%MOD)
        return num
        
    ans = 0
    for i in range(min(K//max(A,B),N)+1):
        rest = K-i*max(A,B)
        if rest%min(A,B) == 0:
            j = rest//min(A,B)
            if j <= N:
                ans += coef(N,i)*coef(N,j)
                ans %= MOD
            
    print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 39232
#include <iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

#define vi vector<int>
#define vvi vector<vi>
#define rpt(i,x) for (int i = 0; i < x; i++)
#define fti(i,f,t) for (int i = f; i <= t; i++)
#define fte(i,f,t) for (int i = f; i < t; i++)
#define rptws(i,x,s) for (int i = 0; i < x; i += s)
#define llrpt(i,x) for (long long i = 0; i < x; i++)
#define llfti(i,f,t) for (long long i = f; i <= t; i++)
#define llfte(i,f,t) for (long long i = f; i < t; i++)


int main () {
    int n, k;
    cin>>n>>k;
    int arr[n];

    rpt(i, n) {
        cin>>arr[i];
    }

    sort(arr, arr+n);

    int rst = 0;
    rpt(i, k) {
        rst += arr[i];
    }
    cout<<rst;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	long long ans = 1;
	const long long num = 1000000007;
	int i,j;
	const int sosList[11] = {2,3,5,7,11,13,17,19,23,29,31};
	int sos[n+1] = {};
	for(i=2;i<=n;i++){
	int tmp = i;
		for(j=0;j<11;j++){
			while(tmp%sosList[j]==0){
				sos[sosList[j]]++;
				tmp/=sosList[j];
			}
		}
		sos[tmp]++;
	}
	for(i=2;i<=n;i++){
		ans*=sos[i]+1;
		ans=ans%num;
	}
	
	
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n, q;

int main() {
    cin >> n;
    vector<ll> avec(n, 0);
    ll sum = 0;
    map<ll, ll> mcnt;
    for(int i = 0; i < n; ++i) {
        cin >> avec.at(i);
        sum += avec.at(i);
        mcnt[avec.at(i)]++;
    }

    cin >> q;
    for(int i = 0; i < q; ++i) {
        ll b, c; cin >> b >> c;
        ll bcnt = mcnt[b];
        sum -= b*bcnt;
        mcnt[b] = 0;
        mcnt[c] += bcnt;
        sum += c*bcnt;
        cout << sum << endl;
    }
}

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

int main()
{
  int n;
  int64_t tmp = 0;
  cin >> n;
  bool ans = 1;
  vector<int64_t> H(n);
  for (int i = 0; i < n; i++)
    cin >> H[i];
  for (int i = 0; i < n; i++) {
    if (H[i] + 1 < tmp) {
      ans = 0;
      break;
    }
    tmp = max(tmp, H[i]);
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
bool cus(pair<string,int>p1,pair<string,int>p2)
{
	if(p1.second==p2.second)
	{
		return p1.first<p2.first;
	}
	return p1.second<p2.second;
}
int main()
{
	int n;cin>>n;
	string s; 
	map<string,int>mp;
	vector<pair<string,int> >vp;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		mp[s]++;
		
	}
	for(auto x: mp)
	{
		vp.push_back({x.first,x.second});
	}
	sort(vp.rbegin(),vp.rend(),cus);
	int have=vp[0].second;
	vector<string>ans;
	for(auto x : vp)
	{
		if(x.second==have)
		{
			ans.push_back(x.first);
		}
	}
	sort(ans.begin(),ans.end());
	for(auto x : ans){cout<<x<<endl;}
	
	
	
}

Measured memory_bytes: 32876
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e5 + 2;
ll i,n,a;
ll p[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,1,n + 1){
        cin>>a;
        p[a] = i;
    }
    rep(i,1,n + 1) cout<<p[i]<<" ";
    return 0;
}

Measured memory_bytes: 1664
#define MYDEBUG
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <stack>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl 
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

int W,H;
const int MAXW = 30*2+1;
int cnt[MAXW][MAXW];
int ng[MAXW][MAXW];
int di[4] = {-2,0,2,0};
int dj[4] = {0,2,0,-2};
int W2,H2;

void bfs(int si, int sj, int gi, int gj){
	queue<int> qi;
	queue<int> qj;
	qi.push(si);
	qj.push(sj);
	while(!qi.empty()){
		int i = qi.front(), j = qj.front();
		qi.pop(); qj.pop();
		if(i==gi&&j==gj) return;
		for(int k=0; k<4; ++k){
			int ni=i+di[k], nj=j+dj[k];
			if(0<=ni&&ni<H2&&0<=nj&&nj<W2&&//???????????????????????????
			cnt[ni][nj]==0&&//????¨????(=0)????????¢?´¢
			ng[i+di[k]/2][j+dj[k]/2]==0){//???????£?????????????(i??¨i+2?????????i+2/2)
				qi.push(ni);
				qj.push(nj);
				cnt[ni][nj]=cnt[i][j]+1;
			}
		}
	}
}

void solve(){
	//ifstream cin("/storage/emulated/0/AppProjects/AtCoder/jni/in.txt");
	while(true){
		cin >> W >> H;
		if(W==0&&H==0) return;
		W2=2*W-1;
		H2=2*H-1;
		for(int i=0; i<MAXW; ++i){
			for(int j=0; j<MAXW; ++j){
				ng[i][j]=0;
				cnt[i][j]=0;
			}
		}
		for(int i=0; i<H; ++i){
			for(int j=0; j<W-1; j++){//v
				cin >> ng[i*2][j*2+1];
			}
			if(i==H-1) break;
			for(int j=0; j<W; j++){//h
				cin >> ng[i*2+1][j*2];
			}
		}
		bfs(0,0,H2-1, W2-1);
		int ans = cnt[H2-1][W2-1];
		if(ans>0) ans++;
		cout << ans << endl;
	}
}

int main() {
	solve();
}

Measured memory_bytes: 3104
#include <iostream>
#include <map>

using namespace std;

int N;
map<string, bool> x;

int main (){
  cin>>N;
  for (int i = 0; i<N; i++){
   string str;	cin>>str;
   x[str] = 1;
  }
  cout<<x.size()<<endl;
}

Measured memory_bytes: 19232
import sys
from fractions import gcd
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    m = L.pop()
    if m < sum(L): print("Yes")
    else: print("No")

if __name__ == "__main__":
    main()


Measured memory_bytes: 64876
#include<stdio.h>

int main(void){
	int ball[3];
	int x,y,temp;
	char a,b;
	ball[0]=1;ball[1]=0;ball[2]=0;
	while(scanf("%c,%c\n",&a,&b)!=EOF){
		switch(a){
		case 'A':x=0;break;
		case 'B':x=1;break;
		case 'C':x=2;break;
		}
		switch(b){
		case 'A':y=0;break;
		case 'B':y=1;break;
		case 'C':y=2;break;
		}
		temp=ball[x];ball[x]=ball[y];ball[y]=temp;
	}
	if(ball[0]==1){
		printf("A\n");
	}else if(ball[1]==1){
		printf("B\n");
	}else{printf("C\n");}
	return 0;
}

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

int main(){
 ll n; cin >> n;
 ll sum=0;
 vector<ll> a(n);
 rep(i,n) cin >> a[i], sum+=a[i];
 double ave=(double)sum/(double)n;
 ll ave_int=sum/n;
 double ave_flt=ave-(double)ave_int;

 ll med;
 if(ave_flt>=0.5)med=ave_int+1;
 else med=ave_int;

 ll ans=0;
 rep(i,n)ans+=(med-a[i])*(med-a[i]);

 cout << ans << endl;
}


Measured memory_bytes: 256
import fractions as f
n = int(input())
l = [-1]*(n+5)#0-i-1までの最大公約数
r = [-1]*(n+5)#i - n-1の最大公約数
l[0] ,r[n] = 0,0
a = list(map(int,input().split()))
for i in range(n):
    l[i+1] = f.gcd(l[i],a[i])
    i = n-i
    r[i-1] = f.gcd(r[i],a[i-1])
ans = -10**9
for i in range(n):
    
    ans = max(ans,f.gcd(l[i],r[i+1]))

print(ans)
    

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

int main(){
    int N,x,ans;
    cin >> N;
    vector<int> c_sum(N+1);
    for (int i=1;i<=N;i++){
        cin >> x;
        c_sum[i] = c_sum[i-1] + x;
    }
    ans = c_sum[N];
    for (int i=0;i<N;i++){
        if (abs((c_sum[N]-c_sum[i])-c_sum[i])<ans){
            ans = abs((c_sum[N]-c_sum[i])-c_sum[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

int main(){    
  long long H,A,count=0;
  cin >> H >> A;
  while(H>0){
  H = H-A;
  count++;
  }
  cout << count << endl;
  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  private static Scanner sc;

  public static void main(String[] args) {
    sc = new Scanner(System.in);
    new Main().solve();
  }


  private void solve() {
    int N = Integer.parseInt(sc.next());
    int ans = 0;
    for (int i = 0; i < N; i++) {
      ans += Integer.parseInt(sc.next()) - 1;
    }

    System.out.println(ans);
  }
}



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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  string s; cin >> s;
  int ans = 0, cur = 0;
  for (int i = 0; i < N; ++i) {
    if (s[i] == 'I') { ans = max(ans, ++cur); }
    else if (s[i] == 'D') { --cur; }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int n, n1, n2, a[N], b[N], aa[N], bb[N];
char s[N], s2[N];

bool check(int x, int y, int xx, int yy) {
	if((a[y] - a[x - 1] - b[y] + b[x - 1] + 30000000) % 3 == (aa[yy] - aa[xx - 1] - bb[yy] + bb[xx - 1] + 30000000) % 3)
		return true;
	return false;
}

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> s + 1;
	cin >> s2 + 1;
	n1 = strlen(s + 1);
	n2 = strlen(s2 + 1);
	for(int i = 1; i <= n1; i++) {
		a[i] = a[i - 1] + (s[i] == 'A');
		b[i] = b[i - 1] + (s[i] == 'B');
	}
	for(int i = 1; i <= n2; i++) {
		aa[i] = aa[i - 1] + (s2[i] == 'A');
		bb[i] = bb[i - 1] + (s2[i] == 'B');
	}
	cin >> n;
	for(int i = 1; i <= n; i++) {
		int l1, r1, l2, r2;
		cin >> l1 >> r1 >> l2 >> r2;
		if(check(l1, r1, l2, r2))
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long n,m;
	cin>>n>>m;
	if((n+m)%2==0) {
		cout<<(n+m)/2<<endl;
		return 0;
	} else {
		cout<<"IMPOSSIBLE"<<endl; 
		return 0;
	}
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int c1, c2, c3;
  int answer = 0;
  int input;
 
  cin >> input;
  c1 = floor(input/100);
  c2 = floor((input-100*c1)/10);
  c3 = floor((input-100*c1-10*c2));
  
  if(c1==1){
    answer=answer+1;
  }
  if(c2==1){
    answer=answer+1;
  }
  if(c3==1){
    answer=answer+1;
  }

  cout << answer <<endl;
}

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

/* define const */
const long Nmax = 100010;
const long Amax = 1000000000;
/* end up defineing const */

long A[Nmax] = {};
long T;
long N;

int main()
{
  cin >> N >> T;
  for (int i = 0; i < N; i++) cin >> A[i];
  // end up inputting

  long min = Amax+1;
  long gain_max = -1;
  long cnt = 0;
  for (long i = 0; i < N; i++) {
    if (A[i] < min) {
      min = A[i];
      for (long j = 1; i+j < N; j++) {
        if (A[i+j] < min) break;
        else {
          if (gain_max < A[i+j]-min) {
            gain_max = A[i+j]-min;
            cnt = 1;
          }
          else if (gain_max == A[i+j]-min) {
            cnt++;
          }
        }
      }

    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
int n, k;
int a[maxx];

int main() {
	int minT = Inf;
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) {
		int t1 = Inf, t2 = Inf, tmp;
		if(i + k - 1 >= 1 && i + k - 1 <= n) t1 = abs(a[i]) + abs(a[i + k - 1] - a[i]);
		if(i - k + 1 >= 1 && i - k + 1 <= n) t2 = abs(a[i]) + abs(a[i - k + 1] - a[i]);
		tmp = min(t1, t2);
		minT = min(minT, tmp);
	}
	cout << minT << endl;
}


Measured memory_bytes: 640
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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

}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    rep(i, 0, N-2) {
        if (S[i] == 'A') {
            if (S[i+1] == 'B') {
                if (S[i+2] == 'C') {
                    ++ans;
                    i += 2;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct zahyo{
    double x;
    double y;
};
static const double pi = 3.141592653589793;
int kock(int n,zahyo p1,zahyo p2){
    if(n==0) return 0;
    zahyo s,t,u;
    s.x = (2*p1.x+1*p2.x)/3;
    s.y = (2*p1.y+1*p2.y)/3;
  
    t.x = (1*p1.x+2*p2.x)/3;
    t.y = (1*p1.y+2*p2.y)/3;

    u.x = (t.x-s.x)*cos(pi/3)-(t.y-s.y)*sin(pi/3)+s.x;
    u.y = (t.x-s.x)*sin(pi/3)+(t.y-s.y)*cos(pi/3)+s.y;

    kock(n-1,p1,s);
    cout << s.x << " " << s.y << endl;
    kock(n-1,s,u);
    cout << u.x << " " << u.y << endl;
    kock(n-1,u,t);
    cout << t.x << " " << t.y << endl;
    kock(n-1,t,p2);
}
int main(){
    int n;cin >> n;
    zahyo left = {0,0};
    zahyo right = {100,0};
    cout << left.x << " " << left.y << endl;
    kock(n,left,right);
    cout << right.x << " " << right.y << endl;
    return 0;
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
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; }
using namespace std;

int n, m;
vector<int> g[1000];
vector<int> rev_g[1000];

pair<int, int> distance(int v){
    vector<int> dist(n, n);
    dist[v] = 0;
    queue<int> que;
    que.push(v);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(int u : g[v]){
            if(chmin(dist[u], dist[v] + 1)){
                que.push(u);
            }
        }
    }
    int t = -1, res = n + 1;
    for(int u : rev_g[v]){
        if(chmin(res, dist[u] + 1)){
            t = u;
        }
    }
    return { res, t };
}

int main(){

    cin >> n >> m;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        rev_g[b].push_back(a);
    }

    int v = -1, u = -1, mi = n + 1;
    rep(i, n){
        pair<int, int> p = distance(i);
        if(chmin(mi, p.first)){
            v = i;
            u = p.second;
        }
    }

    if(v == -1){
        cout << -1 << endl;
        return 0;
    }

    vector<int> dist(n, n);
    vector<int> prev(n, -1);
    queue<int> que;
    dist[v] = 0;
    que.push(v);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(int u : g[v]){
            if(chmin(dist[u], dist[v] + 1)){
                que.push(u);
                prev[u] = v;
            }
        }
    }
    cout << mi << endl;
    for(; u != -1; u = prev[u])cout << u + 1 << endl;

}

Measured memory_bytes: 384
N = int(input())
A = [int(x) for x in input().split()]
ans = sum(A)
 
rep = dict()
for i in range(N):
    rep[A[i]] = rep.get(A[i], 0) + 1

Q = int(input())
for i in range(Q):
    b, c = map(int, input().split())
    if b in rep:
        ans = ans + rep[b] * (c-b)
        rep[c] = rep.get(c, 0) + rep[b]
        rep[b] = 0
    print(ans)

Measured memory_bytes: 20652
//
// Created by Hideaki Imamura on 2020-03-14.
//
# include <bits/stdc++.h>

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

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

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

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

ll h, w;

int main() {
    cin >> h >> w;
    if (h != 1 && w != 1) {
        cout << (h * w) / 2 + (h * w) % 2 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}

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

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

int main() {

    int n; cin >> n;
    string s; cin >> s;

    // 全て白にした場合を最初に考える
    int w = 0;
    int r = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') {
            r++;
        }
    }

    int ans = max(w, r);

    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') {
            r--;
        } else {
            w++;
        }

        int now = max(r, w);

        ans = min(ans, now);
    }

    cout << ans << endl;
}

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

int main(void) {
    int N, D;
    cin >> N >> D;

    int X[N][D];
    for(int i=0;i<N;i++) {
        for(int j=0;j<D;j++) {
            cin >> X[i][j];
        }
    }

    float norm;
    int int_norm;
    int cnt = 0;
    for(int i=0;i<N;i++) {
        for(int j=i+1;j<N;j++) {
                norm = 0.0;
            for(int k=0;k<D;k++) {
                norm += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }
                norm = sqrt(norm);
                int_norm = (int)norm;
                if(abs(norm-(float)int_norm)<0.0001) cnt++;
        }
    }

    cout << cnt << endl;

    return (0);
}


Measured memory_bytes: 256
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();
		for(int i=1;i<=b;i++){
			if(a*i%b==c){
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#include<vector>
#include<deque>
#include<list>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
	double ma=0;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int x,y;
	cin>>x>>y;
	cout<<abs(x-y)<<endl;

	return 0;
}



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

using namespace std;

typedef long long lint;
const lint N = 110, M = 1e5+100;
lint n, P, dp[N][M], w[N], value[N];

lint knapsack(int i, int p){
	if (dp[i][p] != -1)
		return dp[i][p];
	if (i == n)
		return dp[i][p] = 0;

	lint nao = knapsack(i+1, p), sim = 0;

	if (p - w[i] >= 0)
		sim = knapsack(i+1, p - w[i]) + value[i];

	return dp[i][p] = max(sim, nao);
}

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	scanf("%lld %lld", &n, &P);

	for (int i = 0; i < n; i++){
		scanf("%lld %lld", &w[i], &value[i]);
	}

	memset(dp, -1, sizeof dp);

	printf("%lld\n", knapsack(0, P));

	return 0; 
}

Measured memory_bytes: 89836
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const int INF = 100100100;
using namespace std;

int main()
{
  int A, B;
  int res=0;
  cin >> A >> B;

  res = A*B - A - B + 1;

  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    char c;
    cin >> c;

    cout << (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' ? "vowel" : "consonant") << endl;
    
    return 0;
}

Measured memory_bytes: 256
while 1 
n = gets.to_i
if n != 0 then
a = [0]
score_a=0
score_b = 0
tmp = [0]
for x in 1..n do
	tmp = gets.chomp.split(" ")
	tmp.map!{|x| x.to_i}
	if tmp[0] > tmp[1]
		score_a += tmp[0] + tmp[1]
	elsif tmp[0] < tmp[1]
		score_b += tmp[0] + tmp[1]
	else
		score_a +=tmp[0]
		score_b +=tmp[1]
	end
end

puts score_a.to_s + " " + score_b.to_s
else
break
end
end

Measured memory_bytes: 6112
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b,c;char t='a';cin>>a>>b>>c;
  int na,nb,nc;
  na=a.size();nb=b.size();nc=c.size();
  while(true){
    if(t=='a'){
      if(na==0){
        cout<<"A"<<endl;
        break;
      }
      else{
        t=a.at(a.size()-na);
        na--;
      }
    }
    else if(t=='b'){
      if(nb==0){
        cout<<"B"<<endl;
        break;
      }
      else{
        t=b.at(b.size()-nb);
        nb--;
      }
    }
    else{
      if(nc==0){
        cout<<"C"<<endl;
        break;
      }
      else{
        t=c.at(c.size()-nc);
        nc--;
      }
    }
  }
}

Measured memory_bytes: 256
from collections import deque
h,w = map(int,input().split())
dx = [1,-1,0,0]
dy = [0,0,1,-1]
ans = 0
maze = []
for i in range(h):
    maze.append(list(input()))
for i in range(h):
    for j in range(w):
        if maze[i][j] == ".":
            d = [[-1 for a in range(w)] for b in range(h)]
            dq = deque([(j,i)])
            d[i][j] = 0
            while dq:
                x,y = dq.popleft()
                for k in range(4):
                    nx = x + dx[k]
                    ny = y + dy[k]
                    if 0<=nx<=w-1 and 0<=ny<=h-1 and maze[ny][nx] != "#" and d[ny][nx] == -1:
                        dq.append((nx,ny))
                        d[ny][nx] = d[y][x]+1
                        ans = max(ans,d[ny][nx])
print(ans)

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

int main(void){
    vector<int> n(3);
    for(int i = 0; i < 3; i++){
        cin >> n[i];
    }
    sort(n.begin(), n.end());

    bool res = false;
    if(n[0] == n[1] && n[0] != n[2]) res = true;
    else if(n[1] == n[2] && n[0] != n[1]) res = true;

    cout << (res ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
class union_find_tree {
private:
	vector<int>par, rank_;
public:
	union_find_tree(int n) : par(n),rank_(n) {
		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank_[i] = 0;
		}

	}
	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = root(par[x]);
		}
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (rank_[x] > rank_[y]) {
			par[y] = x;
		}
		else if (rank_[x] == rank_[y]) {
			par[x] = y;
			rank_[y]++;
		}
		else if (rank_[x] < rank_[y]) {
			par[x] = y;
		}

	}
};

struct edge {
	int from, to, cost;
     bool operator<(const edge& other)const{
		 return cost < other.cost;
	 }
};

using edges = vector<edge>;

int kruskal(union_find_tree& uf, edges& es, int V) {

	sort(es.begin(), es.end());
	int res = 0;
	for (auto e : es) {
		if (!uf.same(e.from, e.to)) {
			uf.unite(e.from, e.to);
			res += e.cost;
		}
	}
	/*int E = es.size();
	for (int i = 0; i < E; i++) {
		if (!uf.same(es[i].from, es[i].to)) {
			uf.unite(es[i].from, es[i].to);
			res += es[i].cost;
		}
	}*/
	return res;
}

int main() {
	int V, E;
	cin >> V >> E;
	edges es(E);
	for (int i = 0; i < E; i++) {
		cin >> es[i].from >> es[i].to >> es[i].cost;
	}
	union_find_tree uf(V);
	cout << kruskal(uf, es, V) << endl;
	return 0;

}






Measured memory_bytes: 4128
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        
        if(a<b) System.out.println("a < b");
        else if(a==b) System.out.println("a == b");
        else if(a>b) System.out.println("a > b");
    }
}


Measured memory_bytes: 26112
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <utility>
#define N 120
using namespace std;

pair<int, int> a[N];

int main(void)
{
    int n;
    int i, k, x, y;
    long long o;

    scanf("%d", &n);
    for(i = 0; i < n; i ++)
        scanf("%d %d", &a[i].first, &a[i].second);

    for(k = o = 0; k < 100000; k ++)
    {
        random_shuffle(a, a + n);
        for(i = x = y = 0; i < n; i ++)
            if((long long)(x + a[i].first) * (x + a[i].first) + (long long)(y + a[i].second) * (y + a[i].second) > (long long)x * x + (long long)y * y)
            {
                x += a[i].first ;
                y += a[i].second;
            }
        o = max(o, (long long)x * x + (long long)y * y);
    }
    printf("%.15Lf\n", sqrt((long double)o));

    return 0;
}


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

int main() {
  int R = 0, G = 0;
  cin >> R >> G;
  while(R<0 || R>4500 || G<0 || G>4500){
    cout << "please confirm input" << endl;
    cin >> R >> G;
  }
  cout << 2 * G - R << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;

const int MOD = 1e9 + 7;

ll s(ll b, ll e){
    return ((e + b) * (e - b + 1)) / 2;
}


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

    ll ans = 0;
    for(int i=k;i<=n+1;i++){
        ll mn = s(0, i-1);
        ll mx = s(n-i+1, n);
        ans += mx - mn + 1;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

int n;
vector<vector<int> >G;
vector<int> num[2];
int ok = 1;
vector<int> ans;

void dfs(int pos,int pre){
  int mn = -INF,mx = INF;
  for(int to:G[pos]){
    if(pre == to) continue;
    dfs(to,pos);
    Max(mn,num[0][to]);
    Min(mx,num[1][to]);
  }
  Max(num[0][pos],mn - 1);
  Min(num[1][pos],mx + 1);
}

void dfs2(int pos,int pre,int s){
  ok &= num[0][pos] <= s && s <= num[1][pos];
  if(!ok) return ;
  ans[pos] = s;
  
  for(int to:G[pos]){
    if(to == pre) continue;
    int mn = num[0][to], mx = num[1][to];
    if(mn <= s + 1 && s + 1 <= mx) dfs2(to,pos,s+1);
    else if(mn <= s -1 && s - 1 <= mx) dfs2(to,pos,s-1);
    else ok = 0;
  }
}

signed main(){
  cin>>n;
  G.resize(n);
  num[0].resize(n);
  num[1].resize(n);
  ans.resize(n);
  for(int i=0;i<n;i++) num[0][i] = -INF;
  for(int i=0;i<n;i++) num[1][i] = INF;

  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b, a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  int K;
  cin>>K;
  for(int i=0;i<K;i++){
    int v,p;
    cin>>v>>p; v--;
    num[0][v] = num[1][v] = p;
  }

  dfs(0,-1);
  dfs2(0,-1,num[1][0]);
  
  if(!ok) cout<<"No"<<endl;
  else {
    cout<<"Yes"<<endl;
    for(int i=0;i<n;i++) cout<<ans[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 16512