akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            String s = Integer.toString(i);
            int sum = 0;
            for (int j = 0; j < s.length(); j++) {
                sum += Integer.parseInt(s.substring(j, j + 1));
            }
            if(sum >= a && sum <= b) {
                ans += i;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 38264
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a,b = na()
d = 1 if a%2==0 or b%2==0 else 0
print(['Yes','No'][d])

Measured memory_bytes: 3064
s = input()
if 1 <= int(s[:2]) <= 12:
    if 1 <= int(s[2:]) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= int(s[2:]) <= 12:
        print("YYMM")
    else:
        print("NA")

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	ll l;
	cin >> n >> l;
	ll a[n+1];
	for(int i=1; i<=n; i++) cin >> a[i];

	int idx=0;
	for(int i=1; i<n; i++){
		if(a[i]+a[i+1]>=l) idx=i;
	}
	if(idx==0){
		cout << "Impossible" << endl;
		return 0;
	}

	vector<ll> v;
	v.push_back(idx);
	for(int i=idx-1; i>0; i--) v.push_back(i);
	for(int i=idx+1; i<n; i++) v.push_back(i);
	reverse(v.begin(), v.end());

	cout << "Possible" << endl;
	for(int i=0; i<n-1; i++) cout << v[i] << endl;
	return 0;
}

Measured memory_bytes: 2548
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
a = LIST()
a.sort()
b = sorted(list(set(a)))
c = Counter(a)
lenb = len(b)
d = [0 for _ in range(lenb)]
for i in range(lenb):
    d[i] = c[b[i]] - 1
t = sum(d)

if t % 2 == 1:
    t += 1
print(n - t)

Measured memory_bytes: 23100
alpha2num=lambda c:ord(c)-ord('a')+1

result=(alpha2num(input()))

if result==1:
    print('b')
elif result==2:
    print('c')
elif result==3:
    print('d')
elif result==4:
    print('e')
elif result==5:
    print('f')
elif result==6:
    print('g')
elif result==7:
    print('h')
elif result==8:
    print('i')
elif result==9:
    print('j')
elif result==10:
    print('k')
elif result==11:
    print('l')
elif result==12:
    print('m')
elif result==13:
    print('n')
elif result==14:
    print('o')
elif result==15:
    print('p')
elif result==16:
    print('q')
elif result==17:
    print('r')
elif result==18:
    print('s')
elif result==19:
    print('t')
elif result==20:
    print('u')
elif result==21:
    print('v')
elif result==22:
    print('w')
elif result==23:
    print('x')
elif result==24:
    print('y')
elif result==25:
    print('z')


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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
        const char* c = strchr(na + 1, ',');
        cerr.write(na, c - na) << " : " << arg1 << " , ";
        __f(c + 1, args...);
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)), V.erase(unique(all(V)), V.end())
typedef pair <int,int> pii;
typedef long long LL;
const double pi = acos(-1.0);
const double eps = 1e-9;
const int inf = 1e9;
const long long INF = 1e18;
const int N = 1e5 + 5;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    #ifdef LOCAL
        //freopen("input.txt", "r", stdin);
    #endif // LOCAL
    int t = 1; //cin >> t;
    for (int tc = 1; tc <= t; tc++) {
        LL a, b;
        cin >> a >> b;
        cout << a*b/__gcd(a,b) << endl;
    }
    return 0;
}







Measured memory_bytes: 256
N = int(input())
s = 0
c = 0
for i in range(N):
  x, y = map(int, input().split())
  if x == y:
    s += 1
  else:
    s = 0
  if s >= 3:
    c = 1
if c == 1:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9164
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

