akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

class B3{
  public static void Main(){
    int n,q,fin_count = 0,fin_sum = 0;
    Queue<int> queue = new Queue<int>();
    Queue<string> queue2 = new Queue<string>();

    string[] str = Console.ReadLine().Split(' ');
    n = int.Parse(str[0]);
    q = int.Parse(str[1]);
    string[] name = new string[n];
    string[] fin_name = new string[n];
    int[] fin_time = new int[n];
    int[] time = new int[n];
    for(int i = 0;i < n;i++){
      string[] str2 = Console.ReadLine().Split(' ');
      name[i] = str2[0];
      time[i] = int.Parse(str2[1]);
    }
    for(int i = 0;i < n;i++){
      queue.Enqueue(time[i]);
      queue2.Enqueue(name[i]);
    }
    while(true){
      int x = queue.Dequeue();
      if(x - q <= 0){
        fin_name[fin_count] = queue2.Dequeue();
        fin_time[fin_count] = x + fin_sum;
        fin_sum += x;
        fin_count++;
        if(fin_count == n) break;
      }
      else if(x - q > 0){
        int i = 0;
        string temp;
        temp = queue2.Dequeue();
        queue.Enqueue(x - q);
        queue2.Enqueue(temp);
        i++;
        fin_sum += q;
      }
    }
    for(int i = 0;i < n;i++){
      Console.WriteLine(fin_name[i] + " " + fin_time[i]);
    }
  }
}


Measured memory_bytes: 16496
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////




int main() {

	ll N;
	cin >> N;
	vector<ll> x(N + 1), y(N + 1);
	repn(i, N) cin >> x[i] >> y[i];

	map<pair<ll, ll>, ll> mp;

	repn(i, N) {
		repn(j,N){
			if (i == j) { continue; }
			mp[{x[i] - x[j], y[i] - y[j]}]++;
		}
	}

	ll ans = N;

	for (auto x : mp) {
		ans = min(ans, N - x.second);
	}


	cout << ans;

	system("PAUSE");

}


Measured memory_bytes: 632
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處
const int MAXN = 1e7 + 2;
int cnt[MAXN];

