akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define mod 1000000007
#define inf 9999999999999999ll
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    vi p(n),q(n);
    for(ll i=0;i<n;i++)
        cin>>p[i];
    for(ll i=0;i<n;i++)
        cin>>q[i];
    vi b;
    for(ll i=0;i<n;i++)
    {
        b.pb(i+1);
    }
    vv a;
    do
    {
        a.pb(b);
    }while(next_permutation(b.begin(),b.end()));
    ll in1=0;
    ll in2=0;
    for(ll i=0;i<a.size();i++)
    {
        if(a[i]==p)
            in1=i;
        if(a[i]==q)
            in2=i;
    }
    cout<<abs(in2-in1)<<endl;
}


Measured memory_bytes: 4408
#include<iostream>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define int64 long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int r,g,b,n;
  cin>>r>>g>>b>>n;
  int ans=0;
  rep(i,n/r+1){
    rep(j,n/g+1){
      if((n-r*i-g*j)%b==0 && n>=r*i+g*j){
        ans++;
      }
    }
  }
  cout<<ans;
}


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

#define int ll

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

const int MAX = 1E6 + 100;
int cnt[MAX];
int bad[MAX];
set<int> used;

int32_t main() {
	int n;
	cin >> n;
	vi a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(used.count(a[i])) {
			bad[a[i]] = true;
			continue;
		}
		for(int j = a[i]; j < MAX; j += a[i])
			cnt[j]++;
		used.insert(a[i]);
	}
	int res = 0;
	for(int i = 0; i < n; i++) {
		if(cnt[a[i]] == 1 && !bad[a[i]])
			res++;
	}
	cout << res << '\n';
}


Measured memory_bytes: 28864
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int x, y;
	cin >> x >> y;
	
	int ans = 0;
	if (x == 1) ans += 300000;
	if (x == 2) ans += 200000;
	if (x == 3) ans += 100000;
	if (y == 1) ans += 300000;
	if (y == 2) ans += 200000;
	if (y == 3) ans += 100000;
	if (x == 1 && y == 1) ans += 400000;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>

const int MAX_N = 1e5, A = 1e9 + 7;
int n, m;
int d[30], f[MAX_N + 1], p[MAX_N + 1];

int fac(int x) {
    int cnt = 0;
    for (int i = 1; i * i <= m && x != 1; i++) {
        while (i > 1 && x % i == 0) {
            x /= i;
            d[cnt]++;
        }
        if (d[cnt] > 0) cnt++;
        if ((i + 1) * (i + 1) > m && x != 1) {
            d[cnt++] += 1;
        }
    }
    return cnt;
}

int po(int x, int y) {
    int ans = 1;
    while (y > 0) {
        if (y & 1) ans = static_cast<long>(ans) * x % A;
        x = static_cast<long>(x) * x % A;
        y >>= 1;
    }
    return ans;
}