struct connect{
    int x, y, edge;
};

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

    int n, m;
    cin >> n >> m;
    bool exist[701][701] = {};
    rep(i, m){
        int a, b;
        cin >> a >> b;
        exist[a][b] = exist[b][a] = true;
    }

    vector<vector<int>> edge(n+1, vector<int>());
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(exist[i][j] || i == j){
                continue;
            }
            edge[i].push_back(j);
        }
    }

    vector<int> mark(n+1);
    stack<P> st;
    int c = 0;
    for(int i = 1; i <= n; i++){
        if(mark[i] != 0){
            continue;
        }
        st.emplace(i, ++c);

        while(not st.empty()){
            int v = st.top().first;
            int col = st.top().second;
            st.pop();

            if(mark[v] != 0){
                if(mark[v] != col){
                    cout << -1 << endl;
                    return 0;
                }
                continue;
            }
            mark[v] = col;

            for(int u : edge[v]){
                st.emplace(u, -col);
            }
        }
    }

    vector<connect> vc(c + 1);
    for(int i = 1; i <= n; i++){
        if(mark[i] > 0){
            vc[mark[i]].x++;
        }else{
            vc[-mark[i]].y++;
        }
        vc[abs(mark[i])].edge += edge[i].size();
    }

    for(int i = 1; i <= c; i++){
        vc[i].edge /= 2;
    }

    map<P, bool> dp;
    dp[{0, 0}] = 0;
    for(int i = 1; i <= c; i++){
        map<P, bool> tmp;
        for(pair<P, bool> pp : dp){
            P p = pp.first;

            P p1 = {p.first + vc[i].x, p.second + vc[i].y};
            P p2 = {p.first + vc[i].y, p.second + vc[i].x};
            tmp[p1] = true;
            tmp[p2] = true;
        }
        dp = tmp;
    }

    int ans = INF;
    for(pair<P, bool> p : dp){
        int tmp = (p.first.first - 1) * p.first.first / 2;
        tmp += (p.first.second - 1) * p.first.second / 2;
        ans = min(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6400
#!/usr/bin/python3

while True:
    n, p = list(map(int, input().split()))
    if n == 0 and p == 0: break

    candidates = [0] * n
    pebbles = p
    i = 0
    while True:
        #print(pebbles," ",candidates)

        if pebbles == 0:
            pebbles = candidates[i]
            candidates[i] = 0
        else:
            pebbles -= 1
            candidates[i] += 1
            if candidates[i] == p:
                break

        i += 1
        if i == n: 
            i = 0
    print(i)

Measured memory_bytes: 6720
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		sc.close();
		out.println(n*n*n);
	}
}


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

int main(){
    
    // 1. 入力情報.
    int N, K, X, Y;
    scanf("%d %d %d %d", &N, &K, &X, &Y);
    
    // 2. 出力.
    printf("%d\n", min(N, K) * X + max(0, N - K) * Y);
    return 0;
    
}

Measured memory_bytes: 3772
# -*- coding: utf-8 -*-

A = set([1,3,5,7,8,10,12])
B = set([4,6,9,11])
C = set([2])

x, y = map(int, input().split())

if x in A and y in A:
    print("Yes")

elif x in B and y in B:
    print("Yes")

elif x in C and y in C:
    print("Yes")

else:
    print("No")

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n;
int hx, hy, dx, dy, cx[21], cy[21];

double dist(double ax, double ay, double bx, double by){
  return sqrt((ax-bx)*(ax-bx) + (ay-by)*(ay-by));
}

int dfs(int c, double t, int x, int y, int *used){
  //  printf("%d %lf %lf %lf\n", c, t, x, y);
  if(c == n) return 1;

  rep(i, n){
    if(used[i]) continue;
    if(t + dist(x, y, cx[i], cy[i]) + EPS > dist(dx, dy, cx[i], cy[i])) return 0;
  }

  rep(i, n){
    if(used[i]) continue;
    double nt = dist(x, y, cx[i], cy[i]);
    //    printf("x:%lf y:%lf nt:%lf\n", x, y, nt);
    //    printf("dx;%lf dy:%lf cx:%lf cy:%lf\n", dx, dy, cx[i], cy[i]);
    //    printf("%lf %lf\n", t + nt + EPS, dist(dx, dy, cx[i], cy[i]));
    if(t + nt + EPS > dist(dx, dy, cx[i], cy[i])) return 0;
    used[i] = 1;
    if(dfs(c+1, t + nt, cx[i], cy[i], used)) return 1;
    used[i] = 0;
  }
  return 0;
}

int main(){
  while(scanf("%d%d%d%d%d", &n, &hx, &hy, &dx, &dy) && n+hx+hy+dx+dy){
    rep(i, n)
      scanf("%d%d", cx+i, cy+i);;

    int used[21];
    memset(used, 0, sizeof(used));
    if(dfs(0, 0, hx, hy, used)) puts("YES");
    else puts("NO");
  }
  return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

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


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

using namespace std;
using ll=long long;

int t;
const int MOD=1e9+7;

void add_self(int &a, int b){
    a+=b;
    if(a>=MOD)a-=MOD;
}

void test_case(){
    int n;
    cin>>n;
    vector<vector<int>>grid(n,vector<int>(n));
    for(int i=0; i<n; i++)for(int j=0; j<n; j++)cin>>grid[i][j];
    vector<int>dp(1<<n); // how many ways to pair __builtin_popcount(i)th boy with b'th bit girl in state i;
    dp[0]=1;
    for(int mask=0; mask<1<<n; mask++){
        int b=__builtin_popcount(mask);
        for(int g=0; g<n; g++){
            int n_mask=mask|(1<<g);
            if(!((1<<g)&mask) && grid[b][g]){
                add_self(dp[n_mask],dp[mask]);
            }
        }
    }

    cout<<dp[(1<<n)-1]<<endl;
}

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

    t=1;
    while(t--){
        test_case();
    }

    return 0;
}

