akhauriyash/Code-Regression huggingface dataset:
//#define WYS
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i = (a); i >= (b); --i)
#define pb push_back
#define Pll pair<ll,ll>
#define Pii pair<int,int>
#define Plp pair< ll,Pii >
#define Pip pair< int,Pii >
#define Ppp pair< Pii,Pii >
#define x first
#define y second
typedef long long ll;
const int N = 1010;
using namespace std;

int n, m,a,b,c;
int ck(int a,int b,int c)  {
    return (a+b>c&&abs(a-b)<c);
}
int main() {
#ifdef WYS
    freopen("in.txt","r",stdin);
#endif
    scanf("%d%d%d",&a,&b,&c);
    if(a==b&&b==c)puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ":" << x << "\n"
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;

int main () {
	int N, W; cin >> N >> W;
	vector<ll> dp(W + 1); // dp[j] = 重さ合計jでの価値の最大値
	int w, v;
	rep(i, N) {
		cin >> w >> v;
		// debug(w); debug(v);
		for (int j = W; j >= w; j--) dp[j] = max(dp[j], dp[j - w] + v);
		// rep(j, W + 1) cout << dp[j] << " "; cout << endl;
	}
	/*
	ll ans = 0;
	rep(i, W + 1) ans = max(ans, dp[i]);
	cout << ans;
	*/
	cout << dp[W];
}

Measured memory_bytes: 1024
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    long long h;
    cin >> h;
    long long k = log(h) / log(2);
    //cout << pow(2, k+1) - 1 << endl;
    long long ans = pow(2, k+1) - 1;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 384
//
// Created by kuroneko on 2019-07-06.
//

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>

typedef long long ll;
using namespace std;

int main() {
    int x, y, z, k; cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);

    for (int i = 0; i < x; i++) cin >> a[i];
    for (int i = 0; i < y; i++) cin >> b[i];
    for (int i = 0; i < z; i++) cin >> c[i];

    vector<ll> ab;
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            ab.push_back(a[i] + b[j]);
        }
    }
    sort(c.rbegin(), c.rend());
    sort(ab.rbegin(), ab.rend());

    vector<ll> abc;
    for (int i = 0; i < min(k, x*y); i++) {
        for (int j = 0; j < min(k, z); j++) {
            abc.push_back(ab[i] + c[j]);
        }
    }
    sort(abc.rbegin(), abc.rend());
    for (int i = 0; i < k; i++) cout << abc[i] << endl;
    return 0;
}


Measured memory_bytes: 43268
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

H, W = mi()
C = li2(10)
A = li2(H)

for k in range(10):
    for i in range(10):
        for j in range(10):
            C[i][j] = min(C[i][j], C[i][k]+C[k][j])

ans = 0
for i in range(H):
    for j in range(W):
        if abs(A[i][j]) != 1:
            ans += C[A[i][j]][1]

print(ans)

Measured memory_bytes: 40668
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

void check(VVI a){
    int n = a.size(), k = a[0].size();
    REP(i,n) REP(j,k) a[i][j]--;
    VI cnt(n);
    REP(i,n) REP(j,k) cnt[a[i][j]]++;
    REP(i,n) {
        if (cnt[i] != k){
            cout << "wrong" << i << endl;
            return;
        }
    }
    REP(i,n) REP(j,i){
        int c = 0;
        REP(x,k) REP(y,k) if (a[i][x] == a[j][y]) c++;
        if (c != 1){
            cout << "wrong" << endl;
            cout << i << " " << j << endl;
            for (int x : a[i]) cout << x+1 << " ";
            cout << endl;
            for (int x : a[j]) cout << x+1 << " ";
            cout << endl;
            return;
        }
    }
}

int main() {
    int k = 38;
    // k = 6;
    int n = k * (k - 1) + 1;
    int c = k - 1;

    VVI ans;
    REP(i,k){
        VI tmp;
        tmp.push_back(1);
        REP(j,c) tmp.push_back(c*i + j + 2);
        ans.push_back(tmp);
    }

    VI s(c), d(c);
    REP(i,c) s[i] = c*(i+1) + 2;

    // REP(i,c) cout << s[i] << endl;

    FOR(x,2,k){
        REP(i,c){
            VI tmp;
            tmp.push_back(x);
            REP(j,c) tmp.push_back(s[j] + (d[j] + i) % c);
            ans.push_back(tmp);
        }
        REP(i,c){
            d[i] = (d[i] + (i+1)) % c;
        }
    }

    cout << n << " " << k << endl;
    for (VI v : ans){
        for (int x : v) cout << x << " ";
        cout << endl;
    }

    // check(ans);

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

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

    cout << r*r << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sunuke = new Scanner(System.in);
    String pass = sunuke.next();
    
    String p1 = pass.substring(0,1);
    String p2 = pass.substring(1,2);
    String p3 = pass.substring(2,3);
    String p4 = pass.substring(3,4);

    if (p1.equals(p2) || p2.equals(p3) || p3.equals(p4)) {
       System.out.println("Bad");
       }
    else{
       System.out.println("Good");
       }    
  }
}