int main() {
	LL N; cin >> N;
	memset(cnt, 0, sizeof(int) * (N+1));
	LL ans = 0;
	ans += (N+1) * N / 2;
	for (int i = 2; i <= N; ++i) {
		ans += 1LL * (cnt[i]+1) * i;
		for (int j = 2; i * j <= N; ++j) {
			++cnt[i*j];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 42676
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
using namespace std;
#define loop(i,a,b) for(int i = a; i < b; i++)
#define rep(i,a) loop(i,0,a)
#define shosu(x) fixed<<setprecision(x)
typedef long long ll;

int main()
{	
	string str;
	
	cin>>str;
	cin>>str;
	
	cout<<'A'<<str[0]<<'C'<<endl;


	return 0;
}



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

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int N, A, x[51];
ll dp[51][51][2503];
vector<int> vec;
ll dfs(int a, int i, int sum) {
    if (i == N) {
        return a != 0 && sum == A * a;
    }
    if (dp[a][i][sum] != -1) return dp[a][i][sum];
    ll ret = 0;

    ret += dfs(a, i + 1, sum);
    if (sum + x[i] <= 2503) {
        ret += dfs(a + 1, i + 1, sum + x[i]);
    }

    return dp[a][i][sum] = ret;
}
int popcount(int S) {
    int ret = 0;
    while (S) {
        if (S & 1) ret++;
        S >>= 1;
    }
    return ret;
}
void small() {
    int ans = 0;
    int cnt[51] = {};
    rep(S, 1 << N) if (S) {
        int s = 0;
        rep(i, N) if (S >> i & 1) s += x[i];
        if (A * popcount(S) == s) {
            ans++;
            // rep(i, N) if (S >> i & 1) cout << x[i] << " ";
            cnt[popcount(S)]++;
            // cout << endl;
        }
    }
    // rep(i, N) cout << i << ": " << cnt[i] << endl;
    cout << ans << endl;
}
int main() {
    cin >> N >> A;
    rep(i, N) cin >> x[i];
    ll ans = 0;
    memset(dp, -1, sizeof(dp));
    ll t = dfs(0, 0, 0);
    ans += t;
    cout << ans << endl;
    return 0;
}


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

int main()
{
        long i, N,K;
        long sum = 0L;
        scanf("%ld %ld", &N, &K);
        long den = 1000000007L;
        for (i=K;i<=N+1;i++) {
                sum += (i*(N-i+1)+1);
        }
        printf("%ld\n", sum%den);
        return EXIT_SUCCESS;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
int main() {
	int H, N; cin >> H >> N;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		int x; cin >> x;
		sum += x;
	}
	cout << (sum >= H ? "Yes" : "No");
}

Measured memory_bytes: 256
n = int(input())
t = [int(input()) for _ in range(n)]

from fractions import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm(t))


Measured memory_bytes: 5076
#include<stdio.h>
main(){
  long long a,b,i;
  while(scanf("%lld %lld",&a,&b)!=EOF){
    a=a+b;
    for(i=0;a!=0;i++){
      a=a/10;
    }
    printf("%lld\n",i);
  }
  return 0;
}

Measured memory_bytes: 600
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

bool cmp(const pii&l, const pii&r)
{
	return (l.first/l.second)<(r.first/r.second);
}


void min_u(int&m, int v)
{
	if(m<0 || m>v) m=v;
}


int main(void)
{
	int h, n;
	while(scanf("%d%d", &h, &n)==2)
	{
		vpii ab(n);
		for(auto&m:ab) scanf("%d%d", &m.first, &m.second);

		vi dp(h+1, -1);
		dp[0]=0;
		for(int j=0;j<n;j++)
		{
			for(int i=0;i<=h;i++)
			{
				if(dp[i]<0) continue;
				int nh=i+ab[j].first;
				int nm=dp[i]+ab[j].second;
				if(nh>h) nh=h;
				min_u(dp[nh], nm);
			}
		}
		printf("%d\n", dp[h]);
	}
	return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        int[] A = new int[int.Parse(Console.ReadLine())];
        string[] input = Console.ReadLine().Split(' ');
        for(int i = 0; i < A.Length; i++)
        {
            A[i] = int.Parse(input[i]);
        }

        ulong sum = 0;
        bool isOdd = false;
        int min = int.MaxValue;
        for(int i = 0; i < A.Length; i++)
        {
            int v = Math.Abs(A[i]);
            if (A[i] < 0) isOdd = isOdd == false;
            if ( v < min)
            {
                min = v;
            }
            sum += (ulong)v;
        }
        if (isOdd)
        {
            sum -= (ulong)min * 2;
        }
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 29280
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long int ll;

int main()
{
    int n,a;

    while(scanf("%d%d",&n,&a) != EOF)
    {
        printf("%d\n",n*n-a);
    }

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	int L, R; scanf("%d%d", &L, &R);
	
	int ret = 3000, upper = min(R, L + 2018);
	for (int i = L; i <= upper; i++){
		for (int j = i + 1; j <= upper; j++){
			ret = min(ret, ((i%2019)*(j%2019)) % 2019);
		}
	}

	printf("%d", ret);

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
n,k = map(int,input().split())

m = 10**9 + 7



#print(ans)

rr = 0
mx = 0
mn = 0
for i in range(k):
    mx += (n-i)%m
    mn += i%m

#print(mx)
#print(mn)
#print("-------")
rr = mx-mn+1
#print(rr)
#print("-------")
pp = rr
for j in range(k+1,n+2):
    mn_p = j-1
    mx_p = n-j+1
    #print(mn_p,mx_p)
    if(mx_p==0 or mn_p == n):
        pp += 1
        break
    else:
        pp += rr +mx_p - mn_p
        rr = rr +mx_p - mn_p
        #print(pp)
        
    
    
print(pp%m)    
    
    

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

int main() {
  string S;
  cin >> S;
  bool palindrome1=true, palindrome2=true, palindrome3=true;
  int N = S.size();
  for (int i=0; i<N; i++) {
    if (S.at(i)!=S.at(N-1-i)) {
      palindrome1 = false;
      break;
    }
  }
  for (int i=0; i<(N-1)/2; i++) {
    if (S.at(i)!=S.at((N-3)/2-i)) {
      palindrome2 = false;
      break;
    }
  }
  for (int i=(N+1)/2; i<N; i++) {
    if (S.at(i)!=S.at(N-1-i)) {
      palindrome3 = false;
      break;
    }
  }
  if (palindrome1&&palindrome2&&palindrome3) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
x1,y1,x2,y2=map(int,input().split())

x3=x2-(y2-y1)
y3=y2+x2-x1
x4=x3-(x2-x1)
y4=y3-(y2-y1)
print(str(x3)+' '+str(y3)+' '+str(x4)+' '+str(y4))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <bitset>
#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000'000'007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;
int main(){
    
    string s;
    cin >> s;

    ll ans = 0;
    ll tmp;
    for(int i = 0;i < (1ll << (s.size() - 1));i++){
        tmp = s[0] - '0';
        for(int j = 0;j < s.size() - 1;j++){
            if(i & (1 << j)){
                ans += tmp;
                tmp = s[j+1] - '0';
            }
            else{
                tmp *= 10;
                tmp += s[j+1] - '0';
            }
        }
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int N, M; cin >> N >> M;
    vector<int> v[100001];
    for (int i=0; i<N; i++) {
        int A, B; cin >> A >> B;
      	v[A].push_back(B);
    }
  
    int ans = 0;
    priority_queue<int> pq;
    for (int i=1; i<=M; i++)
    {
        for (auto e : v[i]) pq.push(e);
   		if (! pq.empty()) {
          ans += pq.top();
          pq.pop();
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5632
N=int(input())
A=list(map(int, input().split()))

p=10**9+7

SUM=0
for i in range(N):
    SUM+=A[i]
    SUM%=p

ans=0
for i in range(N):
    SUM-=A[i]
    SUM%=p
    ans+=(A[i]*(SUM))%p
    
    ans%=p

print(ans)
#print(SUM)

Measured memory_bytes: 105392
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn solve(n: u64, k: u64) -> Option<Vec<(u64, u64)>> {
    if k > (n - 1) * (n - 2) / 2 {
        return None;
    }

    let mut ans = (2..(n + 1)).map(|i| (1, i)).collect::<Vec<(u64, u64)>>();

    let times = (n - 1) * (n - 2) / 2 - k;
    let mut cnt = 0;
    let mut s = 2;
    let mut e = 3;

    while cnt < times {
        ans.push((s, e));
        if e == n {
            s += 1;
            e = s + 1;
        } else {
            e += 1;
        }
        cnt += 1;
    }

    Some(ans)
}

fn main() {
    let (n, k) = parse_line!(u64, u64);
    match solve(n, k) {
        Some(vec) => {
            println!("{}", vec.len());
            for e in vec {
                println!("{} {}", e.0, e.1);
            }
        }
        None => println!("-1"),
    }
}

#[test]
fn solve_test() {
    assert_eq!(
        solve(5, 3),
        Some(vec![(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5)])
    );

    assert_eq!(solve(2, 0), Some(vec![(1, 2)]));
}


Measured memory_bytes: 4352
import bisect
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=[0]
B=[0]
for i in range(n):
    A.append(A[-1]+a[i])
for i in range(m):
    B.append(B[-1]+b[i])
ans=0
for i in range(n+1):
    if A[i]>k:
        break
    index=bisect.bisect_right(B,k-A[i])-1
    index=max(0,index)
    ans=max(ans,i+index)
print(ans)


Measured memory_bytes: 47488
#include<bits/stdc++.h>
using namespace std;
#define ll                          long long
#define in(a)                       ll a; cin>>a;
#define in2(a,b)                    ll a,b; cin>>a>>b;
#define in3(a,b,c)                  ll a,b,c; cin>>a>>b>>c;
#define in4(a,b,c,d)                ll a,b,c,d; cin>>a>>b>>c>>d;
#define in5(a,b,c,d,e)              ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
#define lelo(b)                     for(auto &i:b)cin>>i;
#define ff                          first
#define ss                          second
#define call(v)                     v.begin(),v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define show(x)                     for(auto t:x)cout<<t<<" ";
#define pb                          push_back
#define bhar(s,v)                   memset(s,v,sizeof(s))
#define endl                        "\n"                       
#define ce(x)                       cout<<x<<"\n";
#define nl                          cout<<endl;
#define jaldi                       ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dekh_lo                     ce("dekh_lo");
#define sz(x)                       (ll)x.size()
#define re                          return

typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;

const ll mod=1e9+7;
const ll N=4e5+5;

void solve(){
    in3(h,w,m);

    ll s=m;
    vii cor;
    while(s--){
        in2(x,y);
        cor.pb({x,y});
    }

    vi row(h+1,0),col(w+1,0);
    map<pii,bool> hash;

    for(ll i=0;i<sz(cor);i++){
        row[cor[i].ff]++;
        col[cor[i].ss]++;
        hash[{cor[i].ff,cor[i].ss}]=1;
    }

    ll maxi1=-1e9;
    vi ind1;
    for(ll i=1;i<=h;i++){
        if(row[i]>maxi1){
            maxi1=row[i];
        }
    }

    for(ll i=1;i<=h;i++){
        if(row[i]==maxi1){
            ind1.pb(i);
        }
    }

    ll maxi2=-1e9;
    vi ind2;
    for(ll i=1;i<=w;i++){
        if(col[i]>maxi2){
            maxi2=col[i];
        }
    }

    for(ll i=1;i<=w;i++){
        if(col[i]==maxi2){
            ind2.pb(i);
        }
    }

    bool f=0;
    for(auto j:ind1){
        for(auto i:ind2){
            if(!hash[{j,i}]){
                f=1;
              	break;
            }
        }   
    }
   

    ll ans=maxi1+maxi2-(f==0);
    ce(ans);
   
}

int32_t main(){
    // jaldi
    ll t; 
    // cin>>t;
    t=1;     
    while(t--){
        solve();
    }
} 


Measured memory_bytes: 54828
x,y = (int(i) for i in input().split())

list1 = [1,3,5,7,8,10,12]
list2 = [4,6,9,11]

if x in list1 and y in list1:
    print('Yes')
    
elif x in list2 and y in list2:
    print('Yes')
    
else:
    print('No')
    


Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s,ans=""; cin>>s;
    rep(i,s.size()){
        if(s[i]=='0'){
            ans=ans+"0";
        }
        else if(s[i]=='1'){
            ans=ans+"1";
        }
        else{
            if(ans.size()) ans.pop_back();
        }
    }
    cout<<ans<<endl;
}

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

int main(){
  int N,Q,cnt=0,l,r;
  string S;
  cin >> N >> Q >> S;
  vector<int> vec(N);
  vec[0]=0;
  for(int i=0;i<N-1;i++){
    if(S[i]=='A'&&S[i+1]=='C')
      cnt++;
    vec[i+1]=cnt;
  }
  for(int j=0;j<Q;j++){
    cin >> l >> r;
    cout << vec[r-1]-vec[l-1] << endl;
  }
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<int, int> P;
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
const ll INF = 1e15;
//const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

ll calc(string s) {
    stack<ll> st;
    st.push(0);
    for (char c : s) {
        if (c == '+') {
            st.push(0);
        } else {
            int i = c - '0';
            st.top() *= 10;
            st.top() += i;
        }
    }

    ll ans = 0;
    while (!st.empty()) {
        ans += st.top();
        st.pop();
    }
    return ans;
}

int main() {
    string s;
    cin >> s;

    int d = s.size() - 1;
    ll ans = 0;
    for (int i = 0; i < (1 << d); i++) {
        string t = "";

        for (int j = 0; j < d; j++) {
            t += s[j];
            if ((i >> j) & 1) {
                t += '+';
            }
        }
        t += s.back();
        ll now = calc(t);
        ans += now;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#define _USE_MATH_DEFINENS
#include <cmath>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int a, b, c;
    cin >> a >> b >> c;
    cout << (a * b) / 2 << endl;
}


Measured memory_bytes: 256
import itertools
s=input()
op=list(itertools.product([1,-1], repeat=3))
ans=[int(s[0])]*8
for i in range(8):
    for j in range(3):
        ans[i]+=op[i][j]*int(s[j+1])
newop=['+']*3
for i in range(3):
    if op[ans.index(7)][i]!=1:
        newop[i]='-'
print(s[0]+newop[0]+s[1]+newop[1]+s[2]+newop[2]+s[3]+'=7')

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

int main(void) {
  //input
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i,N) {
    cin >> L.at(i);
  }
  //calc
  int answer = 0;
  sort(L.begin(), L.end());
  int a, b, c;
  for(int i = 0; i < N; i++) {
    a = L.at(i);
    for(int j = i+1; j < N; j++) {
      b = L.at(j);
      for(int k = j+1; k < N; k++) {
        c = L.at(k);
        if ( b < a + c && c < a + b ) {
          answer++;
        }
      }
    }
  }
  //output
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
int main()
{
        int n,i,a;
        cin>>n;
        vector<int>v;
        for(i=0;i<n;i++)
        {
                cin>>a;
                v.push_back(a);
        }
        sort(v.begin(),v.end());
        reverse(v.begin(),v.end());
        long long int s=0;
                s=s+v[0];
        for(i=0;i<n-2;i++)
        {
            s=s+v[i/2+1];   
               // cout<<s<<endl;
        }
        cout<<s;
   return 0;    
}

Measured memory_bytes: 4300
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define rev_rep(i, n) for(int i = n - 1; i >= 0; --i)
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::set<T>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

ll f(ll x){
  if(x % 2 == 0){
    return x/2;
  }else{
    return x * 3 + 1;
  }
}

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){

  ll s;
  cin >> s;

  set<ll> memory;
  int res = 0;
  memory.insert(s);
  while(memory.find(s) == memory.end() || res == 0){
    // dump(memory);
    // dump(s);
    memory.insert(s);
    s = f(s);
    res++;
  };
  cout << res + 1;
  
  
}
#endif


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {

	ull n;

	cin >> n;
	for ( ull i = sqrt(n) ; i > 0 ; i-- ){
		if ( n % i == 0 ){
			cout << n / i + i - 2 << "\n";
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
/*WELCOME TO AYUSH RANJAN CODE'S*/
/*EVERY PROBLEM HAS A SOLUTION SOMETIMES ELEGENT OTHERWISE COMPLEX ELEGENCE*/

#include <bits/stdc++.h>
using namespace std;

    int chkpower2(int x){
        return (x&&!(x&x-1));
    }


    void solve(){
        int d1,n;
        cin>>n;
        int a[4]={0};
        for(int i1=0;i1<n;i1++){
            string s1;
            cin>>s1;
            if(s1=="AC"){
                a[0]++;
            }
            if(s1=="WA"){
                a[1]++;
            }
            if(s1=="TLE"){
                a[2]++;
            }
            if(s1=="RE"){
                a[3]++;
            }
        }
        cout<<"AC x "<<a[0]<<"\n"<<"WA x "<<a[1]<<"\n"<<"TLE x "<<a[2]<<"\n"<<"RE x "<<a[3]<<"\n";
    }

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

        int t;
       t=1;//cin>>t;
        while(t--){
            solve();
            cout<<"\n";
        }
        return 0;
    }


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
bool b=false;
for(int i=n,j=0;i!=-1;i--,j++){
    if(i%4==0&&j%7==0)b=true;
}
if(b)cout<<"Yes";
else cout<<"No";
return 0;
}

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

typedef pair<int,int> pii;

const int N = 50;
const int INF = 1e9;
int n;
int li[4][N+5];

int cnt_bit(int x){
	int ret = 0;
	while(x > 0){
		ret += x&1;
		x/=2;
	}
	return ret;
}

bool cek_bit(int x, int mask){
	return (1<<x) & mask;
}

int tog_bit(int x, int mask){
	return (1<<x) ^ mask;
}

int memo[(1<<18)][52];

int dp(int id, int mask, int last){
	if(mask == (1<<n)-1) return 0;
	int &ret = memo[mask][last];
	if(ret!=-1) return ret;
	ret = INF;
	for(int i=0;i<n;i++){
		if(cek_bit(i,mask)) continue;
		int pake = -1;
		if(abs(i-id)&1){
			pake = li[1][i];
		} else {
			pake = li[0][i];
		}
		if(pake >= last){
			int co = 0;
			for(int j=0;j<i;j++){
				if(!cek_bit(j,mask)) co++;
			}
//			for(int j=0;j<n;j++) cout << (cek_bit(j,mask) ? 1 : 0);
//			cout << " >> " << i << " ke " << id << " cost " << co << " dengan " << pake << endl;
			ret = min(ret,dp(id+1,tog_bit(i,mask),pake) + co);
		}
	}
	return ret;
}


int main(){
	memset(memo,-1,sizeof(memo));
	scanf("%d",&n);
	for(int j=0;j<2;j++){
		for(int i=0;i<n;i++){
			scanf("%d",&li[j][i]);
		}
	}
	int ans = dp(0,0,0);
	if(ans == INF) ans = -1;
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 53504
import java.util.*;

class Main{
	int n;
	int[] ai;
	Scanner scan = new Scanner(System.in);
	public Main(){
		n=scan.nextInt();
		ai=new int[n];
		for(int i=0; i<n; i++){
			ai[i]=scan.nextInt();
		}
		int min=1000000;
		for(int i=0; i<n; i++){
			if(min>ai[i])min=ai[i];
		}
		int max=-1000000;
		for(int j=0; j<n; j++){
			if(max<ai[j])max=ai[j];
		}
		long sum=0;
		for(int k=0; k<n; k++){
			sum=sum+ai[k];
		}
		System.out.println(min+" "+max+" "+sum);
	}
	public static void main(String[]args){
		new Main();
	}
}

Measured memory_bytes: 41224
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

ll gcd(ll x, ll y) {
  if(x > y)
    return gcd(y, x);
  else if(x == 0)
    return y;
  else
    return gcd(y % x, x);
}
ll lcm(ll x, ll y) {
  ll g = gcd(x, y);
  return g * (x / g) * (y / g);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x; cin >> x;
  ll l = lcm(x, 360);
  cout << l / x << endk;
  return 0;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


LL f(LL b, LL n) {
  if (b == 1) return -1;
  if (n < b) return n;
  else return f(b, n / b) + (n % b);
}

void output(LL x) {
  cout << x << endl;
  exit(0);
}

int main(){
  LL n, s;
  cin >> n >> s;

  if (n < s) output(-1);
  else if (n == s) output(n + 1);

  FOR (i, 2, sqrt(n) + 1) {
    if (f(i, n) == s) output(i);
  }

  RFOR (i, 1, sqrt(n) + 1) {
    LL b = (n - s) / i + 1;
    if (f(b, n) == s) output(b);
  }

  output(-1);
}


Measured memory_bytes: 384
import java.util.Scanner;

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

        int N = sc.nextInt();
        int K = sc.nextInt();

        System.out.println(solve(N, K));

        sc.close();
    }

    static int solve(int N, int K) {
        int result = 1;
        for (int i = 0; i < N; ++i) {
            result = Math.min(result * 2, result + K);
        }

        return result;
    }
}

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

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

  string s;
  cin >> s;

  int x = n / 2;
  int cnt = 0;
  if(n == 1 || n%2 == 1){
    cout << "No";
    return 0;
  }
  for(int i=0; i<x; ++i){
    if(s[i] == s[i+x]) cnt++;
  }

  if(x == cnt) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MAX 200000
#define SENTINEL 2000000000
typedef long long ll;
int L[MAX / 2 + 2], R[MAX / 2 +2];

ll merge(int A[], int n, int left, int mid, int right) {
	int i = 0, j = 0, k;
	ll cnt = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	for (i = 0; i < n1; i++) L[i] = A[left + i];
	for (i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] = SENTINEL;
	i = j = 0;
	for (k = left; k < right; k++) {
		if(L[i] <= R[j]) {
			A[k] = L[i++];
		} else {
			A[k] = R[j++];
			cnt += n1 - i;
		}
	}
	return cnt;
}

ll mergeSort(int A[], int n, int left, int right) {
	ll v1,v2,v3;
	if ( left+1 < right ) {
		int mid = (left + right) / 2;
		v1 = mergeSort(A, n, left, mid);//左半分から
		v2 = mergeSort(A, n, mid, right);
		v3 = merge(A,n,left,mid,right);
		return v1 + v2 + v3;
	} else return 0;
}



int main() {
  int A[MAX],n,i;

  scanf("%d", &n);
  for (i=0;i<n;i++) {
		cin >> A[i];
  }

	ll ans = mergeSort(A,n,0,n);
	cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4808
object Main extends App {
  //最大公約数
  def gcd(x: Long, y: Long): Long = {
    if(y == 0) x
    else gcd(y, (x % y))
  }

  val k =  scala.io.StdIn.readInt()
  var result = 0L

  (1 to k).foreach { a =>
    (1 to k).foreach { b =>
      (1 to k).foreach { c =>
        val gcdResult = gcd(gcd(a.toLong, b.toLong), c.toLong)
        if(a == b && a == c && b ==c) {
          result += gcdResult
        } else {
          result += gcdResult
        }

      }
    }
  }
  println(result)
}

Measured memory_bytes: 54788
#include<bits/stdc++.h>                                                                                               
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
#define mk_p(a,b)   make_pair((a),(b))
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    cout << ((a == b && b == c) ? "Yes\n" : "No\n");
    return 0;
}


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

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i ++) cin >> h[i];
    
    sort(h.begin(), h.end());
    
    int m = 1000000000;
    for(int i = 0; i+k-1 < n; i ++){
        if(m > h[i+k-1] - h[i]) m = h[i+k-1] - h[i];
    }
    
    cout << m << "\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define frst first
#define sec second
#define fast cin.tie(0) , ios_base :: sync_with_stdio(0)
#define db double
#define mod 1000000007
void online_judge()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}


ll dp[200001];

ll dfs(vector<ll> g[] , ll strt , bool* vis)
{
	vis[strt] = 1;
	ll ans = 1;
	for (auto x : g[strt])
	{
		if (!vis[x]) {
			ans = max(ans , 1 + dfs(g , x , vis));
		}
		else {
			ans = max(ans , 1 + dp[x]);
		}
	}
	///cout << ans << " ";
	return dp[strt] = ans;
}

void go() {
	ll n , m;
	cin >> n >> m;
	vector<string> v(n);
	for (int i = 0; i < n; ++i)cin >> v[i];
	ll **dp = new ll*[n];
	for (int i = 0; i < n; ++i)dp[i] = new ll[m]();
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			if (i == 0 && j == 0) {
				dp[i][j] = 1;
				continue;
			}
			if (v[i][j] == '#')dp[i][j] = 0;
			else {
				if (i > 0)dp[i][j] += dp[i - 1][j];
				dp[i][j] %= mod;
				if (j > 0)dp[i][j] += dp[i][j - 1];
				dp[i][j] %= mod;
			}
		}
	}
	cout << dp[n - 1][m - 1];
}


int main() {
	fast;
	//online_judge();
	//cout << 2332;
	go();
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int a, b; cin >> a >> b;
  cout << max(0, a-2*b) << endl;
  return 0;
}


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

int main(){

int h[10];

for(int i=0;i<10;i++)
	scanf("%d",&h[i]);

sort(h,h+10);

printf("%d\n%d\n%d\n",h[9],h[8],h[7]);

return 0;		
}

Measured memory_bytes: 1044
#include <stdio.h>
#define N 3000

int main()
{
  int x,y,i,count;
  int a[N],b[N];

  count=0;

  for(i=0;i<N;i++)
  {
    scanf("%d %d",&x,&y);

    if(x==0 && y==0) break;

    else if(x>y)
    {
      b[i]=x;
      a[i]=y;
    }

    else
    {
      a[i]=x;
      b[i]=y;
    }

    count++;

  }

  for(i=0;i<count;i++) printf("%d %d\n",a[i],b[i]);

  return 0;

}

Measured memory_bytes: 624
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
#define int long long
using namespace std;
typedef long long ll;
const int N = 55;
const int M = 110;
const int K = 20010;
const int INF = 0x3f3f3f3f3f3f3f3fLL;
int n, m, money;
struct edge{
    int v, cost, tim, nxt;
}e[M<<2];
int tot, head[N], c[N], d[N];
int dis[N][K];
struct node{
    int u, cst, dis;
    node(int u = 0, int cst = 0, int dis = 0):u(u),cst(cst),dis(dis){}
    bool operator<(const node& rh)const{
        return dis > rh.dis;
    }
};
void init(void){
    tot = 0; memset(head, -1, sizeof head);
}
void addedge(int u, int v, int a, int b){
    e[tot] = (edge){v, a, b, head[u]}; head[u] = tot++;
    e[tot] = (edge){u, a, b, head[v]}; head[v] = tot++;
}
void dijkstra(int s){
    for (int i = 1; i <= n; ++i){
        for (int j = 0; j < K; ++j) dis[i][j] = INF;
    }
    for (int i = 0; i <= min(money, K-1); ++i){
        dis[s][i] = 0;
    }
    priority_queue<node> q;
    q.push(node(s, min(money, K-1), 0));
    while (!q.empty()){
        node p = q.top(); q.pop();
        int u = p.u, cost = p.cst, ds = p.dis;
        //printf("u %d cost %d ds %d\n", u, cost, ds);
        if (ds != dis[u][cost]) continue;
        for (int i = head[u]; i != -1; i = e[i].nxt){
            int v = e[i].v, cst = e[i].cost, tim = e[i].tim;
            if (cost >= cst && dis[v][cost-cst] > dis[u][cost]+tim){
                dis[v][cost-cst] = dis[u][cost]+tim;
                q.push(node(v, cost-cst, dis[v][cost-cst]));
            }
        }
       // printf("cost %d cu %d du %d\n", cost, c[u], d[u]);
        if (cost+c[u] < K){
            if (dis[u][cost+c[u]] > dis[u][cost]+d[u]){
                dis[u][cost+c[u]] = dis[u][cost]+d[u];
                q.push(node(u, cost+c[u], dis[u][cost+c[u]]));
            }
        }
    }
}
signed main(void){
    IOS;
    init();
    cin >> n >> m >> money;
    for (int i = 1; i <= m; ++i){
        int u, v, a, b; cin >> u >> v >> a >> b;
        addedge(u, v, a, b);
    }
    for (int i = 1; i <= n; ++i){
        cin >> c[i] >> d[i];
    }
    dijkstra(1);
    for (int i = 2; i <= n; ++i){
        int t = INF;
        for (int j = 0; j < K; ++j){
            t = min(t, dis[i][j]);
        }
        cout << t << endl;
    }
    return 0;
}

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

typedef long long ll;

int n,d,a,sz;
ll data[800005];
ll lazy[800005];
pair<int,int> mon[200005];

void build(int bk,int l,int r){
    if(l==r){
        if(l<=n){
            data[bk]=mon[l].second;
        }
        return;
    }
    build(bk<<1,l,(l+r)>>1);
    build(bk<<1|1,((l+r)>>1)+1,r);
    data[bk]=data[bk<<1]+data[bk<<1|1];
}

void upd(int bk,int l,int r,int ql,int qr,ll val){
    if(qr<l||r<ql)return;
    if(ql<=l&&r<=qr){
        lazy[bk]+=val;
        data[bk]+=val*(r-l+1);
        return;
    }
    lazy[bk<<1]+=lazy[bk];
    data[bk<<1]+=lazy[bk]*((r-l+1)>>1);
    lazy[bk<<1|1]+=lazy[bk];
    data[bk<<1|1]+=lazy[bk]*((r-l+1)>>1);
    lazy[bk]=0;
    upd(bk<<1,l,(l+r)>>1,ql,qr,val);
    upd(bk<<1|1,((l+r)>>1)+1,r,ql,qr,val);
    data[bk]=data[bk<<1]+data[bk<<1|1];
}

ll qry(int bk,int l,int r,int ql,int qr){
    if(qr<l||r<ql)return 0;
    if(ql<=l&&r<=qr){
        return data[bk];
    }
    lazy[bk<<1]+=lazy[bk];
    data[bk<<1]+=lazy[bk]*((r-l+1)>>1);
    lazy[bk<<1|1]+=lazy[bk];
    data[bk<<1|1]+=lazy[bk]*((r-l+1)>>1);
    lazy[bk]=0;
    return qry(bk<<1,l,(l+r)>>1,ql,qr)+qry(bk<<1|1,((l+r)>>1)+1,r,ql,qr);
}

ll ans;

int main(){

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

    cin>>n>>d>>a;
    sz=1;while(sz<n)sz<<=1;
    for(int i=1;i<=n;i++){
        cin>>mon[i].first>>mon[i].second;
    }
    sort(mon+1,mon+1+n);
    build(1,1,sz);
    int l=1,r=1;
    while(l<=n){
        while(mon[r+1].first-mon[l].first<=d+d&&r<n){
            r++;
        }
        ll lft=qry(1,1,sz,l,l);//cerr<<lft<<endl;
        if(lft<=0){
            l++;
            continue;
        }
        ll tms=(lft+a-1)/a;
        ans+=tms;
        upd(1,1,sz,l,r,(-tms)*a);
        l++;
    }
    cout<<ans<<endl;

    return 0;
}

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

int main(void) {
	string moji;
	int p;
	int count[26] = {};
	char math[26];
	while (1) {
		getline(cin, moji);
		if (moji[0] == '\0')break;
		p = moji.size();

		for (int t = 0; t <= 25; t++) {
			for (int i = 0; i <= p; i++) {
				if (moji[i] == '\n')break;
				if ((moji[i] == 65 + t) || (moji[i] == 97 + t)) {
					count[t]++;
				}
			}
		}
	}
	
	for (int s = 0; s <= 25; s++) {
		math[s] = 97+s;
		cout << math[s] << " : " << count[s] << "\n";
	}
	return 0;
}

Measured memory_bytes: 3172
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

import heapq


class PriorityQueue:
    class Reverse:
        def __init__(self, val):
            self.val = val

        def __lt__(self, other):
            return self.val[0] > other.val[0]

        def __repr__(self):
            return repr(self.val)

    def __init__(self, x=None, desc=False):
        if not x:
            x = []
        if desc:
            for i in range(len(x)):
                x[i] = self.Reverse(x[i])
        self._desc = desc
        self._container = x
        heapq.heapify(self._container)

    @property
    def is_empty(self):
        return not self._container

    def pop(self):
        if self._desc:
            return heapq.heappop(self._container).val
        else:
            return heapq.heappop(self._container)

    def push(self, item):
        if self._desc:
            heapq.heappush(self._container, self.Reverse(item))
        else:
            heapq.heappush(self._container, item)

    def top(self):
        if self._desc:
            return self._container[0].val
        else:
            return self._container[0]

    def sum(self):
        return sum(self._container)

    def __len__(self):
        return len(self._container)


def main():
    def f(p, q):
        ret = (min(p, q), max(p, q))
        return ret

    n = int(readline())
    a = list(map(int, readline().split()))
    a.sort(reverse=True)
    ans = a[0]
    pq = PriorityQueue(desc=True)
    pq.push(f(a[0], a[1]))
    pq.push(f(a[0], a[1]))

    for x in a[2:]:
        first, second = pq.pop()
        ans += first
        pq.push(f(first, x))
        pq.push(f(second, x))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 130516
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U;typedef long long ll;typedef pair<int,int > P;
ll inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	//int ttt;scanf("%d",&ttt);for(int i=1;i<=ttt;i++)
	printf("%lld",inp());
	return 0;
}
ll inp(){
	ll a,b;scanf("%lld%lld",&a,&b);
	if( a > b)swap(a,b);
	if( a == 1 ){
		if( b == 1 ) return 1;
		else return b - 2;
	}
	return a * b - ( a + b - 2)*2;
}
//a.cc by xsthunder at Sat Aug  4 13:41:49 2018


Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep3(i,a,b) for (int i = (a); i >= (b); --i)
#define all(x) (x).begin(),(x).end()
inline int popcount(const int x) { return __builtin_popcount(x);}
inline ll popcount(const ll x) { return __builtin_popcountll(x);}
template<class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b;}
template<class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b;}
template<class T> void drop(const T &x) { std::cout<<x<<endl; exit(0);}
void debug_out() { std::cout << "\n";}
template<class T, class... Args> void debug_out(const T &x, const Args &... args) { std::cout<<x<< " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

struct InitIO{
  InitIO() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
  }
}init_io;

map<ll, int> mp;

int dfs(ll y) {
  if (y == 0) return 0;
  if (mp.count(y)) return mp[y];
  ll next = y % popcount(y);
  mp[y] = dfs(next) + 1;
  return mp[y];
}

int main() {
  int n;
  string X;
  cin >> n >> X;
  int cnt = 0;
  rep(i, n) {
    if (X[i] == '1') cnt++;
  }
  ll modpop1 = 0, modpop2 = 0;
  ll two1 = 1;
  rep3(i, n-1, 0) {
    if (cnt-1 == 0) break; //cnt-1=0のとき0除算
    if (X[i] == '1') {
      modpop1 += two1;
      modpop1 %= (cnt-1);
    }
    two1 *= 2LL; two1 %= (cnt-1);
  }
  ll two2 = 1;
  rep3(i, n-1, 0) {
    if (X[i] == '1') {
      modpop2 += two2;
      modpop2 %= (cnt+1);
    }
    two2 *= 2LL; two2 %= (cnt+1);
  }

  // debug(modpop1, modpop2);
  two1 = 1LL, two2 = 1LL;
  vector<int> ans(n);
  rep3(i, n-1, 0) {
    ll y = 0;
    if (X[i] == '1') {
      if (cnt-1 == 0) {
        ans[i] = 0; continue;
      }
      y = modpop1 - two1;
      y %= (cnt-1);
      if (y < 0) y += ll(cnt-1);
    }
    else {
      y = modpop2 + two2;
      y %= (cnt+1);
    }
    if (cnt-1 != 0) {
      two1 *= 2LL; two1 %= (cnt-1);
    }
    two2 *= 2LL; two2 %= (cnt+1);

    ans[i] = dfs(y) + 1;
    // debug(y, ans[i]);
  }
  rep(i,n) cout << ans[i] << "\n";
  return 0;
}

Measured memory_bytes: 5720
#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)

int N;
int mod = 1000000007;

int main() {
    int mx = 200000;
    cin >> N;
    vector<int> memoi(mx,0);
    vector<int> memoans(mx,0);

    unsigned int ans = 1;
    int nowc;
    rep(i,N) {
        cin >> nowc;
        int fir = memoi[nowc], sec = memoans[nowc];
        if(sec != 0 && fir != i-1){
            ans += sec;
            ans = ans % mod;
        }
        memoi[nowc] = i;
        memoans[nowc] = ans;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1792
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = S()
    d = defaultdict(int)
    for i in s:
        d[i] += 1
    for i in d.keys():
        if d[i] != 2:
            print("No")
            quit()
    print("Yes")
    return

#B
def B():
    n = I()
    p = LI()

    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return


#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 39408
#include <bits/stdc++.h>
using namespace std;
#define fo(i, a, b)     for (int i=a; i<(b); i++)
#define forev(i, b, a)  for (int i = (b)-1; i >= a; i--)
typedef long long int   lli;
typedef long double     ld;
#define all(x) x.begin(), x.end()
#define sortall(x) sort(all(x))
#define enl "\n"
#define fast    ios_base::sync_with_stdio(0); cin.tie(0);
// #define PI 3.1415926535897932384626
// const int MOD = 1000000007; // const ll INF = 1e18; // const int MX = 100001;
//==================================================================================

int main() {
    fast;
    // int t; cin >> t; while (t--)
    // int a = ((11 ^ 9) ^ 24) ^ 20;
    // int b = a ^ 20;
    // cout << b;

    uint64_t n; cin >> n;
    uint64_t a[n];
    cin >> a[0];
    uint64_t xorr = a[0];
    for (uint64_t i = 1; i < n; ++i) {
        cin >> a[i];
        xorr = a[i] ^ xorr;
    }

    for (uint64_t i = 0; i < n; ++i) {
        uint64_t ans = xorr ^ a[i];
        cout << ans << " ";
    }


    return 0;
}

Measured memory_bytes: 5116