akhauriyash/Code-Regression huggingface dataset:
import sys
def s():
 e=sys.stdin.readline
 n,m=map(int,e().split())
 P=[[]for _ in[0]*n]
 C=[0]*n
 k=0
 for _ in[0]*m:
  s,t=map(int,e().split());P[s]+=[t];P[t]+=[s]
 for i in range(n):
  k+=1
  if C[i]<1:
   s=[i];C[i]=k
   while s:
    u=s.pop()
    for v in P[u]:
     if C[v]<1:C[v]=k;s+=[v]
 for _ in[0]*int(e()):
  a,b=map(int,e().split())
  print(['no','yes'][C[a]==C[b]])
if'__main__'==__name__:s()


Measured memory_bytes: 24092
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())

#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7:合同式の法
 
int main(){
    int n;
    cin >> n;

    string s;
    cin >> s;

    REP(i,SIZE(s)){
        s[i] += n;
        if(s[i] > 90){
            s[i] -= 26;
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3596
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"sort"
)

var used [1001][1001][1001]bool

func main() {
	X, Y, Z, K := ReadInt(), ReadInt(), ReadInt(), ReadInt()
	A := ReadInts(X)
	B := ReadInts(Y)
	C := ReadInts(Z)
	sort.Sort(sort.Reverse(sort.IntSlice(A)))
	sort.Sort(sort.Reverse(sort.IntSlice(B)))
	sort.Sort(sort.Reverse(sort.IntSlice(C)))

	q := Heapq{}
	q.push(State{A[0] + B[0] + C[0], 0, 0, 0})
	for q.Len() > 0 && K > 0 {
		now := q.pop()
		if used[now.i][now.j][now.k] {
			continue
		}
		used[now.i][now.j][now.k] = true
		K--
		fmt.Println(now.sum)
		if now.i+1 < X {
			q.push(State{A[now.i+1] + B[now.j] + C[now.k], now.i + 1, now.j, now.k})
		}
		if now.j+1 < Y {
			q.push(State{A[now.i] + B[now.j+1] + C[now.k], now.i, now.j + 1, now.k})
		}
		if now.k+1 < Z {
			q.push(State{A[now.i] + B[now.j] + C[now.k+1], now.i, now.j, now.k + 1})
		}
	}
}

type State struct {
	sum, i, j, k int
}

type Heapq []State

func (q Heapq) Less(i, j int) bool    { return q[i].sum > q[j].sum }
func (q Heapq) Len() int              { return len(q) }
func (q Heapq) Swap(i, j int)         { q[i], q[j] = q[j], q[i] }
func (q *Heapq) Push(x interface{})   { *q = append(*q, x.(State)) }
func (q *Heapq) Pop() (x interface{}) { *q, x = (*q)[:len(*q)-1], (*q)[len(*q)-1]; return }
func (q *Heapq) push(v State)         { heap.Push(q, v) }
func (q *Heapq) pop() State           { return heap.Pop(q).(State) }

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int main(void)
{
	int n,i,j,len,temp,check;
	char st[11];
	int w[41];
	
	while(scanf("%d",&n))
	{
		if(n==0)
		break;
		
		for(i=0;i<n;i++)
		{
			scanf("%s",st);
			len = strlen(st);
			w[i] = len;
		}
		check = 0;
		for(i=0;i<n;i++)
		{
			temp = 0;
			j = i;
			while(1)
			{
				do{
					temp+=w[j];
					j++;
				}while(temp<5);
				if(temp>5)
				break;
				temp = 0;
				do{
					temp+=w[j];
					j++;
				}while(temp<7);
				if(temp>7)
				break;
				temp = 0;
				do{
					temp+=w[j];
					j++;
				}while(temp<5);
				if(temp>5)
				break;
				temp = 0;
				do{
					temp+=w[j];
					j++;
				}while(temp<7);
				if(temp>7)
				break;
				temp = 0;
				do{
					temp+=w[j];
					j++;
				}while(temp<7);
				if(temp>7)
				break;
				check = 1;
				break;
			}
			if(check==1)
			break;
		}
		printf("%d\n",i+1);
	}
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
	vector<string> S(N);
	for(int i=0;i<N;i++){
		cin >> S.at(i);
	}

  int M;
  cin >> M;
	vector<string> T(M);
	for(int i=0;i<M;i++){
		cin >> T.at(i);
	}

	// Nの重複確認
	vector<int> cnt(N,1);
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(i != j && S.at(i) == S.at(j)){
				cnt.at(i)++;
			}
		}
	}

	int max = 0;
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			if(S.at(i) == T.at(j)){
				cnt.at(i) --;
			}
		}
		if(cnt.at(i) > max){
			max = cnt.at(i);
		}
	}
  	cout << max << endl;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=1;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x"=" << x <<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3