Measured memory_bytes: 11352
#include <bits/stdc++.h>
using namespace std;
bool possible[110];
int n;

int main() {
    cin>>n;
    possible[0] = possible[4] = possible[7] = true;

    for(int i=1;i<=n;i++) {
        if(i-4>=0) possible[i] |= possible[i-4];
        if(i-7>=0) possible[i] |= possible[i-7];
    }
    if(possible[n]) cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int A, B, C;
    std::cin >> A >> B >> C;
    std::cout << ((A + B >= C) ? "Yes" : "No") << std::endl;

    return 0;
}


Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

dp = Array.new(k+1) {[nil, nil]}

(k+1).times do |i|
    2.times do |player|
        a.each do |e|
            break 1 if i < e

            if dp[i-e][player ^ 1] == player
                dp[i][player] = player
                break
            end
        end or next
        dp[i][player] = player ^ 1
    end
end

puts dp[k][0] == 0 ? "First" : "Second"

Measured memory_bytes: 22544
import java.util.*;

public class Main{

	static Scanner s=new Scanner(System.in);
	public static void main(String[] $){
		for(int i=s.nextInt();i>0;--i)
			solve();
	}
	static ArrayDeque<ArrayList<Integer>>stack=new ArrayDeque<>();
	static void solve(){
		Scanner sc=new Scanner(s.next().replaceAll("([^\\d])"," $1 "));
		stack.add(new ArrayList<>());
		do {
			String n=sc.next();
			if(n.equals("[")) {
				stack.push(new ArrayList<>());
			}else if(n.equals("]")) {
				ArrayList<Integer>l=stack.pop();
				int v=l.stream().sorted().mapToInt(o->o).sorted().limit(l.size()/2+1).sum();
				stack.peek().add(v);
			}else {
				stack.peek().add(Integer.parseInt(n)/2+1);
			}
		}while(stack.size()>1);
		System.out.println(stack.pop().get(0));
	}
}


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