int main() {
    scanf("%d %d", &n, &m);
    int cnt = fac(m);

    f[0] = 1;
    int n1 = std::max(n, 30);
    for (int i = 1; i <= n1; i++) f[i] = static_cast<long>(f[i - 1]) * i % A;
    p[n1] = po(f[n1], A - 2);
    for (int i = n1; i > 0; i--) p[i - 1] = static_cast<long>(i) * p[i] % A;

    int ans = 1;
    for (int i = 0; i < cnt; i++) {
        int sum = 0;
        for (int j = 0; j < std::min(d[i], n); j++) {
            sum = (static_cast<long>(f[d[i] - 1]) * p[j] % A
                                       * p[d[i] - 1 - j] % A
                                                  * f[n] % A
                                              * p[j + 1] % A
                                          * p[n - j - 1] % A
                                                  + sum) % A;
        }
        ans = static_cast<long>(ans) * sum % A;
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1024
import sys
input=sys.stdin.readline
n,q=map(int, input().split())
*a,=map(int, input().split())
bit=[0]*(n+1)

def add(t,x):
    while t<=n:
        bit[t]+=x
        t+=t&(-t)

def que(t):
    res=0
    while t:
        res+=bit[t]
        t-=t&(-t)
    return res

for i in range(n):
    add(i+1,a[i])


for _ in range(q):
    i,p,x=map(int, input().split())
    if i:
        ans=que(x)-que(p)
        print(ans)
    else:
        add(p+1,x)


Measured memory_bytes: 65204
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int yakusu(int n)
{
    int ans = 0;
    for (int i = 1;i <= n;i++){
        if (n%i == 0){
            ans++;
        }
    }
    return ans;
}

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    int m = 0;
    for (int i = 0;i < s.size();i++){
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            m++;
        }
        else {
            m = 0;
        }
        ans = max(ans,m);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    for0(i,n) for(int i=0;i<n;i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    Sort(s) sort(s.begin(),s.end())
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    nl     "\n"
#define    End    return 0 
#define    gt     greater<int>()
#define    ll     long long int
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    vl     vector<ll>
#define    mod    1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    pi     acos(-1)

int main()
{
MP;
	
    int n,t,m,c=0;
    cin>>n>>t;
    bool p[n+1];
    forn(i,n)p[i]=0;
    while(t--)
    {
        cin>>m;
        int a;
        while(m--)
        {
            cin>>a;
            p[a]=1;
        }
    }
    forn(i,n){
        if(p[i]==0)c++;
    }
    cout<<c;
    
End;
}


Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

const int maxn=2e5+10;
int n,a[maxn];
long long ans;

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()

int main() {
  int n;
  cin>>n;
  vector<double> a(n);
  rep(i,n) cin>>a[i];
  double divisor=0;
  rep(i,n) divisor+=1/a[i];
  cout<<fixed<<setprecision(6)<<1/divisor<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//Optimizations
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
//save time
#define endl '\n'
#define db(x) cerr << "> " << #x << ": " << x << endl
typedef long long ll;
 
//for sorting
#define all(a) a.begin(),a.end()
 
//Constants
#define PI   3.141592653593
#define MOD  1000000007LL
#define EPS  0.000000001
#define INF  0X3f3f3f3f
 
//loops
#define REP(i,n) 	    for(int i=0;i<(n);++i)
#define FOR(i,a,b)      for(int i=(a);i<(b);++i)
#define DFOR(i,a,b)     for(int i=(a);i>=(b);--i)
 
//vectors
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pair<int,int>>
#define vlll vector<pair<ll,ll>>
#define pb 	push_back
 
//pairs
#define pi pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define F first
#define S second
 
//fast I/O
#ifndef _WIN32
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif
#define gc getchar
#define pc putchar
 
//If using cin and cout
#define IOS ios::sync_with_stdio(false)
#define TIE cin.tie(NULL);cout.tie(NULL)
 
//queue
#define di deque<int>
#define dll deque<ll>
#define qi queue<int>
#define PQ priority_queue
 
//general
#define E empty()
 
//Declare all variables and methods needed between this comment and the next one(OCD lol)
const int MAXN=0;
int main(){

    int n ; cin >> n ; 
    vi ar(n);
    REP(i, n){
        cin >> ar[i];
    }
    vi dp(n+2, INT_MAX);
    dp[0] = 0;
    FOR(i,0, n-1){

        dp[i+1] = min(dp[i+1], dp[i] + abs(ar[i]- ar[i+1]));
        dp[i+2] = min(dp[i+2], dp[i] + abs(ar[i]- ar[i+2]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 3972
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000001;
const long long LINF = 1e18;
const int MAX = 510000;

int main() {
	int n;
	
	cin >> n;
	vector<int> a(3*n);
	long long int ans = 0;
	for (int i = 0; i <3* n; i++) {
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		ans += a.at(3*n - 2 - (2 * i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
const int inf=100000;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;
int main() 
{
	int n;
	cin>>n;
	map<string,int> mp;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		mp[s]+=1;
	}
	int ac=mp["AC"];
	int wa=mp["WA"];
	int tle=mp["TLE"];
	int re=mp["RE"];
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re<<endl;
	return 0;
}




Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n;
    cin>>n;
    int a[n+2];
    int cnt=0,c=0;
    a[0]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]<=a[i-1]){
            c++;
           // cout<<a[i-1]<<" "<<a[i]<<" "<<c<<endl;

        }else{

            c=0;
        }
        cnt=max(cnt,c);
        //cout<<a[i]<<" ";
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 640
i = list(map(int, input().split()))
a = i[0]
b = i[1]
c = i[2]

Cans = 0

if a == b:
    Cans += 1
    if b != c:
        Cans += 1

if a != b:
    Cans += 2
    if a != c and b != c:
        Cans += 1

print(Cans)

Measured memory_bytes: 3060
import java.util.Scanner;

/**
 * @author varun on 7/1/2018
 * @project CompetitiveProgramming
 */
public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        if (c >= a && c <= b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#define INF 1000000000
#define MAX_N 300000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<ll> G[MAX_N];
bool used[MAX_N];
ll n,max_l=0;
ll dfs(ll v){
  used[v]=true;
  ll fi=0,se=0,tmp;
  for(auto to:G[v]){
    if(!used[to]){
      tmp = dfs(to);
      if(tmp>=fi){
        se=fi;
        fi=tmp;
      }else if(tmp>=se){
        se = tmp;
      }
    }
  }
  max_l = max(max_l,fi+se);
  return fi+1;
}
signed main(){
  cin >> n;
  ll a[n],b[n];
  fill(used,used+MAX_N,false);
  queue<P> que;
  for(int i=0;i<n-1;i++){
    cin >> a[i]>>b[i];
    a[i]--;
    b[i]--;
    G[a[i]].push_back(b[i]);
    G[b[i]].push_back(a[i]);
  }
  dfs(0);
  if(max_l%3==1){
    cout <<"Second\n";
  }else{
    cout << "First\n";
  }
}


Measured memory_bytes: 25984
num = []
x = []
y = []
for a in range(3000):
    w = sorted(map(int,input().split()))
    if w[0] == 0 and w[1] == 0:
        break
    x += [w[0]]
    y += [w[1]]
    num.append(w)
for i in range(len(num)):
    print(str(x[i]),str(y[i]))



Measured memory_bytes: 6348
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7

def sol():
    N = int(input())
    T = list(map(int, input().split()))
    A = list(map(int, input().split()))

    if T[-1] != A[0]:
        print(0)
        return

    minHeight = [float('inf')] * N
    minHeight[0] = -1
    minHeight[N - 1] = -1

    for i in range(1, N - 1):
        if T[i] > T[i - 1]:
            if T[i] > A[i]:
                print(0)
                return
            minHeight[i] = -1
        if A[i] > A[i + 1]:
            if A[i] > T[i]:
                print(0)
                return
            minHeight[i] = -1
        minHeight[i] = min(minHeight[i], A[i], T[i])

    ans = 1
    for h in minHeight:
        if h == -1:
            continue
        ans = (ans * h) % MOD

    print(ans)

sol()

Measured memory_bytes: 75876
def solve(X, Y):
    from numpy.linalg import solve
    left = [[1, 1], [2, 4]]
    right = [X, Y]
    res = solve(left, right)
    x = res[0]
    y = res[1]

    if x == float(int(x)) and y == float(int(y)) and x >= 0 and y >= 0:
        print('Yes')
    else:
        print('No')
 
X, Y = map(int, open(0).read().split())
solve(X, Y)

Measured memory_bytes: 27496
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Mon Dec 24 15:59:48 2018
//
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	ans := 0
	for i := 0; i < N; i++ {
		var a int
		fmt.Scan(&a)
		ans += a - 1
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
import java.util.*;
import java.lang.Math;

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

        int x1=sc.nextInt();
        int y1=sc.nextInt();
        int x2=sc.nextInt();
        int y2=sc.nextInt();

        int xlen=Math.abs(x1-x2);
        int ylen=Math.abs(y1-y2);
        if(x1<=x2&&y1<=y2){
            System.out.println(""+(x2-ylen)+" "+(y2+xlen)+" "+(x1-ylen)+" "+(y1+xlen));
        }else if(x1<=x2&&y2<=y1){
            System.out.println(""+(x2+ylen)+" "+(y2+xlen)+" "+(x1+ylen)+" "+(y1+xlen));
        }else if(x2<=x1&&y1<=y2){
            System.out.println(""+(x2-ylen)+" "+(y2-xlen)+" "+(x1-ylen)+" "+(y1-xlen));
        }else if(x2<=x1&&y2<=y1){
            System.out.println(""+(x2+ylen)+" "+(y2-xlen)+" "+(x1+ylen)+" "+(y1-xlen));
        }
    }
}

Measured memory_bytes: 25172
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.fractorial", "r", stdin);
	string str = "";
	while (getline (cin, str ) ){
		stringstream ss(str);
		int n;
		ss >> n;
		if (n == 0){
			break;
		} // end if
		int res = 0;
		while (n > 0){
			res += n/5;
			n /= 5;
		} // end while
		cout << res << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
program main
  implicit none
  integer(8) :: n, i, j, q, r, cnt, m
  integer(8), allocatable :: ca(:), cc(:), cq(:), pt(:)
  character(10 ** 5) :: s
  m = 10 ** 9 + 7
  read *, s
  n = len_trim(s)
  allocate (ca(0:n), cc(0:n), cq(0:n), pt(-3:n))
  ca = 0
  cc = 0
  cq = 0
  do i = 1, n
    if (s(i:i) == "A") ca(i) = 1
    if (s(i:i) == "C") cc(i) = 1
    if (s(i:i) == "?") cq(i) = 1
    ca(i) = ca(i) + ca(i - 1)
    cc(i) = cc(i) + cc(i - 1)
    cq(i) = cq(i) + cq(i - 1)
  end do
  q = cq(n)

  call prep_pt()

  cnt = 0
  do j = 2, n - 1
    if (s(j:j) == "A" .or. s(j:j) == "C") cycle
    if (s(j:j) == "?") then
      r = q - 1
    else if (s(j:j) == "B") then
      r = q
    end if
    cnt = cnt + ca(j - 1) * (cc(n) - cc(j)) * pt(r)
    cnt = modulo(cnt, m)
    cnt = cnt + cq(j - 1) * (cc(n) - cc(j)) * pt(r - 1)
    cnt = modulo(cnt, m)
    cnt = cnt + ca(j - 1) * (cq(n) - cq(j)) * pt(r - 1)
    cnt = modulo(cnt, m)
    cnt = cnt + cq(j - 1) * (cq(n) - cq(j)) * pt(r - 2)
    cnt = modulo(cnt, m)
  end do
  print "(i0)", cnt

  contains

  subroutine prep_pt()
    integer(8) :: i
    pt(:) = 0
    pt(0) = 1
    do i = 1, n
      pt(i) = modulo(pt(i - 1) * 3, m)
    end do
  end subroutine prep_pt
end program main


Measured memory_bytes: 3620
import java.util.HashMap;
import java.util.Scanner;

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

                int X = scan.nextInt();
                int N = scan.nextInt();

                HashMap<Integer, Integer> pHash = new HashMap<Integer, Integer>();

                for (int i = 0; i < N; i++) {
                	pHash.put(scan.nextInt(), 1);
                }

                scan.close();

                int distance = 0;
                int temp = X;
                int output = 0;

                while (true) {

                	temp = X - distance;
                	if (!pHash.containsKey(temp)) {
                		output = temp;
                		break;
                	}

                	temp = X + distance;
                	if (!pHash.containsKey(temp)) {
                		output = temp;
                		break;
                	}

                	distance++;

                }

                System.out.println(output);

        }

}

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

using namespace std;

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define sz(s) (int)s.size()

int main() {
    string s;
	string t;
	cin >> s >> t;
	set<char> fs, ft;
	// for (char c : s) fs.insert(c);
	// for (char c : t) ft.insert(c);
	map<char, int> cs, ct;
	for (char c : s) ++cs[c];
	for (char c : t) ++ct[c];
	vector<int> os, ot;
	for (auto it : cs) os.push_back(it.second);
	for (auto it : ct) ot.push_back(it.second);
	sort(os.begin(), os.end());
	sort(ot.begin(), ot.end());
	if (fs == ft && os == ot) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 2e5 + 100;
int n;
char s[N][20];
int a[N];
void nhap()
{
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
        a[i] = strlen(s[i]);
    }
}

void solve()
{
    for (int i = 2; i <= n; i++) {
        if (s[i][0] != s[i - 1][a[i - 1] - 1]) {
            cout << "No";
            return;
        }
        for (int j = 1; j < i; j++) {
            bool kt = true;
            if (a[i] != a[j]) {
                continue;
            }
            for (int k = 0; k < a[i]; k++) {
                if (s[i][k] != s[j][k]) {
                    kt = false;
                }
            }
            if (kt == true) {
                cout << "No";
                return;
            }
        }
    }
    cout << "Yes";
}
int main()
{
    nhap();
    solve();
}


Measured memory_bytes: 256
from collections import deque

class Graph():
    def __init__(self, directed:bool, nord_count:int):
        self.directed = directed
        self.degree = [0 for _ in range(nord_count)]
        self.edges = [[] for _ in range(nord_count)]
        self.edge_count = 0
        self.nord_count = nord_count


    def insert_edge(self, x, y, directed:bool):
        edge = EdgeNode(y=y, weight=None, edge_node = None)
        self.edges[x].append(edge)
        self.degree[x] += 1
        if directed == False:
            self.insert_edge(y, x, True)
        else:
            self.edge_count += 1

    def print_graph(self):
        for i in range(self.nord_count):
            for edge in self.edges[i]:
                print(i, edge.y)

class EdgeNode():
    def __init__(self, y, weight, edge_node):
        self.y = y
        self.weight = weight
        self.edge_node = edge_node

N, M = [int(i) for i in input().split()]
graph = Graph(directed=False, nord_count = N)
for i in range(M):
    A, B  = [int(i) for i in input().split()]
    graph.insert_edge(x=A-1, y=B-1, directed=False)

signpost = [None for _ in range(N)]
found = [False for _ in range(N)]
found[0] = True
current_node = 0
previous_node = 0
queue = deque([[previous_node, current_node]])
while len(queue) != 0:
    previous_node, current_node = queue.popleft()
    signpost[current_node] = previous_node
    for edge in graph.edges[current_node]:
        if found[edge.y] == False:
            found[edge.y] = True
            queue.append([current_node, edge.y])
signpost = signpost[1:]
if None in signpost:
    print('No')
else:
    print('Yes')
    for i in signpost:
        print(i+1)

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

int main() {
  int64_t X;
  cin >> X;
  int year = 0;
  int64_t sum = 100;
  while(sum < X) {
    sum *= 1.01;
    year += 1;
  }
  cout << year << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int a,b;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
//構造体降順
int comp( const void *c1, const void *c2 )
{
  data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.b;   /* b を基準とする */
  int tmp2 = test2.b;
  return tmp2 - tmp1;
}


int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}

int main(){
    int A,B;
    scanf("%d%d",&A,&B);
    char row[A+B+1];
    scanf("%s",row);
    rep(i,A+B+1){
        if(i==A && row[i]!='-'){
            printf("No");
            return 0;
        }else if(i==A && row[i]=='-'){
            ;
        }else if(i!=A && row[i]>='0' && row[i]<='9'){
            ;
        }else{
            printf("No");
            return 0;
        }
    }
    printf("Yes");
}



Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int a, b;
    cin >> a >> b;
    if(a > b) {
        cout << "a > b" << endl;
    } else if(a < b) {
        cout << "a < b" << endl;
    } else {
        cout << "a == b" << endl;
    }
}



Measured memory_bytes: 3056
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
#define mod 1000000007
#define inf 1000000000000000000
#define pii pair<int, pair<int, int>>
const double pi = acos(-1);
const int sz = 200002;
ll n, m, q, k;
int main() {
	io
	int t = 1;
	//cin>>t;
	while(t--) {
		cin>>n;
		vector<ll>a(n);
		for(int i = 0; i < n; i++) {
			cin>>a[i];
		}
		if(n == 1) cout<<0<<endl;
		else {
			sort(a.begin(), a.end(), greater<int>());
			ll maxi1 = a[0], maxi2 = a[1];
			priority_queue<pii>pq;
			ll ans = a[0];
			pq.push({min(a[0], a[1]), {0, 1}});
			for(int i = 2; i < n; i++) {
				auto x = pq.top();
				if(i != 2)
				pq.pop();
				ans += x.first;
				pq.push({min(a[x.second.first], a[i]), {x.second.first, i}});
				pq.push({min(a[x.second.second], a[i]), {x.second.second, i}});
			}
			cout<<ans;
		}
	}
}


Measured memory_bytes: 7896
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char ch[4];
  for(int i=0; i<4; i++){
    cin>>ch[i];
  }
  sort(ch, ch+4);
  if(ch[0]==ch[1] && ch[1]==ch[2] && ch[2]==ch[3])cout<<"No"<<endl;
  else if(ch[0]==ch[1] && ch[2] == ch[3])
       cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main(){
    using namespace std;
    long X;
    cin >> X;
    for(long i{-120}; i <= 120; ++i)for(long j{-120}; j <= 120; ++j)if(i * i * i * i * i - j * j * j * j * j == X){
        cout << i << " " << j << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3600
# from itertools import accumulate
import itertools

N, x, *A = map(int, open(0).read().split())

B = list(itertools.accumulate(sorted(A))) # cumsum
C = list(itertools.accumulate(sorted(A, reverse=True))) # cumsum

if B[-1] == x:
    print(len(A))
elif B[-1] < x:
    x -= B[-1]
    print(N - (len(list(itertools.takewhile(lambda e: e <= x, C))) + 1))
elif x < B[-1]:
    print(len(list(itertools.takewhile(lambda e: e <= x, B))))

Measured memory_bytes: 9116
require 'prime'

n =  10 ** 7
table = Array.new(n+1, false)
Prime.each(n) {|prime| table[prime] = true }
ps = (1..55555).select { |i| i % 5 == 2 && table[i] }

n = gets.to_s.to_i

puts ps[0...n].join(" ")


Measured memory_bytes: 99692
#!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():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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 = 998244353


def solve():
    n,k,a = LI()
    lst = [0]*(k+1)
    lst[-2] = 1
    A = a*pow(100*n,mod-2,mod)
    inv = pow(n,mod-2,mod)

    for i in range(k-1)[::-1]:
        if k > i + n:
            lst[i] = A*(lst[i+1] - lst[i+n+1]) + lst[i+1]
            lst[i] %= mod
        else:
            lst[i] = A*(lst[i+1] - lst[k]) + (n-(k-i)+1)*inv + lst[i+1]
            lst[i] %= mod
    print((lst[0] - lst[1])%mod)
    return


if __name__ == "__main__":
    solve()



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

using namespace std;

int main(){
    int n;
    cin >> n;
    n = n%10;
    if(n == 8 || n == 6 || n == 1 || n == 0)
        cout << "pon\n";
    else if(n == 3)
        cout << "bon\n";
    else
        cout << "hon\n";
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}

ll lcm(ll u, ll v) {
  return u*v/gcd(u,v);
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll a,b,c,n,ans=0;
  cin >> a >> b >> c >> n;
  rep(i,3100){
    rep(j,3100){
      if(n-(a*i+j*b)>=0&&(n-(a*i+j*b))%c==0)ans++;
    }
  }
  printf("%lld",ans);
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N, Y := sc.NextInt(), sc.NextInt()
	for i := 0; i <= N; i++ {
		for j := 0; i+j <= N; j++ {
			k := N - i - j
			if Y == 10000*i+5000*j+1000*k {
				fmt.Println(i, j, k)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#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;

typedef vector<vll> vvll;
int n;
vll a, sa;
vector<vll> dp;

ll rec(int l, int r) {
    if(dp[l][r] >= 0) return dp[l][r];
    if(l == r) return dp[l][r] = 0;
    ll res = INFL;
    for(int i = l; i + 1 <= r; i++) {
        chmin(res, sa[r + 1] - sa[l] + rec(l, i) + rec(i + 1, r));
    }
    return dp[l][r] = res;
}

int main() {
//	cout << fixed << setprecision(15);
    cin >> n;
    a = vll(n);
    rep(i, n) cin >> a[i];
    sa = vll(n + 1);
    rep(i, n) sa[i + 1] = sa[i] + a[i];

    dp = vector<vll>(n, vll(n, -1));
    cout << rec(0, n - 1) << endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    
 
 
  int main(){
    lint n;
    cin>>n;
    lint a[n];
    rep(i,n)cin>>a[i];
    sort(a,a+n,greater<lint>());
    lint ans=0;
    ans+=a[0];
    lint k=n-2;
    rep(i,n-2){
    if(k==0)break;
    lint b=min((lint)2,k);
    ans+=a[i+1]*b;
    k-=b;
    }
    cout<<ans<<endl;
     }
     
 

Measured memory_bytes: 5232
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static bool Solve(int a, int b, int c)
        {
            HashSet<int> mods = new HashSet<int>();

            int value = 0;
            while (true)
            {
                value += a;
                int mod = value % b;
                if (mod == c)
                    return true;
                if (!mods.Add(mod))
                    return false;
            }
        }

        static void Main(string[] args)
        {
            var array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int a = array[0], b = array[1], c = array[2];
            Console.WriteLine(Solve(a, b, c) ? "YES" : "NO");
        }
    }
}

Measured memory_bytes: 13408
#include <cstdio>
#include <algorithm>

#define mod 998244353LL
#define N (200000 + 5) 

typedef long long ll;
struct robot{
    int l, d;
    friend bool operator <(robot a, robot b)
    {
        return a.l < b.l || (a.l == b.l && a.d > b.d);
    }
}a[N];
int p[N], fir[N], nxt[N];
ll f[N];

void dfs(int x)
{
    f[x] = 1LL;
    for(int i = fir[x]; i; i = nxt[i])
    {
        dfs(i);
        f[x] *= f[i] + 1;
        f[x] %= mod;
    }
}

int main()
{
    int n; scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d%d", &a[i].l, &a[i].d);
    std::sort(a + 1, a + n + 1);

    for(int i = 1; i <= n; i++)
    {
        if(i > 1 && a[i].l == a[i - 1].l) continue;
        int tp = i - 1;
        while(tp && a[tp].l + a[tp].d <= a[i].l) tp = p[tp];
        p[i] = tp;
        nxt[i] = fir[tp];
        fir[tp] = i;
    }

    dfs(0);
    printf("%lld\n", f[0]);

    return 0;
}

Measured memory_bytes: 11904
#include <iostream>

using namespace std;

const int MAX_PROCESS = 100000;

struct process{
    char name[10];
    int time;
};

class Queue {
public:
    Queue();
    void enqueue(process x);
    process dequeue();
    bool isEmpty();

private:
    process data[MAX_PROCESS];
    int head;
    int tail;
};

Queue::Queue() {
    head = 0;
    tail = 0;
}

void Queue::enqueue(process x) {
    data[tail] = x;
    tail++;
    if(tail == MAX_PROCESS) tail = 0;
}

process Queue::dequeue() {
    process x = data[head];
    head++;
    if(head == MAX_PROCESS) head = 0;
    return x;
}

bool Queue::isEmpty() {
    return head == tail;
}


int main() {
    Queue Q;

    int n, q;
    process x;
    cin >> n;
    cin >> q;
    for(int i = 0; i < n; i++) {
        cin >> x.name;
        cin >> x.time;
        Q.enqueue(x);
    }

    int t = 0;
    while(!Q.isEmpty()) {
        x = Q.dequeue();
        if(x.time > q) {
            x.time -= q;
            Q.enqueue(x);
            t += q;
        }
        else {
            t += x.time;
            cout << x.name << ' ' << t << endl;
        }
    }
}


Measured memory_bytes: 4672
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{

    ll i,j,k,n,m,c,cnt,s=0,t;
    //vector<ll>v[30];
    vector<ll>v;
    cin>>n>>t;
    for(i=0;i<n;i++)
    {
        cin>>j>>k;
        if(k<=t)
        {
            v.push_back(j);
        }
    }
    sort(v.begin(),v.end());
    if(v.size()==0)
    {
        cout<<"TLE"<<endl;
    }
    else
        cout<<v[0]<<endl;


  
    return 0;
}


Measured memory_bytes: 384
s = input()
n = len(s)-1
ans=0
for i in range(1 << n):
  k=0
  # print(bin(i))
  for j in range(n):
    # print("","j=",j,bin(i>>j),True if (i>>j)&1 else False,s[k:j+1])
    if i>>j&1 == 0:
      continue
    else:
      ans += int(s[k:j+1])
      k=j+1
  ans += int(s[k:])
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

class Main
{
	public static void main ( String[] args ) {
		Scanner sc = new Scanner ( System.in );
		
		int x = 0;
		int y = 0;
		
		while ( true ) {
			x = sc.nextInt ();
			y = sc.nextInt ();
			
			if ( x == 0 && y == 0 ) {
				break;
			}
			
			if ( y < x ) {
				System.out.println ( y + " " + x );
			} else {
				System.out.println ( x + " " + y );
			}
		}
	}
}

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

all_days = []
for _ in range(n):
  day = input()
  day = day.split()
  for i in range(len(day)):
    day[i] = int(day[i])
  all_days.append(day)
  
def vacation(arr):
    dp = [[0,1,2] for i in range(len(arr))]
    dp[0][0] = arr[0][0]
    dp[0][1] = arr[0][1]
    dp[0][2] = arr[0][2]
    
    for i in range(1, len(arr)):
        dp[i][0] = arr[i][0] + max(dp[i-1][1], dp[i-1][2])
        dp[i][1] = arr[i][1] + max(dp[i-1][0], dp[i-1][2])
        dp[i][2] = arr[i][2] + max(dp[i-1][1], dp[i-1][0])
    
    return max(max(dp[-1][0], dp[-1][1]), dp[-1][2])
  
print(vacation(all_days))

Measured memory_bytes: 54628
import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
ok = False
for i, j in itertools.product(range(10), range(10)):
    ok |= i * j == N

if ok:
    print('Yes')
else:
    print('No')


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

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

int H, W, C;
int panel[8][8];
int ans;
int used[8][8];

int dfs2(int x, int y, int c) {
	int ret = 0;
	used[y][x] = 1;	
	for ( int i = 0; i < 4; i++ ) {
		int nx = x+dx[i], ny = y+dy[i];
		if ( nx < 0 || ny < 0 || nx >= W || ny >= H ||
				 used[ny][nx] || panel[ny][nx] != c ) continue;
		ret += dfs2(nx, ny, c); 
	}

	return ret+1;	
}

void dfs3(int x, int y, int c, int d) {
	used[y][x] = 1;
	panel[y][x] = d;	
	for ( int i = 0; i < 4; i++ ) {
		int nx = x+dx[i], ny = y+dy[i];
		if ( nx < 0 || ny < 0 || nx >= W || ny >= H ||
				 used[ny][nx] || panel[ny][nx] != c ) continue;
		dfs3(nx, ny, c, d);		
	}
}

void dfs(int cnt) {
	int tmp[8][8];
	for ( int i = 0; i < H; i++ )
		for ( int j = 0; j < W; j++ )				
			tmp[i][j] = panel[i][j];

	if ( cnt == 5 ) {
		if ( panel[0][0] == C ) {
			fill_n(*used, 8*8, 0);		
			ans = max(ans, dfs2(0, 0, panel[0][0]));
		}
	} else {
		for ( int i = 1; i <= 6; i++ ) {
			//if ( panel[0][0] == i ) continue;
			fill_n(*used, 8*8, 0);		
			dfs3(0, 0, panel[0][0], i);		
			dfs(cnt+1);
			for ( int k = 0; k < H; k++ )
				for ( int j = 0; j < W; j++ )				
					panel[k][j] = tmp[k][j];
		}
	}
	
}

int main() {
	while ( cin >> H >> W >> C, H ) {
		ans = 0;
		for ( int i = 0; i < H; i++ )
			for ( int j = 0; j < W; j++ )				
				cin >> panel[i][j];

		dfs(0);		
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3104
n=int(input())
s=input()
ans=s.count("R")*s.count("G")*s.count("B")
for j in range(n):
  for i in range(j):
    if (k:=2*j-i)<n:
      if s[i]!=s[k]!=s[j]!=s[i]:
        ans-=1   
print(ans)


Measured memory_bytes: 9152
#include <stdio.h>

int main(void) {
	int a, b, arr, i, sum=0;
	scanf("%d %d", &a, &b);
	for(i=0; i<b; i++){
		scanf("%d", &arr);
		sum += arr;
	}
	if(a<=sum)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 128
import std.algorithm, std.conv, std.range, std.stdio, std.string;

alias graph = Graph!(int, size_t);

void main()
{
  auto rd1 = readln.split.to!(size_t[]), n = rd1[0], m = rd1[1], r = rd1[2];
  auto rs = readln.split.to!(size_t[]).map!"a-1".array;
  rs.sort();

  auto g = new int[][](n, n);
  foreach (i; 0..n) {
    g[i][] = graph.inf;
    g[i][i] = 0;
  }

  foreach (_; 0..m) {
    auto rd2 = readln.split, a = rd2[0].to!size_t-1, b = rd2[1].to!size_t-1, c = rd2[2].to!int;
    g[a][b] = g[b][a] = c;
  }

  auto d = graph.floydWarshal(g);

  auto ans = int.max;
  do {
    auto t = 0;
    foreach (i; 0..r-1) t += d[rs[i]][rs[i+1]];
    ans = min(ans, t);
  } while (rs.nextPermutation);

  writeln(ans);
}

template Graph(Wt, Node, Wt _inf = 10 ^^ 9, Node _sent = Node.max)
{
  import std.algorithm, std.array, std.conv;

  const inf = _inf, sent = _sent;

  Wt[][] floydWarshal(Wt[][] g)
  {
    Wt[][] dist;
    Node[][] inter;
    floydWarshal(g, dist, inter);
    return dist;
  }

  void floydWarshal(Wt[][] g, out Wt[][] dist, out Node[][] inter)
  {
    auto n = g.length;
    dist = g.map!(i => i.dup).array;

    inter = new Node[][](n, n);
    foreach (i; 0..n) inter[i][] = sent;

    foreach (k; 0..n)
      foreach (i; 0..n)
        foreach (j; 0..n)
          if (dist[i][j] > dist[i][k] + dist[k][j]) {
            dist[i][j] = dist[i][k] + dist[k][j];
            inter[i][j] = k.to!Node;
          }
  }
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int A, B;
    char op;
    cin >> A >> op >> B;
    if(op == '+') cout << A + B << endl;
    else cout << A - B << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

struct UnionFind {
    vector<int> par, rnk, cnt;

    UnionFind(int N) : par(N), rnk(N), cnt(N) {
        for (int i = 0; i < N; ++i)
            par[i] = i, cnt[i] = 1;
    }

    int root(int x) {
        return par[x] == x ? x : par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    void unite(int x, int y) {
        x = root(x), y = root(y);
        if (x == y)
            return;
        if (rnk[x] < rnk[y])
            swap(x, y);
        if (rnk[x] == rnk[y])
            rnk[x]++;
        cnt[x] += cnt[y];
        par[y] = x;
    }
};

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

    int N, M;
    cin >> N >> M;

    UnionFind uf(N);
    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        A--, B--;
        uf.unite(A, B);
    }

    int ans = 0;
    vector<bool> seen(N);
    for (int i = 0; i < N; ++i) {
        if (seen[uf.root(i)])
            continue;
        ans = max(ans, uf.cnt[uf.root(i)]);
        seen[uf.root(i)] = true;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5540
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template<typename t1, class t2>
void input(t1 count,t2 array) {
	for(t1 i = 0;i < count;i++) {
		cin >> array[i];
	}
}

template<typename t1, class t2>
void output(t1 count,t2 array) {
	for(t1 i = 0;i < count;i++) {
		cout << array[i];
		if(i != count - 1) cout << " ";
	}
	cout << endl;
}

ll n,k,w[100000];

bool isEnough(ll p) {
	ll cur = 0;
	ll count = 1;
	for(ll i = 0;i < n;i++) {
		cur += w[i];
		if(cur > p) {
			count++;
			cur = w[i];
			if(cur > p) return false;
		}
	}
	return count <= k;
}

int main(void) {
	cin >> n >> k;
	input(n,w);
	ll m[2] = {0,100000000000};
	while(m[1] - m[0] > 1) {
		ll t = (m[0] + m[1]) / 2;
		if(isEnough(t)) {
			m[1] = t;
		}
		else {
			m[0] = t + 1;
		}
	}
	if(isEnough(m[0])) m[1] = m[0];
	cout << m[1] << endl;
}



Measured memory_bytes: 3852