#define MAX_N 1000000001

ll solve(ll, ll);

int main(){
	cin.sync_with_stdio(false);
	ll n , s;
	cin >> n >> s;

	cout << solve(n, s) << endl;

	return 0;
}

ll solve(ll n, ll s) {
	if (n == s) return n + 1;

	ll root = pow(n, 1.0/2);

	repl(i, 2, root + 1) {
		ll sum = 0, div = n;
		while(true) {
			sum += div % i;
			div /= i;
			if (div == 0) break;
		}
		if (sum == s) return i;
	}

	repr(i, root + 1) {
		ll b = (n - s) / i + 1;
		if (b < 2) break;
		ll sum = 0, div = n;
		while(true) {
			sum += div % b;
			div /= b;
			if (div == 0) break;
		}
		if (sum == s) return b;
	}

	return -1;
}


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

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 51;
const int mod = (int) 1e9 + 7;

struct mat {
   int r, c;
   vector<vector<ll> > M;
   mat(int rr, int cc) :
         r(rr), c(cc) {
      M.resize(r, vector<ll>(c));
   }
   vector<ll>& operator[](int i) {
      return M[i];
   }
   const vector<ll>& operator[](int i) const {
      return M[i];
   }
};

struct mul {
   int r, c;
   mul(int rr, int cc) {
      r = rr, c = cc;
   }
   mat operator()(const mat&m1, const mat&m2) const {
      mat ret(m1.r, m2.c);
      for (int i = 0; i < m1.r; i++)
         for (int k = 0; k < m1.c; k++)
            for (int j = 0; j < m2.c; j++) {
               ret[i][j] += (m1[i][k] * m2[k][j]) % mod;
               ret[i][j] %= mod;
            }
      return ret;
   }
};