Measured memory_bytes: 22484
#include <stdio.h>

int main(void)
{
    int n;

    scanf("%d", &n);
    if (n <= 111)
        printf("111\n");
    else if (n <= 222)
        printf("222\n");
    else if (n <= 333)
        printf("333\n");
    else if (n <= 444)
        printf("444\n");
   else if (n <= 555)
        printf("555\n");
    else if (n <= 666)
        printf("666\n");
    else if (n <= 777)
        printf("777\n");
    else if (n <= 888)
        printf("888\n");
    else if (n <= 999)
        printf("999\n");

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

#define POS(i, j) ((j) * (c + 1) + (i))

void run (void) {
  i32 n, c;
  scanf ("%" SCNi32 "%" SCNi32, &n, &c);
  const i32 m = 400;
  i32 *s = (i32 *) calloc ((c + 1) * (m + 1), sizeof (i32));
  const i32 mod = 1000000007;
  for (i32 i = 1; i <= m; ++i) {
    for (i32 j = 0, t = 1; j <= c; ++j, t = (i64) t * i % mod) {
      s[POS(j, i)] = t;
    }
  }
  for (i32 i = 0; i <= c; ++i) {
    for (i32 j = 1; j <= m; ++j) {
      s[POS(i, j)] = (s[POS(i, j)] + s[POS(i, j - 1)]) % mod;
    }
  }
  i32 *a = (i32 *) calloc (2 * n, sizeof (i32));
  i32 *b = a + n;
  for (i32 i = 0; i < 2 * n; ++i) {
    scanf ("%" SCNi32, a + i);
  }
  i32 *dp = (i32 *) calloc (c + 1, sizeof (i32));
  dp[0] = 1;
  for (i32 i = 0; i < n; ++i) {
    for (i32 j = c; j >= 0; --j) {
      i32 local = 0;
      for (i32 k = 0; k <= j; ++k) {
        local = (local + (i64) (s[POS(k, b[i])] + mod - s[POS(k, a[i] - 1)]) * dp[j - k]) % mod;
      }
      dp[j] = local;
    }
  }
  printf ("%" PRIi32 "\n", dp[c]);
}

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


Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long ll;
int fun(ll c,ll n)
{
    ll a=c,result=1;
    while(n>0)
    {
        if(n%2==1)
            result=result*a;
        a=a*a;
        n>>=1;
    }
    return result;
}
int main()
{
   ll a,b;
    while(scanf("%lld%lld",&a,&b)==2)
    {

      if(b>5) b=5;
      ll c=(1900*b+100*(a-b));
      printf("%lld\n",c*fun(2,b));

    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define HSORT(V,n) sort(V,V+n)
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    int ans = 0;
    REP(i,n-1){
        if (s[i] == s[i+1]) ans++;
    }
    cout << min(ans+2*k,n-1) << '\n';
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18;
#define mod 1000000007
//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)

int main(){

    fast;
    int T;
    T=1;
    //cin>>T;
    while(T--){
        int a,b;
        cin>>a>>b;
        cout<<a*b;

    }

}

Measured memory_bytes: 3652
# coding: utf-8
# Your code here!

n,m = [int(i) for i in input().split()]

#a=[]
b=[]
for _ in range(n):
    x,y,z = [int(i) for i in input().split()]
#    a =[x,y,z, x+y+z, x+y-z, x-y+z, x-y-z]
    b.append([x,y,z])

ans=0
b.sort(key=lambda x:x[0]+x[1]+x[2])
#print(b)
c=sum(list(map(sum,b))[:m])
d=sum(list(map(sum,b))[-m:])
#print(c,d)
ans=max(ans,-c,d)

b.sort(key=lambda x:x[0]+x[1]-x[2])
#print(b)
c=sum(list(map(lambda x:x[0]+x[1]-x[2],b))[:m])
d=sum(list(map(lambda x:x[0]+x[1]-x[2],b))[-m:])
#print(c,d)
ans=max(ans,-c,d)

b.sort(key=lambda x:x[0]-x[1]+x[2])
#print(b)
c=sum(list(map(lambda x:x[0]-x[1]+x[2],b))[:m])
d=sum(list(map(lambda x:x[0]-x[1]+x[2],b))[-m:])
#print(c,d)
ans=max(ans,-c,d)

b.sort(key=lambda x:x[0]-x[1]-x[2])
#print(b)
c=sum(list(map(lambda x:x[0]-x[1]-x[2],b))[:m])
d=sum(list(map(lambda x:x[0]-x[1]-x[2],b))[-m:])
#print(c,d)
ans=max(ans,-c,d)

if m == 0:
    print(0)
else:
    print(ans)



Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
bool out(pair<double,string> x,pair<double,string> y) {
	if (x.first > y.first)return true;
	else if (x.first == y.first&&x.second < y.second)return true;
	else return false;
}
int main() {
	int n;
	while (cin >> n,n) {
		vector<pair<double, string>> v;
		string l; double p,a, b, c, d, e, f, s, m;
		for (int i = 0; i < n; i++) {
			cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			double efi = (f * s*m-p) / (a + b + c + m * (d + e));
			v.push_back({ efi,l });
		}
		sort(v.begin(), v.end(),out);
		for (int i = 0; i<n; i++) {
			cout << v[i].second << endl;
		}
		cout << "#" << endl;
	}
	return 0;
}


Measured memory_bytes: 3128
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)



int main(){
  int a;
  cin >> a;
  cout << a + pow(a, 2) + pow(a,3);

}

Measured memory_bytes: 4020
def main():
    a,b,k=map(int,input().split())
    print(make_divisors(gcd(a,b))[k-1])
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors[::-1]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
main()

Measured memory_bytes: 38640
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define fo(i,a,b) for(LL i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
#define max(q,w) ((q)>(w)?(q):(w))
using namespace std;
typedef long long LL;
const int N=1000500,mo=998244353;
int m,n;
LL ans,jc[N],jcn[N];
LL ksm(LL q,int w)
{
    LL ans=1;
    for(;w;w>>=1,q=q*q%mo)if(w&1)ans=ans*q%mo;
    return ans;
}
LL C(int m,int n){return jc[m]*jcn[n]%mo*jcn[m-n]%mo;}
int main()
{
    scanf("%d%d",&n,&m);
    jc[0]=1;fo(i,1,n+m)jc[i]=jc[i-1]*(LL)i%mo;
    jcn[n+m]=ksm(jc[n+m],mo-2);fod(i,m+n-1,0)jcn[i]=jcn[i+1]*(i+1LL)%mo;
    if(n<m)swap(n,m);
    fo(i,1,m)ans=(ans+C(i*2,i)*C(n+m-i*2,m-i)%mo)%mo;
    printf("%lld\n",(ans*ksm(2,mo-2)%mo*ksm(C(m+n,m),mo-2)+n)%mo);
    return 0;
}

Measured memory_bytes: 15872
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	for i := 0; i < n; i++ {
		key := a[i]
		j := i - 1
		for j >= 0 && a[j] > key {
			a[j+1] = a[j]
			j--
		}
		a[j+1] = key
		fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	}
}



Measured memory_bytes: 1272
#include <iostream>

using namespace std;

int main() {
    string s;
    cin >> s;
    bool isAbc = false;
    if (s.find('a') != -1
        && s.find('b') != -1
        && s.find('c') != -1) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

Measured memory_bytes: 256
# デバッグ用
GBN_DEBUG = False
GBN_DEBUG = True
def dprn(s, i):
    if GBN_DEBUG: print(", " + s + " = " + str(i), end = "")
def dprns(s):
    if GBN_DEBUG: print(", " + s, end = "")
def dprni(i):
    if GBN_DEBUG: print(i, end=" ")
def endl(): 
    if GBN_DEBUG: print('')
def puts(s): print(s)

#本体ここから

#S = input()
N = int(input())
#S, T = input().split()
#N, M = map(int, input().split())
s = [input() for _ in range(N)]
#A = list(map(int, input().split()))

M = int(input())
t = [input() for _ in range(M)]

blueSet = set(s) # 青いカードに書かれてる文字の種類
numBlueWord = len(blueSet) # 青いカードに書かれてる文字の種類の数
ans = 0
for i in range(numBlueWord):
    blueWord = blueSet.pop() # setは[]が使えないのね。。。pop()で取り出し
                             # N, M < 100 だし、こんな事をするより
                             # 重複承知で読み込んだリストをそのまま使うほうが
                             # 提出までの時間は早かったりして。
    #print(popBlueWord)
    earn = s.count(blueWord) # blueWord が書かれてる青いカードの枚数
    loss = t.count(blueWord) # blueWord が書かれてる赤いカードの枚数
    ans = max(ans, earn - loss)

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n;
  cin>>n;
  string ans;
  while(n>0)
  {
    int m=(n-1)%26;
    ans+=(m+'a');
    n=(n-m)/26;
  }
  reverse(ans.begin(),ans.end());
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3632
package main

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

var scanner = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 0x100000)
var wtr = bufio.NewWriter(os.Stdout)

// SplitSpace 空白で分割設定
func SplitSpace() {
	scanner.Split(bufio.ScanWords)
}

// NextLine 標準入力から１行読み込む
func NextLine() string {
	scanner.Scan()
	return scanner.Text()
}

// NextInt 標準入力から数値を一つ読み込む
func NextInt() int {
	n, _ := strconv.Atoi(NextLine())
	return n
}

// ReadLine 標準入力から長めの1行を読み込む
func ReadLine() string {
	buf := make([]byte, 0, 0x100000)
	for {
		line, isPrefix, err := rdr.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return string(buf)
}

func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func ChMin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

func ChMax(a *int, b int) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}

//================

func main() {
	SplitSpace()
	n := NextInt()
	a := make([][]int, n)
	dp := make([][]int, n+1)
	for i := 0; i < n; i++ {
		a[i] = []int{NextInt(), NextInt(), NextInt()}
		dp[i] = []int{0, 0, 0}
	}
	dp[n] = []int{0, 0, 0}

	for i := 0; i < n; i++ {
		for abc := 0; abc < 3; abc++ {
			for abcN := 0; abcN < 3; abcN++ {
				if abc != abcN {
					ChMax(&dp[i+1][abcN], dp[i][abc]+a[i][abcN])
				}
			}
		}
	}
	fmt.Println(Max(Max(dp[n][0], dp[n][1]), dp[n][2]))
}


Measured memory_bytes: 12928
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/
#define N 202020
void build(){

}
char c[ N ];
int nxt[ N ][ 26 ] , len , tnxt[ 26 ];
void init(){
  scanf( "%s" , c );
  len = strlen( c );
  for( int i = 0 ; i < 26 ; i ++ )
    tnxt[ i ] = len;
  for( int i = len - 1 ; i >= 0 ; i -- ){
    for( int j = 0 ; j < 26 ; j ++ )
      nxt[ i ][ j ] = tnxt[ j ];
    tnxt[ c[ i ] - 'a' ] = i;
  }
}
int can[ N ];
void solve(){
  set<char> S;
  for( int i = len - 1 ; i >= 0 ; i -- ){
    can[ i ] = can[ i + 1 ];
    S.insert( c[ i ] );
    if( (int)S.size() == 26 ){
      can[ i ] ++;
      S.clear();
    }
  }
  int alen = can[ 0 ] + 1;
  string ans = "";
  int pre = -1;
  for( int j = 0 ; j < alen ; j ++ ){
    for( int i = 0 ; i < 26 ; i ++ ){
      int pp = ( pre == -1 ? tnxt[ i ] : nxt[ pre ][ i ] );
      if( pp >= len ){
        ans += (char)( i + 'a' );
        break;
      }
      //printf( "%d %d %d\n" , j , i , pp );
      if( j + 1 + can[ pp + 1 ] >= alen )
        continue;
      pre = pp;
      ans += (char)( i + 'a' );
      break;
    }
  }
  cout << ans << endl;
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 21504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin>>x;
    if(x%11>6)cout<<x/11*2+2<<endl;
    else if(x%11>0)cout<<x/11*2+1<<endl;
    else cout<<x/11*2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; i>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

int main() {
    fastio;
    ll N;
    cin >> N;
    vector<int> a(N);
    vector<int> b(N);
    rep(i,N) cin >> a[i];
    for (int i=N; i>0; --i) {
        int oe = 0;
        for (int j=i*2; j<=N; j += i) {
            oe += b[j-1];
        }
        oe += a[i-1];
        oe %= 2;
        b[i-1] = oe;
    }
    int m = accumulate(begin(b), end(b), 0);
    cout << m << endl;
    rep(i,N) {
        if (b[i])
            cout << i+1 << endl;
    }
}


Measured memory_bytes: 4788
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <bitset>
#include <assert.h>
using namespace std;
 
typedef long long ll;
#define File  freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define Fast  ios::sync_with_stdio(false); cin.tie(0)
#define pb push_back
 
 
const int N = 2e5, INF = 1e9;
std::vector<int> v[N];
bool ch[N];

void dfs(int u){
	ch[u] = true;
	for(int i = 0; i < v[u].size(); i++){
		if(!ch[v[u][i]])dfs(v[u][i]);
	}
}

int main()
{
	Fast;
	int t = 1;
	//cin >> t;
	int n, m;
	cin >>  n >> m;
	int u, w;
	for(int i = 0; i < m ;i++){
		cin >> u >> w;
		v[u].pb(w);
		v[w].pb(u);
	}
	int ans= 0;
	for(int i = 1; i <= n; i++){
		if(!ch[i]){
			dfs(i);
			ans++;
		}
	}
	cout << ans-1 << "\n";
    
}




Measured memory_bytes: 12060
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  string s;
  cin >> s;
  vector<char> letter(s.length());
  vector<char> letter_c(s.length());
  rep_i(i, s.length()){
    letter[i] = s[i];
    letter_c[i] = s[i];
  }

  // sort_v(letter_c);
  // auto result = unique(letter_c.begin(), letter_c.end());
  // letter_c.erase(result, letter_c.end());

  // char target;
  // vector<int> ind;
  // vector<char>::iterator start = letter.begin();
  // vector<char>::iterator result;
  // rep_i(i, letter_c.size()){
  //   target = letter_c[i];
  //   while(result != letter.end()){
  //     result = find(start, letter.end(), target);
  //   }
  // }
  vector<int> ind;
  vector<int> c;
  char target;
  int min_c = 1000000000;
  rep_i(i, letter_c.size()){
    target = letter_c[i];
    rep_i(v, letter.size()){
      if(letter[v] == target){
        ind.push_back(v);
      }
    }
    if(ind.size() == 1){
      c.push_back(ind.front());
      c.push_back(letter.size() - ind.back() - 1);
    }else{
      c.push_back(ind[0]);
      c.push_back(letter.size() - ind.back() - 1);
      for (int i = 1; i < ind.size(); i++){
        c.push_back(ind[i] - ind[i - 1] - 1);
      }
    }
    int max_ele = *max_element(c.begin(), c.end());
    if( max_ele <= min_c){
      min_c = max_ele;
    }
    c.clear();
    ind.clear();
  }
  cout << min_c << endl;
}

Measured memory_bytes: 256
from typing import List


def dfs(adj_matrix: List[List[int]], vartex: int) -> int:
    global step
    global discover_times
    global finish_times
    if 0 != discover_times[vartex]:
        return 0
    discover_times[vartex] = step

    for col_idx in range(len(adj_matrix)):
        if (0 != adj_matrix[vartex][col_idx]) and (0 == discover_times[col_idx]):
            step += 1
            dfs(adj_matrix, col_idx)

    step += 1
    finish_times[vartex] = step

    return 1


if __name__ == "__main__":
    num_vertices = int(input())
    adj_matrix = [[0] * num_vertices for i in range(num_vertices)]

    for _ in range(num_vertices):
        vertex, _, *adjs = map(lambda x: int(x), input().split())
        for adj in adjs:
            adj_matrix[vertex - 1][adj - 1] = 1

    step = 1
    discover_times = [0] * num_vertices
    finish_times = [0] * num_vertices

    for vartex in range(num_vertices):
        if 1 == dfs(adj_matrix, vartex):
            step += 1

    for vertex, (d, f) in enumerate(zip(discover_times, finish_times)):
        print(f"{vertex + 1} {d} {f}")



Measured memory_bytes: 7356
s=input()
a=int(s[0:2])
b=int(s[2:4])
if ((a<1 or a>12) and (b<1 or b>12)):
	print("NA")
elif (a>=1 and a<=12) and (b>=1 and b <=12):
	print("AMBIGUOUS")
elif a>=1 and a<=12:
	print("MMYY")
else:
	print("YYMM")


Measured memory_bytes: 3060
N=int(input())
Ws=[]
W1=input()
Ws.append(W1)
kotae="Yes"
for i in range(1, N):
    W=input()
    if W not in Ws and W[0]==W1[-1]:
        Ws.append(W)
        W1=W
    else:
        kotae="No"
print(kotae)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i,j,tmpi,N,Alice_sum,Bob_sum,diff;
  int A[101];
  cin >> N;
  for(i = 0; i < N; i++){
  	cin >> A[i];
  }
 
  for(i=0;i<N;i++){
	int tmp = A[0],tmpi = 0;
    for(j = 0;j < N;j++){
      if(A[j] > tmp) {
        tmp = A[j];
        tmpi = j;
      }
    }
    if(i%2 == 0){
      diff += tmp;
    }else{
      diff -= tmp;
    }
    A[tmpi] = 0;
  }

  cout << diff << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll x, k, d;
  cin >> x >> k >> d;
  
  x = abs(x);
  
  if(k < x/d) cout << x-k*d << newl;
  else {
    k -= x/d;
    x %= d;
    if(k%2==1) x = d-x;
    cout << x << newl;
  }
  return 0;
}

Measured memory_bytes: 3580
fn main() {
    let n: usize = read_line_as_value();
    let s: String = read_line_as_value();
    if n % 2 != 0 {
        println!("No");
    } else {
        let sub_len = n / 2;
        if s.get(0..sub_len) == s.get(sub_len..n) {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

fn read_line_as_value<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().parse() {
        Ok(val) => val,
        _ => panic!("error while parsing input: {}", input)
    }
}

Measured memory_bytes: 2104
#include <iostream>
using namespace std;
int main () {
	int m, f, r;
	while (1) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) break;
		else if (m == -1 || f == -1) cout << "F\n";
		else if (m+f >= 80) cout << "A\n";
		else if (m+f >= 65) cout << "B\n";
		else if (m+f >= 50) cout << "C\n";
		else if (m+f >= 30 && r>=50) cout << "C\n";
		else if (m+f >= 30) cout << "D\n";
		else if (m+f < 30) cout << "F\n";
	}
}


Measured memory_bytes: 3024
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

class union_find {
	vector<int> par;
	int find(int a) {
		return par[a] < 0 ? a : par[a] = find(par[a]);
	}
public:
	union_find(int n) : par(n, -1) {}
	bool same(int a, int b) {
		return find(a) == find(b);
	}
	void unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return;
		if (par[a] < par[b]) swap(a, b);
		else if (par[a] == par[b]) par[b]--;
		par[a] = b;
	}
};