int main()
{

int A,B;
cin>>A>>B;
if(A+B >= A-B && A+B >= A*B)
	cout<<A+B;
else if (A-B > A+B && A-B >= A*B)
	cout<<A-B;
else 
	cout<<A*B;

}



Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
int main(){
  int n,i,j,len,count,which,flag;
  char in[1025];
  char data[10][6]={
    {' ',' ',' ',' ',' '},
    {'.',',','!','?',' '},
    {'a','b','c'},
    {'d','e','f'},
    {'g','h','i'},
    {'j','k','l'},
    {'m','n','o'},
    {'p','q','r','s'},
    {'t','u','v'},
    {'w','x','y','z'}
  };
  cin >> n;
  for(i=0;i<n;i++){
    cin >> in;
    len=strlen(in);
    count=-1;
    which=0;
    for(j=0;j<len;j++){
      flag=0;
      if(in[j]=='1') which=1;
      else if(in[j]=='2') which=2;
      else if(in[j]=='3') which=3;
      else if(in[j]=='4') which=4;
      else if(in[j]=='5') which=5;
      else if(in[j]=='6') which=6;
      else if(in[j]=='7') which=7;
      else if(in[j]=='8') which=8;
      else if(in[j]=='9') which=9;
      else{
        if(which==0) continue;
    if(which==1) count%=5;
    else if(which==2||which==3||which==4||which==5||which==6||which==8) count%=3;
    else if(which==7||which==9) count%=4;
    cout << data[which][count];
    flag=1;
        count=-1;
        which=0;
      }
      if(flag==0) count++;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())	//昇順
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())	//降順
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" << v[0]; FOR(i_debug, 1, v.size()){ cout << "," << v[i_debug]; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF 1000000000000000000


using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
	ll N;
    cin>>N;

    vec x(N),y(N);
    REP(i,N){
        cin>>x[i]>>y[i];
    }

    double ans=0;

    REP(i,N-1){
        FOR(j,i+1,N){
            ans+=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
        }
    }

    ans*=2;
    ans/=N;
    cout<<setprecision(100)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
ll dx[4] = {1,0,0,-1};
ll dy[4] = {0,1,-1,0};

#define ARRAY_MAX 100005


int main(){

    int d,e;
    while(cin >> d >> e,d){
        double mini = double(INF);
        for(int i = 0;i <= 100;i++){
            for(int j = 0;j <= 100;j++){
                if(i+j == d){
                    double tmp = abs(sqrt(i*i+j*j)-e);
                    mini = min(tmp,mini);
                }
            }
        }
        cout << mini << endl;
    }



    return 0;
}


Measured memory_bytes: 3252
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end()
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;
using VI = vector<int>;

int main() {
	string a, b, c; CI a >> b >> c;

	CO a[0] << b[0] << c[0] EN;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=5*1e5+5;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin>>n;
	vector<string> v;
	v.pb("a");
	for(int i=2;i<=n;i++)
	{
		vector<string> vv;
		for(auto x:v)
		{
			map<int,int> ma;
			for(int j=0;j<x.size();j++)
			{
				ma[x[j]-'a']=1;
			}
			vector<int> av;
			bool ok=false;
			for(int j=0;j<i;j++)
			{
				if(ma[j])
				{
					av.pb(j);
				}
				else{
					if(!ok)
					{
						// cout<<j;
						av.pb(j);
						ok=true;
					}
				}
			}
			for(auto y:av)
			{
				vv.pb(x+(char)(y+'a'));
			}
		}
		v=vv;
	}
	for(auto x:v)
	{
		cout<<x<<"\n";
	}
}
// aa,ab
// aaa
// aab
// aba
// abb
// abc
// 
// aaaa
// aaab
// aaba
// aabb
// aabc
// abca
// abcb
// abcc
// Don't be afraid to fail. Be afraid not to try.
// "Become grindian instead of greendian" - aryanc403
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

Measured memory_bytes: 11036
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;cin>>s;
  string w[] = {"Sunny", "Cloudy", "Rainy", "Sunny"};
  for (int i=0;i<3;i++) {
    if (s == w[i]) cout << w[i+1] << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
string s[2];
int search(int id){
  int id2 = (id+1)%2;
  int ret=0;
  int a[40004];
  for(int j=(int)s[id2].size()-1;j>-(int)s[id].size();j--){
    memset(a,0,sizeof(a));
    for(int i=0;i<(int)s[id].size();i++){
      if(i+j < 0) continue;
      if(i+j >= (int)s[id2].size()) continue;
      if(s[id][i]==s[id2][i+j]) a[i]=1;
    }
    int co=0;
    for(int i=0;i<(int)s[id].size()+1;i++){
      if(a[i]) co++;
      else{
	ret = max(ret,co);
	co=0;
      }
    }
  }
  return ret;
}
int main(){
  while(cin >> s[0]){
    cin >> s[1];
    printf("%d\n",search(0));
  }
}

Measured memory_bytes: 1364
'use strict';
(function(stdin) {
  var inputs = stdin.toString().trim().split('\n');
  var params = inputs[0].split(' ').map(Number);

  (function(a, b) {
    // ????????????????????????
    console.log(a * b,2*(a+b));

  })(params[0], params[1]);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15528
#include<cstdio>
const long long mod = 1e9+7;
long long x[100005];

long long pow(long long a,long long b){
    long long res = 1;
    while(b){
        if(b&1) res = res*a%mod;
        a = a*a%mod;
        b /= 2;
    }
    return res;
}

long long inv(long long u){ return pow(u,mod-2); }

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) scanf("%lld",&x[i]);
    long long ans = 0;
    long long count = 0;
    long long hold = 1;
    for(int i = 2; i <= n-1; i++) hold = hold*(long long)i%mod;
    //printf("hold = %lld\n",hold);
    for(int i = 1; i <= n-1; i++){
        count = (count + inv(i))%mod;
        //printf("i = %d, time = %lld\n",i,count*hold%mod);
        ans = (ans + count*(x[i+1]-x[i])%mod)%mod;
    }
    printf("%lld\n",ans*hold%mod);
    return 0;
}




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

int main() {
	int n; cin >> n;
	int ans = 1, cnt_max = 0;
	for (int i = n; i > 0; i--) {
		int t = i, cnt = 0;
		while (t % 2 == 0) {
			t /= 2; cnt++;
		}
		if (cnt_max < cnt) {
			cnt_max = cnt;
			ans = i;
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main(void) {
  long long X;
  long long a=100;
  int cnt=0;
  cin >> X;
  
  while(X > a){
    a = a*1.01;
    cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
template<class T> inline int sod_L(T n){
  int res=0;
  while(n){
    res += n%10;
    n /= 10;
  }
  return res;
}
int N;
int main(){
  rd(N);
  if(N%sod_L(N)==0){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N;
// {
//   rd(N);
//   wt( if[N%sod(N)==0, "Yes", "No"] );
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n,m;
  cin >> n >> m;
  vi x(m+1,0);
  vi k(n);
  rep(i,n){
    cin >> k[i];
    rep(j, k[i]){
      ll a;
      cin >> a;
      x[a]++;
    }
  }
  ll count = 0;
  rep(i, m + 1){
    if(x[i]==n){
      count++;
    }
  }
  print(count);
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int K,X,l,r;
int main()
{
	cin>>K>>X;
	l=max(-1000000,X-K+1);
	r=min(1000000,X+K-1);
	for(int i=l;i<=r;i++)
		cout<<i<<" ";
	return 0;
}

Measured memory_bytes: 256
import math

class Vector:
    def __init__(self,x,y):
        self.x = x
        self.y = y
        
    def __add__(self,other):
        return Vector(self.x+other.x,self.y+other.y)
    
    def __sub__(self,other):
        return Vector(self.x-other.x,self.y-other.y)
    
    def __mul__(self,scalar):
        return Vector(self.x*scalar,self.y*scalar)
    def __rmul__(self, scalar):
        return Vector(self.x*scalar,self.y*scalar)
    
   
    def __repr__(self):
        return str([self.x,self.y])
        
    def norm_2(self):
        return dot(self,self)
    
    def norm(self):
        return math.sqrt(self.norm_2())
    
def v_sum(v1,v2):
    return Vector(v1.x+v2.x,v1.y+v2.y) 
def scalar_multi(k,v):
    return Vector(k*v.x,k*v.y)
def v_diff(v1,v2):
    return v_sum(v1,scalar_multi(-1,v2))
    
def dot(vector1,vector2):
    return vector1.x*vector2.x+vector1.y*vector2.y

def cross(vector1,vector2):
    return vector1.x*vector2.y-vector1.y*vector2.x

def polygon_andrew_scan(points):
    u = []
    l = []
    if len(points)<3:
        return points
    points.sort(key = lambda p:p.x+p.y*10**-8)
    
    u.append(points[0])
    u.append(points[1])
    l.append(points[-1])
    l.append(points[-2])
    #from IPython.core.debugger import Pdb;
    #Pdb().set_trace()
    for i in range(2,len(points)):
        while len(u)>1 and cross(u[-2]-u[-1],points[i]-u[-1])<0:
            u.pop()
        u.append(points[i])
    #Pdb().set_trace()
    for i in range(2,len(points)):
        while len(l)>1 and cross(l[-2]-l[-1],points[-i-1]-l[-1])<0:
            l.pop()
        l.append(points[-i-1])
        
    return l[::-1]+u[1:-1][::-1]

n = int(input())
p = []

for i in range(n):
    x,y = map(int,input().split())
    p.append(Vector(x,y))
    
convex_points = polygon_andrew_scan(p)

bottom_l = convex_points[0]
start = 0
for i in range(len(convex_points)):
    if convex_points[i].y < bottom_l.y:
        bottom_l = convex_points[i]
        start = i
    elif convex_points[i].y == bottom_l.y:
        if convex_points[i].x<bottom_l.x:
            bottom_l = comvex_points[i]
            start = i
            
m = len(convex_points)      
print(m)
for i in range(start,start+m):
    print('{} {}'.format(convex_points[i%m].x,convex_points[i%m].y))


Measured memory_bytes: 33232
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N;cin>>N;
  vector<string> s(N);

  rep(i,N) cin>>s[i];
  rep(i,N){
    sort(s[i].begin(), s[i].end());
  }

  sort(s.begin(), s.end());

  ll ans = 0;
  vector<ll> v;
  ll tmp = 0;
  rep(i,N-1){
    if(s[i]==s[i+1]){
      tmp++;
    }
    else{
      if(tmp>0){
        v.pb(tmp+1);
        tmp = 0;
      }
      else continue;
    }
  }
  if(tmp>0) v.pb(tmp+1);
  rep(i,v.size()){
    // cout<<v[i]<<" ";
    if(v[i] == 1) continue;
    else{
      ans += v[i]*(v[i]-1)/2;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array)
#define inin freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

int main(){
    //inin
    IOS
    ll n,k;
    cin>>n>>k;
    ll a[n+1];
    FOR(i,1,n) cin>>a[i];

   
   
    ll tmp=1;
    ll cnt=0;
    ll visited[n+1];
    FOR(i,1,n) visited[i]=0;
    //visited[1]=1;
    ll start;

    if(k<n){
    	ll start=1;
    	fo(i,k){
    		start=a[start];
    	}
    	cout<<start<<endl;
    	return 0;
    }
    ll id[n+1];
    ll extra;
    ll length;
    FOR(i,1,n){

    	visited[tmp]=1;
    	id[tmp]=cnt;	
    	tmp=a[tmp];
    	cnt++;
    	if(visited[tmp]==1) {start=tmp; extra=id[tmp]; length=cnt-id[tmp]; break;}

    }
    //dbg(cnt);


   k=k-extra;
   k=(k)%length;
    ll ans=start;
    fo(i,k){
    	ans=a[ans];

    }
    cout<<ans<<endl;



}

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


#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n,m,i,j,a=2;

main() {
    cin >> n >> m;
    i = min(a,n);
    j = min(a,m);
    if (n==1 && m==1) ct(1)
    else if (n==1 || m==1) ct(max(n,m)-2)
    else ct(n*m-n*j-m*i+i*j)
}


Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    l = int(input().strip())
    result = (l / 3.0) ** 3
    print(result)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include<stdio.h>
int main(void)
{
	long long int n,i,w=1,c=0;
	scanf("%lld",&n);
	for(i=1;i<=n;i++){
		w=w*i;
		w=w%1000000007;
	}
	printf("%lld\n",w);
	return 0;
}	

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int a,b,c,k;
    cin >> a >>b >>c>>k;
    for(int i=0;i<k;i++){
        if(c>b&&b>a){cout<<"Yes"<<endl;
        return 0;
        }

        if(c<=b)c*=2;
        else if(b<=a)b*=2;
        else if(c<=a)c*=2;

    }
    if(c>b&&b>a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
    



Measured memory_bytes: 3632
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<map>
using namespace std;

int main() {
	int N, K;
	unsigned long long A[200005];
	int i, j;
	

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

	for (i = K; i < N ; i++) {
		if(A[i-K]< A[i])cout << "Yes" << endl;
		else cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 5196
#include<bits/stdc++.h>
using namespace std;
double ans=0;
int vis[10],x[10],y[10],n,c[10],num=0;
void dfs(int u,int d){
	if(d==n+1){
		num++;
		for(int i=1;i<n;i++){
			ans+=sqrt((x[c[i+1]]-x[c[i]])*(x[c[i+1]]-x[c[i]])+(y[c[i+1]]-y[c[i]])*(y[c[i+1]]-y[c[i]]));
		}
	}
	for(int i=1;i<=n;i++){
		if(vis[i]) continue;
		vis[i]=1;
		c[d]=i;
		dfs(i,d+1);
		vis[i]=0;
	}
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i]>>y[i];
	}
	for(int i=1;i<=n;i++){
		vis[i]=1;
		c[1]=i;
		dfs(i,2);
		vis[i]=0;
	}
	double t=ans/num;
	printf("%.8f\n",t);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    //input
    int n,m;
    cin >> n >> m;
    int k[50];
    int a[50][50];
    for(int i=0; i<n; i++){
        cin >> k[i];
        for(int j=0; j<k[i]; j++){
            cin >> a[i][j];
        }
    }
    //output
    int flag = 0;
    int cnt = 0;
    for(int i=1; i<=m; i++){
        for(int j=0;j<n;j++){
            for(int l=0;l<k[j];l++){
                if(i==a[j][l]){
                    flag++;
                    break;
                }
            }
        }
        if(flag==n){
            cnt++;
        }
        flag = 0;
    }
    cout << cnt << endl;
}



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

int main(void)
{
	//左右上下に隣接するマスがないときNG
	int h, w;
	cin >> h >> w;
	//定石的に2つ多めにとって禁止エリアにする。
	h+=2; 
	w+=2;
	vector < vector<int>> table;
	table.resize(h);
	for (int i = 0; i < h; i++)
	{
		table[i].resize(w);
		for (int j = 0; j < w; j++)
		{
			table[i][j] = 0;
		}
	}

	char tmp[512];
	for (int i = 0; i < h - 2; i++)
	{
		cin >> tmp;
		for (int j = 0; j < w - 2; j++)
		{
			if (tmp[j] == '#')
			{
				table[i + 1][j + 1] = 1;
			}
		}
	}
	//読み込み終了
	//探索
	bool flag = true;
	for (int i = 1; i < h - 1; i++)
	{
		for (int j = 1; j < w - 1; j++)
		{
			if (table[i][j] == 0)
			{
				//0なら探索しない
				continue;
			}
			if (table[i - 1][j] + table[i + 1][j] + table[i][j + 1] + table[i][j - 1]==0)
			{
				flag = false;
				break;
			}

		}
		if (!flag)
		{
			break;
		}
	}
	if (flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

const string YES = "YES";
const string NO = "NO";

void solve(string A, string B, string C) {
  bool pred = A.back() == B.front() && B.back() == C.front();
  cout << (pred ? YES : NO) << endl;
}

int main() {
  string A;
  cin >> A;
  string B;
  cin >> B;
  string C;
  cin >> C;
  solve(A, B, C);
  return 0;
}


Measured memory_bytes: 256
from copy import copy
n, k = map(int, input().split())
p = list(map(int,input().split()))
c = list(map(int, input().split()))
di = {}
for i in range(n):
    di[i+1] = False
l = 1
cc = 0
per = [] # ループの順番
while cc < n:
    tmp = []
    while True:
        if di[l]:
            break
        else:
            tmp.append(l)
            di[l] = True
            cc += 1
            l = p[l-1]
    per.append(tmp)
    for i in range(n):
        if not di[i+1]:
            l = p[i]
#print(per)
dd = {} # 何個目のループに属するか
for i in range(n):
    dd[i+1] = 0
for i in range(len(per)):
    for j in per[i]:
        dd[j] = i
#print(dd)
su = [] # ループ１週の和
for i in range(len(per)):
    tmp = 0
    for j in per[i]:
        tmp += c[j-1]
    su.append(tmp)
#print(su)
s2 = [] # ループ１週何個か
for i in range(len(per)):
    s2.append(len(per[i]))
#print(s2)
ans = -1*(10**10)
#d2 = {} # per[dd]の中でなんばんめにあるか(0インデックス)
#for i in range(len(per)):
#    for j in range(len(per[i])):
#        d2[per[i][j]] = j
#print(d2)
aa = []
for i in range(n):
    loop = dd[i+1]
    w = i+1
    kk = copy(k)
    if k < s2[loop]:
        tmp = 0
        m = -10**9
        for j in range(k):
            w = p[w-1]
            tmp += c[w-1]
            aa.append(tmp)
    else:
        if su[loop] <= 0:
            tmp = 0
            m = -10**9
            for j in range(n):
                w = p[w-1]
                tmp += c[w-1]
                aa.append(tmp)
        else:
            m_loop = kk // (s2[loop])
            m_loop -= 1
            kk -= m_loop * s2[loop]
            tmp = su[loop]*m_loop
            m = -10**9
            for j in range(kk):
                w = p[w-1]
                tmp += c[w-1]
                if c[w-1] <= 0:
                    continue
                aa.append(tmp)
print(max(aa))


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

using namespace std;

typedef long long ll;

ll solve(ll h, ll w) {
  ll ans = 1e18;
  for (int i = 1; i < h; i++) {
    ll x1 = (h - i) * w, x2, x3;
    x2 = i * (w / 2);
    x3 = i * w - x2;
    ans = min(ans, max(max(x1, x2), x3) - min(min(x1, x2), x3));
    x2 = i / 2 * w;
    x3 = i * w - x2;
    ans = min(ans, max(max(x1, x2), x3) - min(min(x1, x2), x3));
  }
  return ans;
}

int main(int argc, const char *argv[]) {
  ll h, w;
  cin >> h >> w;
  cout << min(solve(h, w), solve(w, h)) << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>
#include<boost/multiprecision/cpp_int.hpp>


using namespace std;
using namespace boost::multiprecision;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A & a, const B & b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A & a, const B & b) { a = max(a, (A)b); };


int main() {
	ll mod = 998244353;
	ll N, K; cin >> N >> K;
	vector<pair<ll, ll>> D(K); REP(i, 0, K) cin >> D[i].first >> D[i].second;
	vector<ll> dp(N + 2); REP(i, 0, N + 2)dp[i] = 0;
	dp[1] = 1;
	dp[2] = -1 % mod + mod;
	ll cur = 0;;
	REP(i, 1, N + 1) {
		cur += dp[i];
		for (auto p : D) {
			ll l = min(i + p.first, N + 1);
			ll r = min(i + p.second, N);
			dp[l] = (dp[l] + cur)%mod;
			dp[r + 1] = ((dp[r + 1] - cur) % mod + mod) % mod;
		}
	}
	ll sum = 0;
	REP(i, 1, N + 1) sum = ((sum + dp[i]) % mod + mod) % mod;
	PRI(sum);
	return 0;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n,k;
	int ans[100];
    cin>>n;
    if (n==0) {
        cout<<n<<endl;
        return 0;
    }
    for(int i=0;;i++) {
        k=pow(-2,i+1);
        if(n%abs(k)==0) ans[i]=0; 
        else {ans[i]=1;n-=pow(-2,i);}
        if(n==0) {
            for(int j=i;j>=0;j--) cout<<ans[j];
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 384
import numpy as np

N, M  = [int(i) for i in input().split()]
A = []
for i in range(N):
    A.append([int(i) for i in input().split()])

A = np.array(A)
B = A[:,1]
A = A[:,0]

#print(N)
#print(M)
#print(A)
#print(B)
x = 0
cost = 0

p = np.argsort(A)
A = A[p]
B = B[p]
#print(A)
#print(B)

i = 0
#print(A)
#print(B)

while x < M:
    # i = np.argmin(A)
        #A = np.delete(A, i)
        #B= np.delete(B, i)
    
    if x + B[i] <= M:
        cost += A[i] * B[i]
        x += B[i]
        i += 1
        #print(A)
        #print(B)
    else:
        cost += A[i] * (M-x)
        x += (M-x)
        i += 1
        #print(A)
        #print(B)


print(cost)

Measured memory_bytes: 31708
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int a[55]={11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1381,1451,1471,1481,1511,1811};
int n;

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

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

using namespace std;

int main(void) {
    string w, t, t0;

    cin >> w;
    int count = 0;
    do {
        cin >> t;
        t0 = t;
        std::transform(t.begin(), t.end(), t.begin(), ::tolower);
        if (t == w) {
            count++;
        }
    } while (t0 != "END_OF_TEXT");

    cout<<count<<endl;
    return 0;
}



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

#define MAX_BIT 60

uint64_t f(uint64_t x, const vector<uint64_t>& a){
    uint64_t sum = 0;
    for (auto& a_i : a){
        sum += a_i ^ x;
    }
    return sum;
}

int main() {
    uint64_t n, k;
    cin >> n >> k;
    vector<vector<int>> a_bit(n);
    vector<uint64_t> a(n);
    for(int i = 0; i < n; i++)
    {   
        a_bit[i].resize(MAX_BIT);
        cin >> a[i];

        for(int j = 0; j < MAX_BIT; j++)
            a_bit[i][j] = (a[i] & ((uint64_t)0x1 << j)) >> j;
    }

    uint64_t result[MAX_BIT] = { 0 };
    uint64_t sum_already_defined = 0;
    for(int i = MAX_BIT - 1; i >= 0; i--){
        if (((uint64_t)0x1 << i) <= (k - sum_already_defined)){
            int count_0 = 0;
            int count_1 = 0;
            for (const auto& a_i : a_bit){
                if (a_i[i] == 0){
                    count_0++;
                }else{
                    count_1++;
                }
            }
            if (count_0 > count_1) {
                result[i] = 1;
                sum_already_defined += (uint64_t)0x1 << i;
            }
        }
    }
    
    uint64_t sum = 0;
    for(int i = 0; i < MAX_BIT; i++){
        sum += result[i] << i;
    }

    cout << f(sum, a) << endl;
    return 0;
}

Measured memory_bytes: 30464
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define maxn 100005
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int n;
char s[5][maxn];
int main()
{
	scanf("%d",&n);
	scanf("%s",s[1]+1);
	scanf("%s",s[2]+1);

	ll ans;
	int ss;

	if(s[1][1]==s[2][1])
		ans=3,ss=2;
	else
		ans=6,ss=3;

	for(int i=ss;i<=n;i++)
	{
		if(s[1][i]==s[2][i])
		{
			if(s[1][i-1]==s[2][i-1])
				ans=(ans*2)%mod;
			else
				ans=(ans*1)%mod;
		}
		else
		{
			if(s[1][i-1]==s[2][i-1])
				ans=(ans*2)%mod;
			else
				ans=(ans*3)%mod;

			i++;
		}
	}
	printf("%lld\n",ans);
}


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

map<const string, const int> mapList =
{
  {"SUN", 7},
  {"MON", 6},
  {"TUE", 5},
  {"WED", 4},
  {"THU", 3},
  {"FRI", 2},
  {"SAT", 1}
};

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

  cout << mapList[S];
  return 0;
}


Measured memory_bytes: 256