mat identity_element(const mul& m) {
   mat I(m.r, m.c);
   for (int i = 0; i < m.r; i++)
      I[i][i] = 1LL;
   return I;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	int n;
	ll k;
	cin >> n >> k;
	mat M(n, n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> M[i][j];
	M = power(M, k, mul(n, n));
	ll res = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			(res += M[i][j]) %= mod;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 512
import Control.Applicative ((<$>))
import qualified Data.Char as Char

main = do
    w <- getLine
    t <- getContents
    print $ length $ findWord w t

findWord :: String -> String -> [String]
findWord w t = filter (\x -> w == (Char.toLower <$> x)) $ concat $ words <$> lines t

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
ll A,B,a[N];
int n;
bool check(ll x){
	ll s=0;
	for(int i=1;i<=n;i++){
		if(a[i]-B*x<=0) continue;
		s+=(a[i]-B*x+A-B-1)/(A-B);
	}
	return s<=x;
}
int main(){
	scanf("%d%lld%lld",&n,&A,&B);
	for(int i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	ll l=0,r=1e9;
	while(l<=r){
		ll mid=(l+r)>>1;
		if(check(mid)) r=mid-1;
		else l=mid+1;
	}
	printf("%lld\n",l);
	return 0;
}


Measured memory_bytes: 4548
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	int N;
	cin>>N;
	vector<int> S(N);
	rep(i,0,N) cin>>S[i];
	
	ll res=0;
	rep(d,1,N-1) {
		ll sum=0;
		for (int k=1; k*d<N-1; k++) {
			sum+=S[k*d]+S[N-1-k*d];
			int A=N-1-k*d;
			if (A>d && (A%d!=0 || k<A/d)) res=max(res,sum);
		}
	}

	cout<<res<<"\n";
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,x[SZ],p[SZ];
int l[SZ],r[SZ];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",x+i),p[x[i]]=i;
	for(int i=1;i<=n*n;++i)
	{
		if(p[i]) continue;
		int g=0;
		for(int j=1;j<=n;++j)
		{
			if(l[j]==j-1||x[j]<i)
				continue;
			if(!g||x[g]>x[j]) g=j;
		}
		if(g)
		{
			++l[g]; p[i]=g;
			continue;
		}
		for(int j=1;j<=n;++j)
			if(r[j]!=n-j&&x[j]<i)
			{
				p[i]=j; ++r[j]; break;
			}
		if(!p[i])
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	for(int i=1;i<=n*n;++i)
		printf("%d ",p[i]);
}


Measured memory_bytes: 7424
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define maxn 100005
using namespace std;
int n, ans, a[maxn];
int main(void)
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++)
            for (int k = j + 1; k <= n; k++)
                if(a[i]+a[j] > a[k] && a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
                    ans++;
    printf("%d\n", ans);
    //system("pause");
    return 0;
}


Measured memory_bytes: 3764
#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 = 1e9+7;
const int INF = 2e9;
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll a, b;
  cin >> a >> b;
  print(a * b);
}

Measured memory_bytes: 3624
import copy

class card:
    def __init__(self, s):
        self.value = int(s[1:])
        self.mark = s[0]
        self.s = s
    
    def __repr__(self):
        return self.s
        
def isstable(Cin, Cout, n):
    for i in range(n):
        for j in range(i+1, n):
            for a in range(n):
                for b in range(a+1, n):
                    if Cin[i].value==Cin[j].value and Cout[a].s==Cin[j].s and Cout[b].s == Cin[i].s:
                        return False
    return True
    
def BubbleSort(C, N):
    Cin = copy.copy(C)
    for i in range(N):
        for j in range(N-1, i, -1):
            if C[j].value < C[j-1].value:
                C[j], C[j-1] = C[j-1], C[j]
    print(*C)

    if isstable(Cin, C, N):
        print('Stable')
    else:
        print('Not stable')

def SelectionSort(C,N):
    Cin = copy.copy(C)
    for i in range(N):
        minj = i
        for j in range(i, N):
            if C[j].value < C[minj].value:
                minj = j
        if minj!=i:
            C[i], C[minj] = C[minj], C[i]

    print(*C)
    if isstable(Cin, C, N):
        print('Stable')
    else:
        print('Not stable')

N = int(input())
C = list(map(card, input().split()))

#N = 5
#C = list(map(card, ['H4', 'C9', 'S4', 'D2', 'C3']))
BubbleSort(copy.copy(C), N)
SelectionSort(copy.copy(C), N)




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

int a[200010];

int main() {
	int N;
	cin >> N;
	int xsum=0;
	for(int i=0; i<N; ++i){
		cin >> a[i];
		xsum ^= a[i];
	}
	cout << (xsum^a[0]);
	for(int i=1; i<N; ++i) cout << ' ' << (xsum^a[i]);
	cout << endl;
	return 0;
}

Measured memory_bytes: 4344
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main() {
    int r, d, x2000;
    cin >> r >> d >> x2000;
    int x = x2000;
    for (int i = 0; i < 10; i++) {
        x = r * x - d;
        cout << x << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

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

    cout<<3*r*r<<endl;

    return 0;
}




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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
string S;
cin>>S;
int ans=700;
rep(i,3){
if(S[i]=='o')
ans+=100;
}
cout<<ans<<endl;



  return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let mut X: usize = sc.get();
    let mut ans = 0;
    ans += X / 500 * 1000;
    X %= 500;
    ans += X / 5 * 5;
    println!("{}", ans);
}


Measured memory_bytes: 4352
N = int(input())
A = list(map(int,input().split()))
ans = []
sum_A = sum(A)
tmp_sum = 0
for i in range(1,len(A)-1,2):
    tmp_sum += 2*A[i]
ans.append(sum_A - tmp_sum)
ans.append((A[0] - (ans[0]//2))*2)
tmp = ans[1]
for i in range(1,N-1):
    tmp = 2*A[i] - tmp
    ans.append(tmp)
print(' '.join([str(n) for n in ans]))

Measured memory_bytes: 19140
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
int main()
{

    int n ;
    cin >> n ;
    string x ;
    cin >> x;
    int ans =0 ;
    for (int i = 0; i < n ;i++)
    {
        ans++;
        int j = i+1 ;
        while (j < n && x[j] == x[i])j++;
        i = j-1;
    }
    cout << ans <<"\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <unordered_set>

int main()
{
  int n, k;
  std::cin >> n >> k;

  std::unordered_set<int> s;
  for (int i = 0; i < k; ++i)
  {
    int d;
    std::cin >> d;
    for (int j = 0; j < d; ++j)
    {
      int tmp;
      std::cin >> tmp;
      s.emplace(tmp);
    }
  }
  std::cout << n - s.size() << std::endl;
  return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
      	long B = sc.nextLong();
      	long K = sc.nextLong();
      	for(long i=A;i<=B;i++){
        	if(i<A+K||i>B-K){
            	System.out.println(i);
            }
        }
 		sc.close();
	}
}


Measured memory_bytes: 21844
x=gets.to_i
if x>=400&&x<=599
  puts "8"
elsif x>=600&&x<=799
  puts "7"
elsif x>=800&&x<=999
  puts "6"
elsif x>=1000&&x<=1199
  puts "5"
elsif x>=1200&&x<=1399
  puts "4"
elsif x>=1400&&x<=1599
  puts "3"
elsif x>=1600&&x<=1799
  puts "2"
elsif x>=1800&&x<=1999
  puts "1"
end

Measured memory_bytes: 14316
#include<bits/stdc++.h>
using namespace std;
#define mx 100010
int a[mx],p[mx],k,koko[mx];

void sieve()
{
    a[1]=1;
    for(int i=2; i<sqrt(mx); i++)
    {
        if(!a[i])
        {
            p[k++]=i;
            for(int j=i*i; j<mx; j=j+i)
            {
                a[j]=1;
            }
        }
    }
}

int main()
{
    //sieve();
    int x;
    scanf("%d",&x);
    printf("%d",48-x);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,y;
  cin>>n>>y;
  if(y/10000>n){
    cout<<"-1 -1 -1";
    return 0;
  }
  for(int i=0;i<=y/10000;i++){
    for(int j=0;j<=n-i;j++){
      for(int k=0;k<=n-i-j;k++){
        if(i+j+k==n&&i*10000+j*5000+k*1000==y){
          cout<<i<<" "<<j<<" "<<k;
          return 0;
        }
      }
    }
  }
  cout<<"-1 -1 -1";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	vvl g(n);
	vl ans(n,LINF);
	rep(i,m){
		ll a,b;
		cin>>a>>b;
		g[a-1].push_back(b-1);
		g[b-1].push_back(a-1);
	}
	queue<pll> q;
	q.push(pll(0,-1));
	while(!q.empty()){
		auto p=q.front();q.pop();
		if(ans[p.fs]!=LINF)continue;
		ans[p.fs]=p.sc;
		for(auto x:g[p.fs]){
			if(x!=p.sc&&ans[x]==LINF)q.push(pll(x,p.fs));
		}
	}
	puta("Yes");
	rep(i,n-1){
		puta(ans[i+1]+1);
	}
}


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

int main() {
	int a[5];
	while(1){
		int flag1=0,flag2=0,flag3=0;
		for(int i=0;i<5;i++){
			cin>>a[i];
			if(a[i]==1)flag1=1;
			if(a[i]==2)flag2=1;
			if(a[i]==3)flag3=1;
		}
		if(a[0]==0)break;
		for(int i=0;i<5;i++){
			if(flag1==1&&flag2==1&&flag3==1){
				cout<<3<<endl;
			}else if(flag1==1&&flag2==1){
				if(a[i]==1)cout<<1<<endl;
				else cout<<2<<endl;
			}else if(flag2==1&&flag3==1){
				if(a[i]==2)cout<<1<<endl;
				else cout<<2<<endl;
			}else if(flag1==1&&flag3==1){
				if(a[i]==3)cout<<1<<endl;
				else cout<<2<<endl;
			}else{
				cout<<3<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
char in[120];
pair<pair<string,int>,int> p[110];
int main(){
    int a;
    cin >> a;
    for(int i = 0; i < a; i++){
        int t;
        cin >> in >> t;
        string tmp = in;
        p[i] = make_pair(make_pair(in, -t),i);
    }
    sort(p,p + a);
    for(int i = 0; i < a; i++){
        cout << p[i].second + 1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n;
	long long x=0,y=0,ans=100000000000000000LL;
	cin >>n;
	vector<long long>a(n);
	for(int i=0;i<n;i++){
		cin >>a[i];
		x+=a[i];
	}
	for(int i=0;i<n;i++){
		y+=a[i];
		if(i+1<n){
			ans=min(ans,abs(x-2*y));
			
		}
	
	}
	cout <<ans<<endl;
	
}


Measured memory_bytes: 1792
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << #i <<" "<< i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;

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

  ll n;
  std::cin>>n;

  std::bitset<4000100> make;

  make[0]=true;

  ll sum=0;

  rep(i,0,n){
    ll a;
    std::cin>>a;
    sum+=a;

    make|=(make<<a);
  }

  rep(i,(sum+1)/2,sum+1){
    if(make[i]){
      std::cout<<i<<"\n";
      return 0;
    }
  }

  return 0;
}

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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, d, x;
  vector<int> a;
  cin >> n >> d >> x;
  for(int i=0; i<n; i++){
    int t;
    cin >> t;
    a.push_back(t);
  }
  int cnt = 0;
  while(true){
    bool update = false;
    for(int i=0; i<n; i++){
      if(a[i] * cnt + 1 <= d){
        update = true;
        x++;
      }
    }
    cnt++;
    if(!update) break;
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
	int n,num,max=0,ans=0;
	scanf("%d",&n);
	int temp;
	scanf("%d",&temp);
	n--;
	while(n--){
		scanf("%d",&num);
		if(temp>=num){
			ans++;
			temp=num;
			if(ans>max)max=ans;
		}
		else {
			ans=0;
			temp=num;
		}
	}
	cout<<max<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int a[N];

int main () {
    to_pray();
    
	char c;
	cin >> c;
	
	cout << (c == 'A' ? "T" : (c == 'T') ? "A" : (c == 'G') ? "C" : "G");
    
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

unordered_map<long, unordered_set<long>> original_joint;

unordered_map<long, bool> in_tree;
unordered_map<long, unordered_set<long>> tree;

unordered_map<long, long> dezisuu;

void make_tree(long current) {
  in_tree[current] = true;
  for (auto it: original_joint[current]) {
    if (in_tree[it]) continue;
    tree[current].insert(it);
    make_tree(it);
  }
}

void adjust(long parent, long current) {
  for (auto it: tree[current]) {
    adjust(current, it);
  }
  if (parent == 0) return;
  if (dezisuu[current] % 2 == 1) {
    cout << current << " " << parent << endl;
    dezisuu[current]++;
  } else {
    cout << parent << " " << current << endl;
    dezisuu[parent]++;
  }
}

void solve() {
  long N, M;
  cin >> N >> M;

  if (M % 2 == 1) {
    cout << -1 << endl;
    return;
  }

  rep (i, M) {
    long A, B;
    cin >> A >> B;
    original_joint[A].insert(B);
    original_joint[B].insert(A);
  }

  make_tree(1);

  for (auto it: original_joint) {
    long from = it.first;
    for (auto to: it.second) {
      if (to < from) continue;
      if (tree[from].count(to) != 0 or tree[to].count(from) != 0) continue;
      cout << from << " " << to << endl;
      dezisuu[from]++;
    }
  }

  adjust(0, 1);
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 49060
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	static void solve(){//Here is the main function
		String s = next();
		myout((s.contains("AC")) ? "Yes" : "No");
	}
	//Method addition frame start



	//Method addition frame end

	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
}


Measured memory_bytes: 32816
n, k = map(int, input().split())
A = list(map(int, input().split()))
A = [x-1 for x in A]

town = 0
cnt = 0

visited = [False] * n
visited[0] = -1

start_cnt = 0
for i in range(n*2):
    town = A[town]
    if visited[town] != False:
        start_cnt = i + 1
        loop = i - visited[town]
        break
    else:
        visited[town] = i

town = 0

if k >= start_cnt:
    k = (k-start_cnt)%loop+start_cnt

for i in range(k):
    town = A[town]

print(town+1)


Measured memory_bytes: 32364
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        a: i64, op: chars, b: i64
    }

    let ret = match op[0] {
        '+' => a + b,
        _ => a - b
    };
    println!("{}", ret);
}

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

string sor(string s)
{
  string ans = "zzzzzzzzzz";
  char min;
  int ind;
  for (int i = 0; i < 10; i++) {
    min = 'z' + 1;
    for (int j = 0; j < 10; j++) {
	  if (s[j] < min) {
        ind = j;
        min = s[j];
      }
    }
    s[ind] = 'z' + 1;
    ans.at(i) = min;
  }
  //cout << ans << endl;
  return ans;
}

int main() {
  int n;
  unsigned long long cnt;
  unsigned long long ans = 0;
  cin >> n;
  string s[100000];
  bool c[100000] = {0};
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    s[i] = sor(s[i]);
  }
  
  qsort(s, n, sizeof s[0], [](const void* a, const void* b)
    {
        string arg1 = *static_cast<const string*>(a);
        string arg2 = *static_cast<const string*>(b);
 
        if(arg1 < arg2) return -1;
        if(arg1 > arg2) return 1;
        return 0;
 
    //  return (arg1 > arg2) - (arg1 < arg2); // possible shortcut
    //  return arg1 - arg2; // erroneous shortcut (fails if INT_MIN is present)
    });
  
  cnt = 1;
  for (int i = 0; i < n-1; i++) {
    //cout << s[i] << endl;
    if (s[i] == s[i+1]) cnt++;
    else if (s[i] != s[i+1] && cnt > 1) {
      ans += cnt*(cnt-1)/2;
      cnt = 1;
    }
    if (i == n-2)
      ans += cnt*(cnt-1)/2;
  }
  cout << ans << endl;
  //delete[] s;
}


Measured memory_bytes: 6524
import java.util.Scanner

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]) = {
    val sc = new Scanner(System.in)
    val S = sc.nextLine()

    val odd = 0.until(S.length).map(i => if (i%2 == 1)"1" else "0")
    val even = 0.until(S.length).map(i => if (i%2 == 1)"0" else "1")

    val o = S.zip(odd).map{
      case (c, s) => if (c.toString == s) false else true
    }.count(_ == true)
    val e = S.zip(even).map{
      case (c, s) => if (c.toString == s) false else true
    }.count(_ == true)

    println(o.min(e))
  }
}


Measured memory_bytes: 50272
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

int dp[3300][3300];

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

    vector<P> p(n);
    rep(i,n) cin >> p[i].first >> p[i].second;

    sort(p.begin(), p.end());
    int ans = 0;

    rep(i,n){
        rep(j,t){
            chmax(dp[i+1][j], dp[i][j]);
            if(j + p[i].first < t) chmax(dp[i+1][j+p[i].first], dp[i][j] + p[i].second);
        }
        int now = dp[i][t-1] + p[i].second;
        ans = max(ans,now);
    }

    dunk(ans);
}


Measured memory_bytes: 39168
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def f(A, B):
	return max(len(A), len(B))

N = INT()
ans = 12

for i in range(1, int(sqrt(N))+1):
	if N%i == 0:
		ans = min(ans, f(str(i), str(N//i)))

print(ans)

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


int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec[i].first;
    vec[i].second = i;
  }
  sort(vec.begin(),vec.end());
  for(int i=0;i<n;i++){
    if(i==vec[n-1].second) cout << vec[n-2].first << endl;
    else cout << vec[n-1].first << endl;
  }
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n;
    cin >> n;
    vll vec;
    if (n == 0) {
        cout << 2 << endl;
        return 0;
    } else if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    vec.push_back(2);
    vec.push_back(1);
    for (ll i = 0; i < n - 1; i++) {
        vec.push_back(vec.at(vec.size()-1) + vec.at(vec.size()-2));
        vec.erase(vec.begin());
    }
    cout << vec.at(vec.size()-1) << endl;
    return 0;
}

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N;
    double ans;
    scanf("%lld", &N);
    if ( N % 2 == 0 ) ans = 0.5;
    else{
        ans = 1 - double( (N - 1) / 2 ) / double(N) ;
    }
    printf("%lf\n", ans);
    return 0;
}

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

int main() {
  int N, K, s = 1;
  cin >> N >> K;
  rep(i, N) {
    s = min(s * 2, s + K);
  }
  cout << s << endl;
}

Measured memory_bytes: 3592
n=int(input())
list=[int(i) for i in input().split()]

c_list=[]
for i in list:
    count=0
    while True:
            
        if i%2==0:
            i=i/2
            count+=1
        else:
            break
    c_list.append(count)

    
print(min(c_list))
    

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


int N,K,R,S,PP;
string T;

void solve() {
    cin >> N >> K >> R >> S >> PP >> T;
    vec v(N, 0);
    ll res=0;
    map<char, int> cmap;
    cmap['r'] = PP; cmap['s'] = R; cmap['p'] = S;
    rep(i, N){
        if(i < K){
            v[i] = 1;
            res += cmap[T[i]];
        }else{
            if(T[i] == T[i-K] && v[i-K]){
                v[i] = 0;
            }else{
                v[i] = 1;
                res += cmap[T[i]];
            }
        }
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

int main(void) {
    int x, y, s;
    while (1) {
        cin >> x >> y >> s;
        if (x == 0 && y == 0 && s == 0) break;

        int ans = -1;
        for (int px = 1; px < s; px++) {
            for (int py = px; py < s; py++) {
                if (px*(100+x)/100 + py*(100+x)/100 == s) {
                    int as = px*(100+y)/100 + py*(100+y)/100;
                    ans = max(ans, as);
                }
            }
        }

        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
/*input
2
1000000000 1000000000
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}

void solve(){
	ll i,j,k;
	ll n;
	cin>>n;
	ll a;
	ll ans=1;
	rep(i,0,n){
		cin>>a;
		if(a>(ll)(1000000000000000000/ans)){
			rep(i,i+1,n){
				cin>>a;
				if(!a){cout<<0<<endl;return ;}
			}
			cout<<-1<<endl;
			return ;
		}
		ans*=a;
		if(ans>1000000000000000000){
			rep(i,i+1,n){
				cin>>a;
				if(!a){cout<<0<<endl;return ;}
			}
			cout<<-1<<endl;
			return;
		}
	}
	cout<<ans<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll T=1;
	//cin>>T;
	while(T--){
		solve();
	}
	return 0;
}




Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main(){
  int a,b,c;
  std::cin >> a>>b>>c;
  bool ok=false;
  for (int i = 1; i < 101; i++) {
    if((a*i)%b==c){
      ok=true;
    }
  }
  if(ok)std::cout << "YES" << '\n';
  else std::cout << "NO" << '\n';
  return 0;
}


Measured memory_bytes: 256