int main() {
  LL N, M;
  cin >> N >> M;

  vector<LL> p(N);
  REP(i, N)
  {
    cin >> p[i];
    p[i]--;
  }

  union_find uf(N);

  REP(i,M){
    LL a, b;
    cin >> a >> b;
    uf.unite(a-1, b-1);
  }

  int cnt = 0;

  REP(i, N)
  {
    if(uf.same(i,p[i])){
      cnt++;
    }
  }

  cout << cnt << endl;
}


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

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

  int cnt[26];
  for (int i = 0; i < 26; i++)
  {
    cnt[i] = 0;
  }

  for (int i = 0; i < 4; i++)
  {
    cnt[S[i] - 'A']++;
  }

  int flag = 0;
  for (int i = 0; i < 26; i++)
  {
    if (cnt[i] == 2)
      flag++;
  }

  if (flag == 2)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>


using namespace std;

const int N = 10;
char a[N][N];
int n, m;
vector< pair<int, int> > v;

int main()
{
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
			if (a[i][j] == '#')
			{
				v.push_back({i, j});
			}
		}
	}
	sort(v.begin(), v.end());
	for (int i = 1 ; i < v.size(); i++)
	{
		if (v[i].second < v[i - 1].second)
		{
			cout << "Impossible";
			exit(0);
		}
	}
	cout << "Possible";




}


 


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 998244353;

