akhauriyash/Code-Regression huggingface dataset:
def mangoes(x, y, red, yellow, cc):
	red = sorted(red)
	red.reverse()
	yellow = sorted(yellow)
	yellow.reverse()
	cc = sorted(cc)
	cc.reverse()
	red = red[:x]
	yellow = yellow[:y]
	newa = red + yellow + cc
	newa = sorted(newa)
	newa.reverse()
	ans = sum(newa[:x + y])
	return ans

well = input().split(' ')
x = int(well[0])
y = int(well[1])
a = int(well[2])
b = int(well[3])
c = int(well[4])
red = input().split(' ')
red = [int(x) for x in red]
yellow = input().split(' ')
yellow = [int(x) for x in yellow]
cc = input().split(' ')
cc = [int(x) for x in cc]

print(mangoes(x, y, red, yellow, cc))

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1000000 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}

int n, k, s;

void work()
{
    cin >>n >>k >>s;

    for(int i = 0; i < k; i++) cout <<s <<" ";
    int t = s + 1;
    if(t > 1000000000) t = 1;
    for(int i = k; i < n; i++) cout <<t <<" ";
    cout <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
int M[110][110] = {0}; 
int n; 
cin >> n; 
for (int i = 1; i <= n; ++i){
  int k; 
  cin >> k; 
  int m; 
  cin >> m; 
    for (int l = 1; l <= m; ++l){
     int j; 
     cin >> j;
     M[k][j] = 1; 
    }
  }
for (int i = 1; i <= n; ++i){
  for (int j = 1; j <= n; ++j){
    if(j-1) cout << " "; 
    cout << M[i][j]; 
  }
  cout << endl; 
}
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;



int main(){
    ll x;
    cin >> x;
    ll ans=0;
    ans += (x/500)*1000;
    x -= (x/500)*500;
    ans += (x/5)*5;

    cout << ans << endl;
   

}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define bil ((ll)1e9)
#define mod ((ll)1e9+7)

int main(int argc,char* argv[]){
    int a,b;
    char op;
    cin >> a >> op >> b;

    if(op=='+')
        cout << a+b << endl;
    else if(op=='-')
        cout << a-b << endl;

    return 0;
}


Measured memory_bytes: 3584
N,T=map(int,input().split())
a=[]
for i in range(N):
    c,t=map(int,input().split())
    a.append([c,t])

cost=10000
for i in range(N):
    if a[i][1] <= T:
        cost = min(cost,a[i][0])



if cost==10000:
    print('TLE')
else:
    print(cost)
    

Measured memory_bytes: 3060
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-19 20:05:28
**/

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

using namespace std;

using int64 = long long;

template <class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '(' << p.first << ", " << p.second << ')'; }
template <class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { int flag = 0; for (auto e : vec) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { int flag = 0; for (auto e : st) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { int flag = 0; for (auto e : mp) os << (flag++ ? ", " : "{") << e; return os << '}'; }
template <class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { for (T& e : vec) is >> e; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

class Combination {
 public:
  static constexpr int mod_ = 1000000007;
  static constexpr int n_ = 300000 + 5;

  Combination() { build(); }

  std::array<int64, n_> fact_;
  std::array<int64, n_> inv_;
  std::array<int64, n_> finv_;

  // return nCk
  int64 get(int n, int k) const noexcept {
    if (n < k || n < 0 || k < 0) return 0;
    return fact_[n] * (finv_[k] * finv_[n - k] % mod_) % mod_;
  }

 private:
  void build() noexcept {
    fact_[0] = 1;
    fact_[1] = 1;
    finv_[0] = 1;
    finv_[1] = 1;
    inv_[1] = 1;
    for (int i = 2; i < n_; ++i) {
      fact_[i] = fact_[i - 1] * i % mod_;
      inv_[i] = mod_ - inv_[mod_ % i] * (mod_ / i) % mod_;
      finv_[i] = finv_[i - 1] * inv_[i] % mod_;
    }
  }
};

//Combination kyomu;

constexpr int64 MOD = 1e9 + 7;

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

  int64 n, k; cin >> n >> k;

  int64 ans = 0;

  for (int64 i = k; i <= n + 1; ++i) {
    ans += (n * i - i * (i - 1LL) + 1LL);
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}

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

int main() {

    int A, B, C;

    cin >> A >> B >> C;

    ll ans = 0;



    for (ll i = 0; i < B/A; i++) {
        if (ans >= C) break;
        ans++;
    }
    
    
    
    cout << ans << endl;
    
    return 0;
}

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

int LCS(char*,char*);


int main(){
  int i,q;
  char x[1001],y[1001];

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%s %s",x,y);

    printf("%d\n",LCS(x,y));
  }

  return 0;
}

int LCS(char *x,char *y){
  int i,j,x_l,y_l,c[1001][1001];

  x_l=strlen(x);
  y_l=strlen(y);

  for(i=0;i<=x_l;i++) c[i][0]=0;
  for(j=0;j<=y_l;j++) c[0][j]=0;

  for(i=1;i<=x_l;i++){
    for(j=1;j<=y_l;j++){

      if(x[i-1]==y[j-1]) c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j]< c[i][j-1]) c[i][j]=c[i][j-1];
      else c[i][j]=c[i-1][j];
    }
  }

  return c[x_l][y_l];
}



Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
int main () {
    int A,B;
    cin >>A >> B ;
    int a,b,c;
    int count =0;
    a=A/100;
    c=a/100;
    b=a/10%10;
    if (100*a+10*b+c>=A)count=1;
    while (true) {
        a++;
        if (a<B/100){
            count++;
        }
        else break;
    }
    c=a/100;
    b=a/10%10;
     if (100*a+10*b+c<=B)count++;
     cout << count <<endl;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 1e5 + 5;

vector<vii> AdjList;

int col[maxn];

void dfs(int node, int p, int w) {
	// printf("node: %d\n",node);
	col[node] = w;
	for(int i=0;i<AdjList[node].size();i++){
		ii v = AdjList[node][i];
		int tet = v.first, warna = v.second;
		if(tet != p){
			if(warna == 0){
				dfs(tet, node, w);
			}else{
				dfs(tet, node, 1-w);
			}	
		}
		
	}
}

int main(){
	int n,i,j;
	scanf("%d",&n);
	AdjList.assign(n+1,vii());
	for(i=0;i<n-1;i++){
		int a,b,w;
		scanf("%d %d %d",&a,&b,&w);
		w %= 2;
		AdjList[a].pb(ii(b,w)); AdjList[b].pb(ii(a,w));
	}
	dfs(1, -1, 0);
	for(i=1;i<=n;i++){
		printf("%d\n",col[i]);
	}
	return 0;
};

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k%2==0){
		cout<<a-b<<endl;
	}else{
		cout<<b-a<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
void solve()
{
	string s;
	cin >> s;
	vector<int> v;
	int cnt=0; 
	for(int i=0; i<(int)s.size(); ++i)
	{
		if(s[i]=='R')
		{
			while(s[i]=='R' && i<(int)s.size())
			{
				++cnt;
				++i;
			}
			v.push_back(cnt);
			cnt=0;
		}
	}
	if((int)v.size()==0) cout << 0 << endl;
	else cout << *max_element(v.begin(), v.end()) << endl;
}
int main()
{
	int t=1;
	//cin >> t;
	while(t--) solve();
	return 0; 
}

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

int main() {
  int N, a = 0;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A.at(i);
    if (A.at(i) % 2 == 1) a++;
  }
  if (a % 2) cout << "NO" << endl;
  else cout << "YES" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const long long mod = 1e18;

int main(){
    long long N;
    cin >> N;
    vector<long long> A(N);
    for(long long i=0; i<N; ++i) cin >> A.at(i);

    sort(A.begin(),A.end());
    long long ans = 1;

    for(long long i=0; i<N; ++i){
        if(A.at(i) == 0){
            ans = 0;
            break;
        }

        if(A.at(i) <= (mod / ans)){
            ans *= A.at(i);
        } else {
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
	int a,b,c;cin>>a>>b>>c;
    int k;cin>>k;
    int cnt=0;
    while(b<=a) {b*=2;cnt++;}
    while(c<=b) {c*=2;cnt++;}
    if(cnt<=k) cout<<"Yes";
    else cout<<"No";
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


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

int main() {
	string S;
	int match[] = {2019, 4, 30};
	cin >> S;
	string str = "";
	string out = "Heisei";
	for (int i = 0, j = 0;; i++) {
		if ('/' == S[i] || S[i] == '\0') {
			int num = atoi(str.c_str());
			switch (j) {
				case 0:
					break;
				case 1:
					if (num > match[j])
						out = "TBD";
					break;
				case 2:
					if (num > match[j])
						out = "TBD";
					break;
			}
			j++;
			str = "";
			if (S[i] == '\0')
				break;
			continue;
		}
		str += S[i];
	}
	cout << out << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n;
	P[] ps;

	void run(){
		sc.useDelimiter(",|\n");
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			ps=new P[n];
			for(int i=0; i<n; i++){
				double x=sc.nextDouble();
				double y=sc.nextDouble();
				ps[i]=new P(x, y);
			}
			solve();
		}
	}

	void solve(){
		Arrays.sort(ps, new Comparator<P>(){
			@Override
			public int compare(P p1, P p2){
				return (int)((p1.x-p2.x)*10000);
			}
		});
		int i=0;
		boolean[] used=new boolean[n];
		int ans=n-1;
		for(int k=0; k<n-1; k++){
			// debug(i, ps[i].x, ps[i].y);
			used[i]=true;
			for(int j=0; j<n; j++){
				if(!used[j]&&check(i, j)){
					i=j;
					ans--;
					break;
				}
			}
		}
		println(""+ans);
	}

	boolean check(int i, int j){
		double a=(ps[j].y-ps[i].y)/(ps[j].x-ps[i].x);
		double b=-a*ps[i].x+ps[i].y;
		TreeSet<Integer> set=new TreeSet<Integer>();
		for(int k=0; k<n; k++){
			if(k!=i&&k!=j){
				int sign=0;
				if(Math.abs(ps[j].x-ps[i].x)<EPS)
					sign=(int)Math.signum(ps[k].x-ps[i].x);
				else
					sign=(int)Math.signum(ps[k].y-(a*ps[k].x+b));
				set.add(sign);
			}
		}
		return set.size()==1;
	}

	class P{
		double x, y;

		P(){
			this(0, 0);
		}

		P(double x, double y){
			this.x=x;
			this.y=y;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

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

#define INF 1e9+1

int main(){
  int N; cin >> N;
  int dp[N+1][3] = {};
  int a,b,c;
  for(int i=0; i<N+1; ++i){
    cin >> a >> b >> c;
    if(i==0){
      dp[i][0] = a;
      dp[i][1] = b;
      dp[i][2] = c;
    }else{
      dp[i][0] = max(dp[i-1][1], dp[i-1][2])+a;
      dp[i][1] = max(dp[i-1][0], dp[i-1][2])+b;
      dp[i][2] = max(dp[i-1][1], dp[i-1][0])+c;
    }
  }
  int ans = max({dp[N-1][0],dp[N-1][1],dp[N-1][2]});
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
x.sort()
y.sort()
if x[-1]<y[0] and x[-1]<Y and X<y[0]:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  int X;
  scanf("%d", &X);
  double L = 100.0;
  double x=0.0;
  double y=0.0;
  double theta=0;
  int count=0;
  double pi=acos(-1);
  while(count==0 || abs(x)>0.001 || abs(y)>0.001){
    x+=L*cos((long long)theta*pi/180.0);
    y+=L*sin((long long)theta*pi/180.0);
    count++;
    theta+=X;
  }
  std::cout << count << std::endl;
  return 0;
}
 

Measured memory_bytes: 3656
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    while(true){
		double x = Integer.valueOf(sc.readLine());
		double h = Integer.valueOf(sc.readLine());
		if(x==0 && h==0)
		    break;
		System.out.println(x*x+2.0*x*Math.sqrt(h*h+(x/2)*(x/2)));
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 9748
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T,class Size=typename vector<T>::size_type>inline auto vector_2d(Size h,Size w,T v){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator,class Pair=typename iterator_traits<RandomAccessIterator>::value_type>inline void sort_pairs_by_second(RandomAccessIterator first,RandomAccessIterator last){sort(first,last,[](const Pair&p1,const Pair&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    string s,t;cin>>s>>t;
    ll ans=t.length();
    for(ll i=0;i<s.length()-t.length()+1;++i){
        ll cnt=0;
        for(ll j=0;j<t.length();++j){
            if(t[j]!=s[i+j])++cnt;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	string S; cin >> S;
	int N = S.length();
	map<char, int> mp;	

	REP(i,N) mp[S[i]]++;

	char ans = ' ';
	for(char a = 'a';a<='z';a++){
		if(mp[a] == 0){
			ans = a;
			break;
		}
	}

	if(ans == ' ') cout << "None" << endl;
	else cout << ans << endl;

	return 0;

}


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


int main() {

	int n;
	cin >> n;
	int* board = new int[n];
	for (int i = 0; i < n; i++) cin >> board[i];

	int ans = 0;

	while (true) {

		bool flag = false;

		for (int i = 0; i < n; i++) {
			if (board[i] % 2) flag = true;
		}

		if (flag) break;

		for (int i = 0; i < n; i++) board[i] /= 2;

		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;
int main()
{
    double ans;
    double a, b, x;
    cin >> a >> b >> x;
    double t = x / a;
    if (t >= a* b / 2) {
        double s = a * b;
        double h = (s - t)*2 / a;
        ans = atan2(h, a);
    }
    else {
        double h = t * 2 / b;
        ans = atan2(b, h);

    }
    cout << setprecision(20);
    cout << ans / (2 * M_PI) * 360;
   
   
    return 0;

}


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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

bool isOK(int index, int key, vector<ll> &a) {
    /*indexが条件を満たすかどうかを判定(今回はkeyよりおおきいか)*/
    if(a[index] > key)
        return true;
    else
        return false;
}

int binary_search(int key, vector<ll> &a) {
    int ng = -1;
    int ok = (int)a.size();
    //okとngの初期値によって最大値だけでなく最小値も求められる.
    //ng=-1の時はkey以上の数値の最小値

    while(abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if(isOK(mid, key, a))
            ok = mid;
        else
            ng = mid;
    }

    return ok;
}

int main() {
    ll n, m, i, j, k;
    string s,t;
    cin >> s >> t;
    vector<vector<ll>> c(27);
    ll ss = s.size();
    ll ts = t.size();
    for(i=0;i<ss;i++){
        c[s[i]-'a'].push_back(i+1);
    }
    ll now = 0;
    ll ret = 0;
    ll flag = 0;
    for(i=0;i<ts;i++){
        if(c[t[i]-'a'].size()>0){
            flag = 1;
        }else {
            cout << -1 << endl;
            return 0;
        }
        ll ch = 0;
        /*for(j=0;j<c[t[i]-'a'].size();j++){
            if(now<c[t[i]-'a'][j]){
                ch = 1;
                now = c[t[i]-'a'][j];
                break;
            }
        }*/
        ch = binary_search(now ,c[t[i]-'a']);
        if(ch == c[t[i]-'a'].size()) {
            now = c[t[i]-'a'][0];
            ret++;
        }else{
            now = c[t[i]-'a'][ch];
        }
        flag = 0;
        //cout << now << endl;
    }
    cout << ret * (ll)ss + now << endl;
    return 0;
}

Measured memory_bytes: 1724
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn grow(l: usize, r: usize, h: u32, hv: &Vec<u32>) -> u32 {
    let mut tmp: usize = 0;
    let mut min: u32 = 111;

    let mut ans: u32 = 0;

    if hv[l] > h {
        tmp = l;
        min = hv[l];
    }
    for i in (l + 1)..r {
        if hv[i - 1] > h && hv[i] <= h {
            ans += min - h + grow(tmp, i, min, hv);
        } else if hv[i] > h {
            if hv[i] < min {
                min = hv[i];
            }
            if hv[i - 1] <= h {
                tmp = i;
                min = hv[i];
            }
        }
    }
    if hv[r - 1] > h {
        ans += min - h + grow(tmp, r, min, hv);
    }
    ans
}

fn main() {
    let n: usize = read();
    let hv: Vec<u32> = read_vec();

    println!("{}", grow(0, n, 0, &hv));
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <algorithm> 
#include <ctime>

#define MaxN 10005
 
using namespace std;
 
FILE *IN,*OUT;

long long N,A,B;

int main()
{
	cin>>N>>A>>B;
	if(A>B)
		cout<<0;
	else if(N==1)
	{
		if(A==B)
			cout<<1;
		else cout<<0;
		
	}
	else if(N==2)
		cout<<1;
	else
	{
		cout<<(N-2)*(B-A)+1;
	}
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String[] line = scanner.nextLine().split(" ");
		int num1 = Integer.parseInt(line[0]);
		int num2 = Integer.parseInt(line[1]);
		
		System.out.println(String.format("%s %s", num1*num2,2*(num1+num2)));
	}
}

Measured memory_bytes: 17204
#include<iostream>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int llint;
int main() {
	int n, m;
	char s[100010], t[100010];
	
	cin >> n >> m;
	cin >> s >> t;
	
	llint n_ = n, m_ = m;
	llint howlong = n_*m_;
	int key;
	while (n_ != 0 && m_ != 0) {
		if (n_ > m_) {
			n_ %= m_;
		}
		else {
			m_ %= n_;
		}
	}
	if (n_ == 0) {
		key = m_;
		howlong /= m_;
	}
	else {
		key = n_;
		howlong /= n_;
	}

	if (s[0] != t[0]) {
		cout << -1 << endl;
	}
	else if (n == m) {
		if (strcmp(s, t) != 0) {
			cout << -1 << endl;
		}
		else {
			cout << howlong << endl;
		}
	}
	else if (n%m == 0) {
		int x = n / m;
		for (int i = 0;i < m;i++) {
			if (s[i*x + 1] != t[i]) {
				cout << -1 << endl;
				break;
			}
			if (i == m - 1) {
				cout << howlong << endl;
			}
		}
	}
	else if (m%n == 0) {
		int x = m / n;
		for (int i = 0;i < n;i++) {
			if (s[i*x + 1] != t[i]) {
				cout << -1 << endl;
				break;
			}
			if (i == n - 1) {
				cout << howlong << endl;
			}
		}
	}
	else if (key != 1) {
		int x = n / key, y = m / key;
		for (int i = 1;i < key;i++) {
			if (s[i*x] != t[i*y]) {
				cout << -1 << endl;
				break;
			}
			if (i == key - 1) {
				cout << howlong << endl;
			}
		}
	}
	else {
		cout << howlong << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int	main(void)
{
  	int	num;
  	char	s[3];
  	
  	num = scanf("%s", s);
 	if (num != 1)
      	return (0);
  
  	if (strcmp(s, "SUN") == 0)
          	printf("7");
  	else if (strcmp(s, "MON") == 0)
          	printf("6");
  	else if (strcmp(s, "TUE") == 0)
          	printf("5");
  	else if (strcmp(s, "WED") == 0)
          	printf("4");
  	else if (strcmp(s, "THU") == 0)
          	printf("3");
  	else if (strcmp(s, "FRI") == 0)
          	printf("2");
  	else if (strcmp(s, "SAT") == 0)
          	printf("1");
    return (0);
}

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

void solve(ll& sum,ll next,ll& ret){
	if(sum*next<=0){
		if(abs(sum)<abs(next)) {
			sum+=next;
			return;
		}
		ll a=abs(sum)+1;
		ll b=abs(a-abs(next));
		if(sum>0){
			next-=b;
			sum+=next;
		}
		else{
			next+=b;
			sum+=next;
		}
		ret+=b;
	}
	else{
		ll a=abs(sum)+1;
		ll b=abs(next)+a;
		if(sum<0){
			next+=b;
		}
		else{
			next-=b;
		}
		ret+=b;
		sum+=next;
	}
}

int main(){
	ll n;cin>>n;
	//case0
	ll sum0=0;
	ll ret0=0;
	//case1
	ll sum=0;
	ll ret=0;
	//case-1
	ll sum2=0;
	ll ret2=0;
	for(ll a=0;a<n;++a){
		ll p=0;cin>>p;
		if(a==0){
			ret+=abs(1-p);
			ret2+=abs(-1-p);
			sum0=p;
			sum=1;
			sum2=-1;
			continue;
		}
		solve(sum0,p,ret0);
		solve(sum,p,ret);
		solve(sum2,p,ret2);
	}
	ll res=min(ret0,min(ret,ret2));
	cout<<res<<endl;
}


Measured memory_bytes: 256
N,K = gets.split.map &:to_i
LRs = K.times.map{ gets.split.map(&:to_i) }

MOD = 998244353

c = 0
event = [0]*N
event[0] = 1
event[1] = -1

N.times do |i|
    c += event[i]
    c %= MOD
    next if c == 0
    LRs.each do |l,r|
        event[i+l] += c if i+l < N
        event[i+r+1] -= c if i+r+1 < N
    end
end

p c % MOD

Measured memory_bytes: 15940
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int INF = 1e9;


int main(){
  int n; cin >> n;
  vector<int> a(n),b(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  ll x=0,y=0;
  rep(i,n){
    if(a[i] > b[i])x += a[i] - b[i];
    else y += (b[i] - a[i])/2;
  }
  cout << (x <= y ? "Yes" : "No") << endl;
}

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

using namespace std;

#define llong long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  string S;
  cin >> S;
  map<char, int> M;
  rep(i, S.size()) {
    ++M[S[i]];
  }

  stl_rep(itr, M) {
    if (itr->second != 2) {
      cout << "No" << endl;
      return 0;
  }
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: str):
    for c in N:
        if c == "7":
            print(YES)
            exit()
    print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = next(tokens)  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

//交换
typedef long long ll;
void swap(int &a , int &b)

{

	int temp;

	temp = a;

	a = b;

	b = temp;

 }
ll sum,ans1,ans2;
bool f;
 //全排列递归算法
int f1[10],f2[10],n,a[10];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        a[i]=i;
    for(int i=1;i<=n;i++)
        scanf("%d",&f1[i]);
    for(int i=1;i<=n;i++)
        scanf("%d",&f2[i]);
   //Perm(a,0,n-1);
   while(next_permutation(a+1, a+n+1))
    {
        sum++;
        f=true;
		for(int i=1 ;i<=n ;i++)
        {
            if(a[i]!=f1[i])  f=false;
             //cout<<list[i];

        } //cout<<endl;
        if(f)   ans1=sum;
        f=true;

        for(int i=1;i<=n;i++)
            if(a[i]!=f2[i])  f=false;
        if(f)  ans2=sum;
    }

    if(ans1<=ans2)  swap(ans1,ans2);
  //  cout<<ans1<<"   "<<ans2<<endl;
    printf("%lld\n",ans1-ans2);
 }


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++)
        cin >> a[i];
    for(int i=n-1; i>=0; i--){
        if(i!=0)
            cout << a[i] << " ";
        else
            cout << a[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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 ll = long long;

const ll mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

ll N, K;

ll gcd( ll a, ll b )
{ return b ? gcd(b,a%b) : a; }

const ll MAX_N = 3000000;

bool used[3000010];
std::vector<ll> primes;

void sieve( ll n )
{
  used[0] = used[1] = true;

  for( ll i = 2; i < n; ++i ) if( !used[i] )
  {
    primes.emplace_back( i );

    used[i] = true;

    for( ll j = i; j < n; j += i )
      used[j] = true;
  }
}

std::map<ll, ll> prime( ll x )
{
  std::map<ll, ll> ret;

  for( ll i = 2; i*i <= x; ++i )
  {
    while( x%i == 0 )
    {
      x /= i;
      ++ret[i];
    }
  }

  if( x != 1 )
    ++ret[x];

  return ret;
}

ll meb( ll x )
{
  auto mp = prime(x);

  ll ret = 1;

  itr(it,mp)
  {
    if( it->second > 1 )
      return 0;
    
    ret *= -1;
  }

  return ret;
}

mint ans;

mint cop[100010], power[100010];

std::vector<ll> divisors( ll x )
{
  std::vector<ll> ret;

  for( ll i = 1; i*i <= x; ++i ) if( x % i == 0 )
  {
    ret.emplace_back( i );

    if( x/i != i )
      ret.emplace_back( i );
  }

  return ret;
}

int main()
{
  std::cin >> N >> K;

  rep( i, K+5 )
    power[i] = mint(i).pow(N);

  for( ll g = K; g >= 1; -- g )
  {
    cop[g] = power[K/g];

    repi( j, 1, K/g )
      cop[g] -= cop[(j+1)*g];

    ans += cop[g]*g;
  }

  std::cout << ans.x << std::endl;

  return 0;
}

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


inline static long long FloorSum(long long n, long long m, long long a, long long b) {
    long long ret=0;
    while(1) {
        if(a >= m) ret += ((n-1)*n*(a/m))>>1,a%=m;
        if(b >= m) ret += n*(b / m),b%=m;
        long long y=(a*n+b)/m, x=(y*m-b);
        if(y==0) return ret;
        ret += (n-(x+a-1)/a)*y;
        b=(a-x%a)%a; swap(a,m); n=y;
    }
}

using ll = long long;
int main() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    int Q; cin >> Q;
    while(Q--){
        ll N,M,A,B; cin >> N >> M >> A >> B;
        cout << FloorSum(N,M,A,B) << "\n";
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long

int n;


int main() {
	int a, b, k;
	cin >> a >> b;
	k = (a + b) / 2;
	if (abs(a - k) == abs(b - k)) {
		cout << k << endl;
		return 0;
	}
	k = 0;
	if (abs(a) == abs(b)) {
		cout << k << endl;
		return 0;
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<cmath>
#include<ctime>
#include<locale>
using namespace std;
long long  t[10][10];
long long  f(long long  a[4])
{
    long long  x=0;
    for(long long  i=0;i<4;i++)x=t[x][a[i]];
    return x;
}
int main()
{

{
    for(long long  i=0;i<10;i++)
        for(long long  j=0;j<10;j++)
            scanf("%ld",&t[i][j]);
    long long s=0;
    for(long long  i=0;i<10000;i++)
    {
        long long  a[4],b[4],k=0;
        a[3]=i%10;
        a[2]=i/10%10;
        a[1]=i/100%10;
        a[0]=i/1000%10;
        long long  x0=f(a);
        for(long long  j=0;j<4&&k==0;j++)
        {
            for(long long  i=0;i<4;i++)b[i]=a[i];
            for(long long  x=0;x<10&&k==0;x++)
            {
                if(a[j]==x)continue;
                b[j]=x;
                if(t[f(b)][x0]==0){s++;k++;}
            }
        }
        for(long j=0;j<10&&k==0;j++)
        {
            if(j==x0)continue;
            if(t[x0][j]==0){s++;k++;}
        }
        for(long long  j=1;j<4&&k==0;j++)
        {
            for(long long  x=0;x<4;x++)b[x]=a[x];
            if(a[j]==a[j-1])continue;
            {long long  x=b[j];b[j]=b[j-1];b[j-1]=x;}
            if(t[f(b)][x0]==0){s++;k++;}
        }
        if(x0!=a[3]&&k==0)
        {
            for(long long  x=0;x<4;x++)b[x]=a[x];
            b[3]=x0;
            if(t[f(b)][a[3]]==0){s++;k++;}
        }
        //cout<<i<<' '<<s<<endl;
    }
    cout<<s<<endl;
}
    return 0;
}

Measured memory_bytes: 3232
n = int(input())

cnt_AC = 0
cnt_WA = 0
cnt_TLE = 0
cnt_RE = 0

for _ in range(n) : 
    result = input()
    if result == "AC" : 
        cnt_AC += 1
    elif result == "WA" : 
        cnt_WA += 1
    elif result == "TLE" : 
        cnt_TLE += 1
    elif result == "RE" : 
        cnt_RE += 1
        
print("AC x", cnt_AC)
print("WA x", cnt_WA)
print("TLE x", cnt_TLE)
print("RE x", cnt_RE)

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

const int inf = 1e9;
const int N = 5e5 + 50;

int n, k, vis[N], a[N], p[N], d[N], Mi[N];
vector<int> g[N];

namespace seg {
# define ls rt << 1
# define rs ls | 1
	int a[N * 4];
	void build(int rt = 1, int l = 1, int r = n) {
		a[rt] = inf;
		if(l == r) return ;
		int mid = l + r >> 1;
		build(ls, l, mid);
		build(rs, mid + 1, r);
	}
	void modify(int rt, int l, int r, int pos, int v) {
		if(l == r) return (void) (a[rt] = v);
		int mid = l + r >> 1;
		if(pos <= mid) modify(ls, l, mid, pos, v);
		else modify(rs, mid + 1, r, pos, v);
		a[rt] = min(a[ls], a[rs]);
	}
	int query(int rt, int l, int r, int ql, int qr) {
		if(l > qr || r < ql) return inf;
		if(l >= ql && r <= qr) return a[rt];
		int mid = l + r >> 1;
		return min(query(ls, l, mid, ql, qr), query(rs, mid + 1, r, ql, qr));
	}
}
void bfs() {
	priority_queue<int, vector<int>, greater<int> > q;
	for(int i = 0; i < (int) g[0].size(); ++i)
		q.push(g[0][i]);
	while(!q.empty()) {
		int u = q.top(); q.pop();
		static int icnt = 0;
		a[++icnt] = u;
		for(int i = 0; i < (int) g[u].size(); ++i) {
			--d[g[u][i]];
			if(!d[g[u][i]]) q.push(g[u][i]);
		}
	}
}

int main() {
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++i)
		scanf("%d", p + i), a[p[i]] = i;
	seg :: build();
	for(int i = n, get; i; --i) {
		get = seg :: query(1, 1, n, a[i], min(n, a[i] + k - 1));
		if(get != inf) {
			++d[a[get]];
			g[a[i]].push_back(a[get]);
		}
		get = seg :: query(1, 1, n, max(1, a[i] - k + 1), a[i]);
		if(get != inf) {
			++d[a[get]];
			g[a[i]].push_back(a[get]);
		}
		seg :: modify(1, 1, n, a[i], i);
	}
	for(int i = 1; i <= n; ++i)
		if(!d[i]) g[0].push_back(i);
	for(int i = 0; i <= n; ++i)
		sort(g[i].begin(), g[i].end());
	bfs();
	for(int i = 1; i <= n; ++i)
		p[a[i]] = i;
	for(int i = 1; i <= n; ++i)
		printf("%d\n", p[i]);
	return 0;
}


Measured memory_bytes: 47872
#include<iostream>
#include<sstream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<queue> 
#include<map>
#include<set>
#include<stack>
#define debug(a) cout << "*" << a << "*" << endl
using namespace std;
typedef long long ll; 
ll a, b, c, d, mx;
ll gcd(ll a, ll b)
{
	return b == 0 ? a : gcd(b, a % b);
}
int main()
{
	while (~scanf("%lld%lld%lld%lld", &a, &b, &c, &d))
	{
		mx = c * d / gcd(max(c, d), min(c, d));
		a--;
		printf("%lld\n", b - a - b / c - b / d + a / c + a / d + b / (mx) - a / (mx));
	}
}

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

const int M = 1e9+7;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin >> n;
    vector<int> a(n);
    int sum = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ans = (ans+(1LL*a[i]*sum)%M)%M;
        sum = (sum+a[i]) % M;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3960
#include <iostream>
using namespace std;
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, h, w; cin >> n >> h >> w;
	cout << (n - h + 1) * (n - w + 1) << '\n';
	return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

const ll mod = 1000000007;

ll modpow(ll b, ll e) {
  ll ans = 1;
  for (; e; b = b * b % mod, e /= 2)
    if (e & 1) ans = ans * b % mod;
  return ans;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n;
  cin >> n;

  vl a(n), b(n);
  rep(i,0,n) cin >> a[i] >> b[i];

  map<pair<ll,ll>, ll> occ;

  vii cnt;
  pii ex = mp(0,0);
  ll ext = 0;
  rep(i,0,n) {
    if (a[i] == b[i] and a[i] == 0) {
      ++ext;
      continue;
    }

    if (a[i] != 0 and b[i] != 0) {
      ll g = __gcd((a[i] < 0 ? -a[i] : a[i]), (b[i] < 0 ? -b[i] : b[i]));
      pair<ll,ll> f = {a[i] / g, b[i] / g};
      if (f.snd < 0) {
        f.fst *= -1;
        f.snd *= -1;
      }
      ++occ[f];
    } else if (a[i] == 0) {
      ++ex.fst;
    } else {
      ++ex.snd;
    }
  }

  set<pair<ll,ll>> done;
  for (auto x: occ) {
    pair<ll,ll> inv = mp(-x.fst.snd, x.fst.fst);
    if (inv.snd < 0) {
      inv.fst *= -1;
      inv.snd *= -1;
    }
    if (done.find(inv) != done.end()) continue;
    done.insert(x.fst);
    cnt.eb(mp(x.snd, occ[inv]));
  }

  ll ans = (modpow(2, ex.fst) + modpow(2, ex.snd) - 1)%mod;
  for (ll i = 0; i < sz(cnt); i++) {
    ans *= (modpow(2, cnt[i].fst) + modpow(2, cnt[i].snd) - 1)%mod;
    ans %= mod;
  }

  ans += ext-1;
  ans %= mod;
  ans += mod;
  ans %= mod;


  cout << ans << '\n';
}

Measured memory_bytes: 46752
w = input()
alp = "abcdefghijklmnopqrstuvwxyz"
ans = 0

for i in alp:
  W = w.count(i)
  if W%2 == 0:
    pass
  else:
    ans += 1
    break
    
if ans == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 2940
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=5e2+50;
const ll mod=1e9+7;
using namespace std;
int dx[]={-1,1,0,0},dy[]={0,0,-1,1},n,p[nmax*nmax],f[nmax][nmax],a[nmax][nmax],x,y,nx,ny,i,j,rs,vl,v[nmax][nmax];
pair<int,int>pr[nmax*nmax];
queue<pair<int,int> >q;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n*n;i++)cin>>p[i];
	for(i=1;i<=n;i++)for(j=1;j<=n;j++)f[i][j]=min(min(i-1,j-1),min(n-i,n-j)),a[i][j]=1,pr[n*(i-1)+j]=mkp(i,j);
	for(i=1;i<=n*n;i++)
	{
		x=pr[p[i]].fr,y=pr[p[i]].sc;
		rs+=f[x][y];
		a[x][y]=0;
		v[x][y]=1;
		q.push(mkp(x,y));
		while(!q.empty())
		{
			x=q.front().fr,y=q.front().sc;
			q.pop();
			vl=f[x][y]+a[x][y];
			for(j=0;j<4;j++)
			{
				nx=x+dx[j],ny=y+dy[j];
				if(nx<1 || nx>n || ny<1 || ny>n || f[nx][ny]<=vl)continue;
				q.push(mkp(nx,ny));
				f[nx][ny]=vl;
			}
		}
	}
	cout<<rs<<endl;
	return 0;
}


Measured memory_bytes: 9720
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	map<string, int> mp;
	rep(i, n) {
		string s;
		cin >> s;
		mp[s]++;
	}
	cout << mp.size() << endl;
}


Measured memory_bytes: 19252
#include <iostream>
#include <string>

int main()
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  
  int n;
  std::cin>>n;
  
  int64_t result=1;
  
  for(;n!=0;n--)
  {
    int64_t a;
    std::cin>>a;
    if(a==0)
    {
      result=0;
      break;
    }
    if(result==-1)
    {
      continue;
    }
    result*=a;
    if(result<=0ll||1000000000000000000ll<result)
    {
      result=-1;
    }
  }
  
  std::cout<<result<<std::endl;
  
  return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
 
int main(void){
	
  char a[1];
  
  scanf("%s",a);
  
  if(a[0]=='a'||a[0]=='i'||a[0]=='u'||a[0]=='e'||a[0]=='o'){
  printf("vowel\n");
  } else {
  printf("consonant\n");
  }
  return 0;
}

Measured memory_bytes: 128
/*やったぜ。　投稿者：変態糞土方 (8月16日（水）07時14分22秒)

昨日の8月15日にいつもの浮浪者のおっさん（60歳）と先日メールくれた汚れ好きの土方のにいちゃん

（45歳）とわし（53歳）の3人で県北にある川の土手の下で盛りあったぜ。

今日は明日が休みなんでコンビニで酒とつまみを買ってから滅多に人が来ない所なんで、

そこでしこたま酒を飲んでからやりはじめたんや。

3人でちんぽ舐めあいながら地下足袋だけになり持って来たいちぢく浣腸を3本ずつ入れあった。

しばらくしたら、けつの穴がひくひくして来るし、糞が出口を求めて腹の中でぐるぐるしている。

浮浪者のおっさんにけつの穴をなめさせながら、兄ちゃんのけつの穴を舐めてたら、

先に兄ちゃんがわしの口に糞をドバーっと出して来た。

それと同時におっさんもわしも糞を出したんや。もう顔中、糞まみれや、

3人で出した糞を手で掬いながらお互いの体にぬりあったり、

糞まみれのちんぽを舐めあって小便で浣腸したりした。ああ～～たまらねえぜ。

しばらくやりまくってから又浣腸をしあうともう気が狂う程気持ちええんじゃ。

浮浪者のおっさんのけつの穴にわしのちんぽを突うずるっ込んでやると

けつの穴が糞と小便でずるずるして気持ちが良い。

にいちゃんもおっさんの口にちんぽ突っ込んで腰をつかって居る。

糞まみれのおっさんのちんぽを掻きながら、思い切り射精したんや。

それからは、もうめちゃくちゃにおっさんと兄ちゃんの糞ちんぽを舐めあい、

糞を塗りあい、二回も男汁を出した。もう一度やりたいぜ。

やはり大勢で糞まみれになると最高やで。こんな、変態親父と糞あそびしないか。

ああ～～早く糞まみれになろうぜ。

岡山の県北であえる奴なら最高や。わしは163*90*53,おっさんは165*75*60、や

糞まみれでやりたいやつ、至急、メールくれや。

土方姿のまま浣腸して、糞だらけでやろうや。*/
#include "bits/stdc++.h"
#include <numeric>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define llMIN numeric_limits<long long>::min()
#define intMIN numeric_limits<int>::min()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
struct meel{
  ll a;
  ll b;

};
bool cmp(const meel &a, const meel &b)
{
    return a.b < b.b;
}
bool cmp2(const meel &a, const meel &b)
{
    return ((float)a.b/(float)a.a) < ((float)b.b/(float)b.a);
}
int main(void){
  ll n,t;
  cin>>n>>t;
  vector<meel> data(n);
  rep(i,n){
    cin>>data[i].a>>data[i].b;
  }
  vll dp(n+1,vl(t,0));//t-1までいける
  vl dp_max(n,0);
  vl dp2_max(n,0);
  rep(i,n){
    rep(j,t){
      dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
      if(j+data[i].a<t){
        dp[i+1][j+data[i].a]=max(dp[i+1][j+data[i].a],dp[i][j]+data[i].b);
      }
    }
  }
  vll dp2(n+1,vl(t,0));//t-1までいける
  rep(i,n){
    rep(j,t){
      dp2[i+1][j]=max(dp2[i][j],dp2[i+1][j]);
      if(j+data[n-1-i].a<t){
        dp2[i+1][j+data[n-1-i].a]=max(dp2[i+1][j+data[n-1-i].a],dp2[i][j]+data[n-1-i].b);
      }
    }
  }
  /*rep(i,n){
    rep(j,t){
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
  rep(i,n){
    rep(j,t){
      cout<<dp2[i][j]<<" ";
    }
    cout<<endl;
  }*/
  ll ansmax=0;
  rep(i,n){
    rep(j,t){
      
      ansmax=max(ansmax,data[i].b+dp[i][j]+dp2[n-1-i][t-1-j]);
    }
  }
  cout<<ansmax<<endl;
  return 0;
}


Measured memory_bytes: 141312
#ifndef ONPC
  #define _FORTIFY_SOURCE 0
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("no-stack-protector")
  #pragma GCC optimize("unroll-loops")
  #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
  #pragma GCC optimize("fast-math")
#endif

#include <bits/stdc++.h>

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << ' ' << y << ' ' << z << '\n';

    return 0;
}


Measured memory_bytes: 256