int main() {
  ll N,M,Q;cin >> N >> M >>Q;
  vector<string> S(N);
  repeat(i,N) cin >> S[i];
  vector<vll> sumv(N+1,vll(M+1,0));
  vector<vll> sumel(N+1,vll(M+1,0)),sumew(N+1,vll(M+1,0));
  repeat(i,N){
    repeat(j,M){
      sumv[i+1][j+1] = sumv[i+1][j]+(S[i][j]=='1');
      sumel[i+1][j+1] = sumel[i+1][j]+ (j>0&&(S[i][j]=='1')&&(S[i][j-1]=='1'));
      sumew[i+1][j+1] = sumew[i][j+1]+ (i>0&&(S[i][j]=='1')&&(S[i-1][j]=='1'));
    }
  }
  repeat(j,M){
    repeat(i,N){
      sumv[i+1][j+1] += sumv[i][j+1];
      sumel[i+1][j+1] += sumel[i][j+1];
      sumew[i+1][j+1] += sumew[i+1][j];
    }
  }
  repeat(q,Q){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    ll ans=sumv[x2][y2]-sumv[x2][y1-1]-sumv[x1-1][y2]+sumv[x1-1][y1-1];
    //debug(ans);
    ans -= sumel[x2][y2]-sumel[x2][y1]-sumel[x1-1][y2]+sumel[x1-1][y1];
    //debug(ans);
    ans -= sumew[x2][y2]-sumew[x2][y1-1]-sumew[x1][y2]+sumew[x1][y1-1];
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 100480
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int A,B,C;

//解法
void solve() {
	if (A >= B && A >= C) {
		cout << (A * 10 + B + C);
		return;
	}
	if (B >= A && B >= C) {
		cout << (B * 10 + A + C);
		return;
	}
	if (C >= A && C >= B) {
		cout << (C * 10 + A + B);
		return;
	}

	return;
}

int main() {
	//入力
	cin >> A >> B >> C;
	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> H(N);
    ll m = 1e10, M = -1e10;
    Rep (i, N) {
        cin >> H[i];
    }

    string ans = "Yes\n";
    H[0]--;
    Rep (i, N-1) {
        if (H[i+1] - H[i] >= 1) {
            H[i+1]--;
        } else if (H[i+1] - H[i] < 0) {
            ans = "No\n";
        } 
    }

    cout << ans;
}

Measured memory_bytes: 1024
from itertools import accumulate
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[max(0,i) for i in a]

a=[0]+list(accumulate(a))
b=[0]+list(accumulate(b))
s=b[-1]

print(max([max(a[i+k]-a[i],0)+s-b[i+k]+b[i] for i in range(n-k+1)]))

Measured memory_bytes: 18568
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*

 */
int n;

int main(){
  cin >> n;
  cout << "ABC" <<n << endl;

  return 0;
}


Measured memory_bytes: 256
import math

a, b, h, m = list(map(int, input().split()))
short = 2*math.pi*(h+m/60)/12
long = 2*math.pi*m/60
kakudo = min(abs(long-short), 2*math.pi-abs(long-short))

ans = math.sqrt(a**2 + b**2 -2*a*b*math.cos(kakudo))
print(ans)

Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int INF = 1e9;
double temp_start = 100.0;
double temp_end = 0.001; 
int climb_loop = 7000000;
double temp;

int main(){
  int seed = 12345;
  mt19937 eng(seed);
  uniform_real_distribution<> uniform_01;
  normal_distribution<> dist(182.0,70.0);

  // input
  int D;
  cin >> D;
  int c[26];
  rep(i,26) cin >> c[i];
  int s[D+1][26];
  rep(i,D) rep(j,26) cin >> s[i+1][j];
  
  // define parameter
  int last[D+1][26];
  int t[D+1];
  rep(i,D+1) rep(j,26) last[i][j] = 0;
  
  // calculate initial content climbing
  int content = 0;
  for(int day = 1; day <= D; day++) {
    int content_after = -INF;
    int best_kind = 0;
    rep(kind,26) {
      int res = content + s[day][kind];
      rep(j,26) {
        if(j == kind) last[day][j] = day;
        else last[day][j] = last[day-1][j];
        res -= c[j] * (day - last[day][j]);
      }
      if(res > content_after) {
        best_kind = kind;
        content_after = res;
      }
    }
    t[day] = best_kind;
    content = content_after;
    rep(j,26) {
      if(j == t[day]) last[day][j] = day;
      else last[day][j] = last[day-1][j];
    }
  }
   
  // simulated annealing
  rep(x,climb_loop) {
    double gen = dist(eng);
    int d = gen;
    if(d > D) d = D;
    if(d < 0) d = 0;
    int q = eng() % 26;
    if(q != t[d]) {
      temp = temp_start + (temp_end - temp_start)*x/climb_loop;
      int diff = s[d][q] - s[d][t[d]];
      int cur = d;
      while(cur <= D && last[cur][t[d]] == d) {
        diff -= c[t[d]] * (d - last[cur-1][t[d]]);
        last[cur][t[d]] = last[cur-1][t[d]];
        cur++;
      }
      cur = d;
      while(cur <= D && last[cur][q] < d) {
        diff += c[q] * (d - last[cur][q]);
        last[cur][q] = d;
        cur++;
      }
      if(diff > 0 || uniform_01(eng) < exp((double)diff/temp)) {
        t[d] = q;
        content += diff;
      } else {
        int day = d;
        while(day <= D && last[day][t[d]] < d) {
          last[day][t[d]] = d;
          day++;
        }
        day = d;
        while(day <= D && last[day][q] == d) {
          last[day][q] = last[day-1][q];
          day++;
        }
      }
    }
  }
  // output
  for(int day = 1; day <= D; day++) cout << t[day]+1 << endl;
  return 0;
}


Measured memory_bytes: 4360
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int a, b, x, y;

bool inRange(int t, int u, int v) {
	return (u <= t && t <= v);
}

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

	cin >> x >> y;
	int lx = 0, rx = 0;
	int ly = 0, ry = 0;
	int col = 0, turn = 0;

	while(!inRange(x, lx, rx) || !inRange(y, ly, ry)) {
		col = (col + 1) % 3;

		if(turn == 0) rx += ry - ly + 1;   
        if(turn == 1) ry += rx - lx + 1;
        if(turn == 2) lx -= ry - ly + 1;
        if(turn == 3) ly -= rx - lx + 1;
		turn = (turn + 1) % 4;
	}

	cout << col + 1 << endl;
	return 0;
}


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

// r -> P, s -> R, p -> S
int main() {
    int N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    auto score = [&](int i) {
        if (T[i] == 'r') return P;
        else if (T[i] == 's') return R;
        else return S;
    };
    long long res = 0;
    for (int k = 0; k < K; ++k) {
        bool last = false;
        for (int i = k; i < N; i += K) {
            if (i >= K && T[i-K] == T[i] && last) last = false;
            else res += score(i), last = true;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3752
/* exC */

#include<stdio.h>
#define N 1000000007

int main(void){
    int n, num, i, total=0;
    scanf("%d", &n);
    long long a[n], b[n];
    for(i=0; i<n; i++){
        scanf("%d", &num);
        a[i] = num%N;
    }
    for(i=0; i<n; i++){
        if(i==0){
            b[n-i-1]=a[n-i-1]%N;
        }else{
            b[n-i-1]=(b[n-i]+a[n-i-1])%N;
        }
    }

    for(i=0; i<n-1; i++){
        total += (a[i]*b[i+1])%N;
        total %= N;
    }
    printf("%d\n", total);
}


Measured memory_bytes: 4812
import sys
input = lambda: sys.stdin.readline().rstrip()
import bisect

def cumsum(a):
   r = [0]
   for v in a:
      r.append(r[-1] + v)
   return r

n, m, k = map(int, input().split())
a = cumsum(list(map(int, input().split())))
b = cumsum(list(map(int, input().split())))

ans = 0
for a_num, v in enumerate(a):
   tmp = 0
   if k >= v:
      b_num = bisect.bisect_right(b, k - v) - 1
      tmp = a_num + b_num
   ans = max(ans, tmp)
print(ans)




Measured memory_bytes: 119796
a,b,c,x,y = map(int,input().split())

l = a+b-2*c

if l < 0:
    print(a*x+b*y)
else:
    if x>y:
        print(min(c*2*y+a*(x-y), x*2*c))
    else:
        print(min(c*2*x+b*(y-x), y*2*c))


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

long b[51];
long p[51];

long f(int n, long x) {
    if (n == 0) {
        return (x > 0 ? 1 : 0);
    }

    if (x < (b[n - 1] + p[n - 1]) + 2) {
        return f(n - 1, x - 1);
    } else if (x > b[n - 1] + p[n - 1] + 2) {
        return p[n - 1] + 1 + f(n - 1, x - 2 - (b[n - 1] + p[n - 1]));
    } else {
        return p[n - 1] + 1;
    }
}

int main() {
    int n;
    long x;

    cin >> n >> x;

    b[0] = 0;
    p[0] = 1;
    for (int i = 1; i <= n; i++) {
        b[i] = b[i - 1] * 2 + 2;
        p[i] = p[i - 1] * 2 + 1;
    }

    cout << f(n, x) << endl;

    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define print(x) cout<<x<<endl;
typedef long long ll;

int main() {
	int a, b;
	string s;
	cin >> a >> s >> b;
	if (s == "+") { print(a + b); }
	else if (s == "-") { print(a - b); }
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	final static int N = 3;
	public static int[] A;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		A = new int[N];
		int temp;

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}

		if (A[0] > A[1]) {
			temp = A[0];
			A[0] = A[1];
			A[1] = temp;
		}
		if (A[1] > A[2]) {
			temp = A[1];
			A[1] = A[2];
			A[2] = temp;
		}
		if (A[0] > A[1]) {
			temp = A[0];
			A[0] = A[1];
			A[1] = temp;
		}

		System.out.print(A[0]);
		for (int i = 1; i < N; i++) {
			System.out.print(" " + A[i]);
		}
		System.out.println();
	}
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 10e-10;

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    string s;
    int w;
    cin >> s >> w;
    for(int i=0;i<int(s.length());i+=w){
        cout << s[i];
    }
    cout <<"\n";
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  long long int n=0;
  scanf("%lld", &n);

  int tmp=n;
  int sum=0;
  while(tmp>0){
    sum+=tmp%10;
    tmp/=10;
  }

  if(n%sum==0){printf("Yes\n");}
  else{printf("No\n");}

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <cstdlib>
#include <cctype>
#include <random>

using namespace std;

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

  cout << (24-m)+24 << endl;
    
  return 0;
}


Measured memory_bytes: 256
mod = 10**9 + 7
n, a, b = map(int, input().split())
ans = pow(2, n, mod)-1

# a
x = 1
for i in range(n - a + 1, n + 1):
    x = (x*i) % mod
y = 1
for i in range(1, a + 1):
    y = (y*i) % mod

a_ans = x*pow(y, mod-2, mod)

x = 1
for i in range(n - b + 1, n + 1):
    x = (x*i) % mod
y = 1
for i in range(1, b + 1):
    y = (y*i) % mod
b_ans = x*pow(y, mod-2, mod)
print((ans - a_ans - b_ans) % mod)


Measured memory_bytes: 3064
count = 0
n1 = int(input())
s = list(map(int, input().split()))
n2 = int(input())
t = list(map(int, input().split()))
used = []
for tt in t:
  for ss in s:
    if tt == ss and tt not in used:
      used.append(tt)
      count += 1

print(count)


Measured memory_bytes: 6552
#include <iostream>
#include <set>
using namespace std;
const int N = 2002;

int n,k,q,a[N],vis[N];
set<int> st;

int main() 
{
    scanf("%d%d%d",&n,&k,&q);

    for(int i=1;i<=n;i++) {
        scanf("%d", &a[i]);
        st.insert(a[i]);
    }
    int ans = 1e9+7;


    for (auto x: st) {
        for(int i=1;i<=n;i++) {
            vis[i] = 0;
            if (a[i] < x) vis[i] = 1;
        }
        multiset<int> S;
        multiset<int> tmp;

        for(int i=1;i<=n;i++) {
            if (vis[i] == 0) {
                tmp.insert(a[i]);
            } 
            if (vis[i] == 1 || i == n) {
                int c = 0, value = 0;
                int size = tmp.size();
                for(auto y : tmp) {
                    c ++;
                    if (c <= size - k + 1) {
                        S.insert(y); 
                    } else {
                        break;
                    }
                }
                tmp.clear();
            }
        }

        int c = 0, mx = 0;
        for(auto y: S) {
            c++;
            //printf("%d %d\n", c, y);
            if (c == q) {
                mx = y;
                break;
            }
        }
        if (mx) ans = min(ans, mx - x);
        //printf("--------------\n");

    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(10);
}

#define int ll
string C(string a) {
	REP(q, a.length()-1) {
		swap(a[q], a[q + 1]);
	}
	return a;
}
string J(string a) {
	for (int q = a.length() - 1; q >= 1; --q) {
		swap(a[q], a[q - 1]);
	}
	return a;
}
string E(string a) {
	int hoge = (a.length() + 1) / 2;
	for (int q = 0; q < a.length() / 2; ++q) {
		swap(a[q], a[q + hoge]);
	}
	return a;
}
string A(string a) {
	reverse(ALL(a));
	return a;
}

string P(string a) {
	REP(i, a.length()) {
		if (a[i] >= '0' && a[i] <= '9') {
			if (a[i] == '0') {
				a[i] = '0' + 10;
			}
			a[i]--;
		}
	}
	return a;
}

string M(string a) {
	REP(i, a.length()) {
		if (a[i] >= '0' && a[i] <= '9') {
			if (a[i] == '9') {
				a[i] = '0' -1;
			}
			a[i]++;
		}
	}
	return a;
}
void solve() {
	int n;
	cin >> n;
	REP(i, n) {
		string a, b;
		cin >> a >> b;
		for (int i = a.length() - 1; i >= 0; --i) {
			if (a[i] == 'C') {
				b = C(b);
			}
			else if (a[i] == 'J') {
				b = J(b);
			}
			else if (a[i] == 'E') {
				b = E(b);
			}
			else if (a[i] == 'P') {
				b = P(b);
			}
			else if (a[i] == 'A') {
				b = A(b);
			}
			else {
				b = M(b);
			}
		}
		cout << b << endl;
	}
}
#undef int

int main() {
	init();
	solve();
}


Measured memory_bytes: 3136