akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  long long int a,b;
  cin>>a>>b;
  vector<pair<long long int,long long int>>c(a);
  rep(i,a){
    long long int e,d;
    cin>>e>>d;
    c[i].first=e;
    c[i].second=d;
  }
  long long int f=0,g=0;
  sort(c.begin(), c.end());
  rep(i,a){
    g+=c[i].first*min(c[i].second,b);
    b-=min(c[i].second,b);
    if(b<1)break;
  }
  cout<<g;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio> 
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#ifndef typeof
#define typeof __typeof__
#endif // typeof
 
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(typeof((c).rbegin()) i = (c).rbegin(); i != (c).rend(); i++)
#define repby(i, a, b, step) for(typeof(b) i = (a); i < (b); i += (step))
#define repab(i, a, b) repby(i, (a), (b), 1)
#define rep(i, n) repab(i, 0, (n))
#define pb push_back
#define sz(c) int((c).size())

int main(int argc, char **argv)
{
  repab (i, 1, 10) {
    repab (j, 1, 10) {
      cout << i << "x" << j << "=" << i*j << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
string s; bool ok=1;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> s;
for (int i=0;i<s.size();i+=2){
	if (s[i]!='R' and s[i]!='U' and s[i]!='D') ok=0;
}
for (int i=1;i<s.size();i+=2){
	if (s[i]!='L' and s[i]!='U' and s[i]!='D') ok=0;
}
if (ok) cout << "Yes";
else cout << "No";
return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
import math
input=sys.stdin.readline


a,b,h,m=map(int,input().split())
t=60*h+m
hun=6*t%360
zi=0.5*t
deg=min(360-abs(zi-hun),abs(zi-hun))
ans=a**2+b**2-2*a*b*math.cos(math.radians(deg))
print(pow(ans,0.5))

Measured memory_bytes: 27204
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    int ans = 0;
    int n , i , a[100002];
    cin >> n;
    for(i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    for(i=1;i<=n;i++)
    {
        if(a[a[i]] == i)
            ans++;
    }
    cout << ans/2 ;
    return 0;
}

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

using namespace std;

const int MAX_N = 2000;
const int MAX_S = 4000000;
int v[MAX_N];
bitset<MAX_S+1> dp;

int main() {
  int n, s;
  scanf("%d", &n);
  s = 0;
  for(int i = 0; i < n; ++i) {
    scanf("%d", &v[i]);
    s += v[i];
  }
  dp[0] = true;
  for(int i = 0; i < n; ++i)
    dp = dp | (dp << v[i]);
  s = (s + 1) / 2;
  while(!dp[s])
    ++s;
  printf("%d", s);
  return 0;
}


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

int N;
int A[100010];

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)scanf("%d",A + i);

    sort(A,A + N);
    printf("%d ",A[N - 1]);

    int dif = 1001001001;
    int id = 0;
    for(int i = 0; i < N - 1; i++)
    {
        if(abs(A[N - 1] - A[i] * 2) < dif)
        {
            dif = abs(A[N - 1] - A[i] * 2);
            id = i;
        }
    }
    printf("%d\n",A[id]);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  vector<vector<int>>train(N - 1,vector<int>(3,0));
  for(int i=0;i<N-1;i++){
    for(int j=0;j<3;j++){
      cin >> train[i][j];
    }
  }
  
  for(int i=0;i<N;i++){
    int t = 0;
    for(int j=i;j<N-1;j++){
      if(t < train[j][1])
        t = train[j][1];
      else if(t % train[j][2] == 0);
      else
        t = t + train[j][2] - (t % train[j][2]);
      t += train[j][0];
    }
    
    cout << t << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)

int main()
{
    IO;
    int i, j, n, m, k, l;
    cin>>n>>m>>k;
    cout<<k<<' '<<n<<' '<<m<<endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
d = dict()
for x in a:
    t = x // 400
    if t > 8:
        t = 8
    d[t] = d.get(t, 0) + 1
ans = 0
for k, v in d.items():
    if k < 8:
        ans += 1
if ans == 0:
    max_v = d.get(8, 0)
    min_v = 1 if max_v > 0 else 0
else:
    max_v = ans + d.get(8, 0)
    min_v = ans
print(min_v, max_v)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 1; i <= n; i++) {
			if(i<n) {
				System.out.printf("%d ", a[n - i]);
			} else {
				System.out.printf("%d", a[n - i]);
			}
		}
		System.out.println("");
	}

}



Measured memory_bytes: 26492
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val As = List.fill(sc.nextInt())(sc.nextLong())
  val sum = As.sum
  val (_, diffs) = As.scanLeft(0L -> sum) {
    case ((acc, _), a) =>
      acc + a -> math.abs(sum - (acc + a) * 2)
  }.unzip
  println(diffs.min)
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 res = INF_LL;
	int64 N;
	cin >> N;
	for (int64 i = 1; i < sqrt(N)+1; i++) {
	  if (N % i == 0) {
	    chmin(res, i+N/i-2);
	  }
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;


int main()
{
	char x, y;
	cin >> x >> y;
	cout << (x == y ? "=" : (x > y ? ">" : "<")) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, maxn = 4e5 + 148, mod = 998244353, N = 1e7 + 5;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;

int r;	


main () {
	cin >> r;
	cout << r * r << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <climits>

using namespace std;

typedef unsigned long long ull;

const ull H = 1000000007;

int n,m;
char s[333333],t[11];
int l,r;
set<ull> res;

ull pow(ull a,ull b)
{
  if( b == 0 ) return 1;
  ull ret = pow(a*a,b/2);
  if( b%2 ) ret *= a;
  return ret;
}

int main(void)
{
  int n,m;
  ull h = 0;
  scanf("%d%d",&n,&m);
  scanf("%s",s);
  h = *s;
  while( m-- ) {
    scanf("%s",t);
    if( *t == 'R' ) {
      if( t[1] == '+' ) {
        ++r;
        h = (h*H+s[r]);
      }
      if( t[1] == '-' ) {
        h = h-s[r];
        h = h*pow(H,ULLONG_MAX);
        --r;
      }
    } else {
      if( t[1] == '+' ) {
        h = h-s[l]*pow(H,r-l);
        ++l;
      }
      if( t[1] == '-' ) {
        --l;
        h = h+s[l]*pow(H,r-l);
      }
    }
    res.insert(h);
  }
  printf("%ld\n",res.size());
  return 0;
}

Measured memory_bytes: 15384
import java.util.Scanner;

public class Main{
		public static void main(String[] args) {
		  try(Scanner sc = new Scanner(System.in)) {
			  int ans=0;
			  while(sc.hasNext()) {
				  String str=sc.nextLine();
				  String[] tokens=str.split("[^0-9]");
				  for(String t:tokens) {
					  if(t.length()>0) {
						  ans+=Integer.valueOf(t);
					  }
				  }
			  }
			  System.out.println(ans);
		  }
	}
}


Measured memory_bytes: 26112
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line: Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0] as usize;
    let m = line[1];
    let a: Vec<i64> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut b = vec![0; n+1];
    let mut memo = HashMap::with_capacity(n);
    memo.insert(0, 1);
    let mut ans = 0u64;
    for i in 0..n {
        b[i+1] = (b[i] + a[i])%m;
        ans += *(memo.get(&b[i+1]).unwrap_or(&0)) as u64;
        let tmp = memo.get(&b[i+1]).unwrap_or(&0) + 1;
        memo.insert(b[i+1], tmp);
    }

    println!("{}", ans);
}


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

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define endl '\n'
#define boost ios::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL);
typedef long long li;
#define int long long
const int N = 1e5 + 10;
int w[N] , v[N];
int n , W;
int dp[102][N];

int solve(int tot , int i){

	if(i==n || tot==0)
		return 0;
	if(dp[i][tot]!=-1)
		return dp[i][tot];

	if(w[i]>tot){
		return dp[i][tot] = solve(tot , i+1);
	}
	return dp[i][tot] =  max(v[i] + solve(tot - w[i] , i+1) , solve(tot  , i + 1));
}
signed main(){

	cin>>n>>W;

	for(int i = 0 ; i < n ; ++i){
		cin>>w[i]>>v[i];
	
	}

	for(int i = 0 ; i < 101; ++i)
		for(int j = 0 ; j  < N ; ++j)
			dp[i][j] = -1;

	cout<<solve(W,0)<<endl;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
#define PRYES(x) PR((x) ? "Yes" : "No")
const long long INF = numeric_limits<long long>::max();

template <class T> void dumpVector(const vector<T>& vec) {
#ifdef SOURCE_TEST
    for (ll i = 0; i < vec.size(); ++i) {
        cout << vec[i] << ",";
    }
    cout << endl;
#endif
}

template <class T> void distinct(vector<T>& vec) {
    // 配列から重複を削除する
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

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

    vector<string> strings;
    for (ll i = 0; i < s.size(); ++i) {
        for (ll j = 1; (i + j) <= s.size(); ++j) {
            if (j > 5) continue;
            strings.push_back(s.substr(i, j));
        }
    }

    dumpVector(strings);
    sort(strings.begin(), strings.end());
    distinct(strings);

    PR(strings[N - 1]);
    return 0;
}

Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector< vector<int> > Graph;
int n[2],m[2];
map<string,int> mp;
vector<int> vp;
int cnt=1;

vector<Graph> Forest_to_Trees(Graph &G){
	vector<int> num(n[0],-1);
	vector<Graph> tree;
	for(int i=0;i<n[0];i++){
		if(num[i]==-1){
			Graph gra(1);
			queue<int> q;
			q.push(i);
			int cur=0;
			num[i]=0;
			while(q.size()){
				int v=q.front();
				q.pop();
				for(int j=0;j<G[v].size();j++){
					int nv=G[v][j];
					if(num[nv]==-1){
						num[nv]=++cur;
						gra.push_back(vector<int>());
						gra[num[v]].push_back(num[nv]);
						gra[num[nv]].push_back(num[v]);
						q.push(nv);
					}
				}
			}
			tree.push_back(gra);
		}
	}
	return tree;
}


int calc2(Graph &G2,int v,int parent){
	if(G2[v].size()==0)return 1;
	if(G2[v].size()==1 && parent!=-1)return 1;
	vector<string> s;
	for(int i=0;i<(int)G2[v].size();i++){
		int nv=G2[v][i];
		if(parent==nv)continue;
		int val=calc2(G2,nv,v);
		s.push_back(to_string(val));
	}
	sort(s.begin(),s.end());
	string str="";
	for(int i=0;i<s.size();i++){
		str+=s[i];
	}
	if(!mp.count(str))mp.insert(map<string,int>::value_type(str,++cnt));
	return mp[str];
}

void dfs2(Graph &G2,int v,vector<int> &dist){
	if(dist[v]==-1)dist[v]=0;
	for(int i=0;i<G2[v].size();i++){
		if(dist[G2[v][i]]==-1){
			dist[G2[v][i]]=dist[v]+1;
			dfs2(G2,G2[v][i],dist);
		}
	}
}

vector<int> getCenter(Graph &G){
	int nn=G.size();
	vector<int> dist(nn,-1);
	vector<int> dist2(nn,-1);
	vector<int> dist3(nn,-1);
	dfs2(G,0,dist);
	int maxi=-1;
	int tgt=0;
	for(int i=0;i<nn;i++){
		if(dist[i]>maxi){
			maxi=dist[i];
			tgt=i;
		}
	}
	dfs2(G,tgt,dist2);
	maxi=-1;
	for(int i=0;i<nn;i++){
		if(dist2[i]>maxi){
			maxi=dist2[i];
			tgt=i;
		}
	}
	dfs2(G,tgt,dist3);
	vector<int> res;
	for(int i=0;i<nn;i++){
		if(maxi%2==0){
			if(dist2[i]==maxi/2 && dist3[i]==maxi/2)res.push_back(i);
		}else{
			if(dist2[i]==(maxi+1)/2 && dist3[i]==maxi/2)res.push_back(i);
			if(dist2[i]==maxi/2 && dist3[i]==(maxi+1)/2)res.push_back(i);
		}
	}
	return res;
}

int main(void){
	Graph g2;
	scanf("%d%d",&n[0],&m[0]);
	Graph G(n[0]);
	for(int i=0;i<m[0];i++){
		int f,t;
		scanf("%d%d",&f,&t);
		f--;
		t--;
		G[f].push_back(t);
		G[t].push_back(f);
	}
	vector<Graph> tree=Forest_to_Trees(G);
	scanf("%d",&n[1]);
	m[1]=n[1]-1;
	for(int i=0;i<n[1];i++){
		g2.push_back(vector<int>());
	}
	for(int i=0;i<m[1];i++){
		int f,t;
		scanf("%d%d",&f,&t);
		f--;
		t--;
		g2[f].push_back(t);
		g2[t].push_back(f);
	}
	vector<int> root[2];
	root[1]=getCenter(g2);
	mp["0"]=1;
	for(int i=0;i<root[1].size();i++){
		vp.push_back(calc2(g2,root[1][i],-1));
	}
	int res=0;
	for(int i=0;i<tree.size();i++){
		if(tree[i].size()!=n[1])continue;
		root[0].clear();
		root[0]=getCenter(tree[i]);
		bool flag=false;
		for(int j=0;j<root[0].size();j++){
			if(flag)break;
			int s1=calc2(tree[i],root[0][j],-1);
			for(int k=0;k<vp.size();k++){
				if(s1==vp[k])flag=true;
			}
		}
		if(flag)res++;
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 55580
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

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

    bool f=1;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            if(s[i]=='L'){
                f=0;
                break;
            }
        }else{
            if(s[i]=='R'){
                f=0;
                break;
            }
        }
    }

    cout<<((f)? "Yes":"No")<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    if (x == 1 || x == 2 * n - 1) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        for (int i = 0; i < 2 * n - 1; i++) {
            cout << (i - n + x + 2 * n - 1) % (2 * n - 1) + 1 << endl;
        }
    }
}

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

A,B = [],[]

for _ in range(n):
    a,b = map(int, input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()

l,h = A[n//2] , B[n//2]
if n%2==0:
    l+=A[n//2 -1]
    h+=B[n//2 -1]
print(h-l+1)





    

Measured memory_bytes: 98900
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n, L;
	scanf("%d%d", &n, &L);
	vector<int> A(n);
	int p = -1;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
		if (i && A[i] + A[i - 1] >= L) {
			p = i - 1;
		}
	}
	if (p == -1) printf("Impossible\n");
	else {
		vector<int> ans;
		for (int j = p; j + 1 < n; ++j) ans.push_back(j + 1);
		for (int j = p - 1; j >= 0; --j) ans.push_back(j + 1);
		reverse(ans.begin(), ans.end());
		printf("Possible\n");
		for (int x : ans) printf("%d\n", x);
	}
}


Measured memory_bytes: 1784
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        String[] in = new String[H];
        for (int i = 0; i < H; i++) {
            in[i] = sc.next();
        }
        int[] xSerch = {-1,0,0,1};
        int[] ySerch = {0,1,-1,0};
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (in[i].charAt(j) == '#') {
                    boolean ok = false;
                    for (int k = 0; k < 4; k++) {
                        int x = j+xSerch[k];
                        int y = i+ySerch[k];
                        if (-1 < x && x < W && -1 < y && y < H) {
                            if (in[y].charAt(x) == '#') {
                                ok = true;
                            }
                        }
                    }
                    if (!ok) {
                        System.out.println("No");
                        return;
                    }
                }
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
typedef std::pair<std::string,double> P;

long long N, M, T, ans; 
string s;
int op[1200000];
void solve(){
    if(N*2<M){
        ans += N;
        M-=N*2;
        ans += M/4;
    }else{
        ans += M/2;
    }
    cout << ans << endl;
}
int main() {
    cin >> N >> M;
    solve();
	return 0;
}

Measured memory_bytes: 256
N = int(input())
b = 0
c = 0
first = 0
A = []
for i in range(N):
    a = int(input())
    if b < a:
        ind = i
        b = a
    A.append(a)
for j in range(N):
    if j==ind:
        continue
    if c < A[j]:
        sind = j
        c = A[j]
for k in range(N):
    if k==ind:
        print(c)
    else:
        print(b)


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N, M;

int main(void) {
    map<int,int> D;

    cin >> N;
    rep(i, N) {
        int n;
        cin >> n;
        D[n]++;
    }

    cin >> M;
    bool result = true;
    rep(i, M) {
        int n;
        cin >> n;
        if (D[n] == 0) {
            result = false;
            break;
        }
        D[n]--;
    }

    if (result) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 9600
H, W=map(int, input().split())
s=["."]*(W+2)
a=[s]
for i in range(H):
  tmp=input()
  tmp="."+tmp+"."
  a.append(list(tmp))
a.append(s)

ans="Yes"
dero=False
for i in range(1,H+1):
  for j in range(1,W+1):
    if a[i][j]==".":
      continue
    f1=a[i-1][j]=="."
    f2=a[i+1][j]=="."
    f3=a[i][j+1]=="."
    f4=a[i][j-1]=="."
    if f1 and f2 and f3 and f4:
      ans="No"
      dero=True
      break
  if dero:
    break
print(ans)
  

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;


int main(){

int w,a,b;
cin >> w>> a >> b;

if(a>b){
    if(b<a and a<b+w)cout << 0 << endl;
    else if (b+w<a)cout << a-b-w << endl;
    else cout << 0 << endl;
       }
else if (b>a){
    swap(a,b);
    if(b<a and a<b+w)cout << 0 << endl;
    else if (b+w<a)cout << a-b-w << endl;
    else cout << 0 << endl;
            }
else cout << 0 << endl;





return 0;

}




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

int n, m;
vector <int> g[400005];
vector <pair <int, pair <int, int> > > e;

int find(vector <int> &dsu, int x) {
	if (dsu[x] != x)
		return dsu[x] = find(dsu, dsu[x]);
	return x;
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1, u, v, c; i <= m; i ++) {
		scanf("%d%d%d", &u, &v, &c);
		e.push_back(make_pair(c, make_pair(u, v)));
	}
	int cc = n + 1;
	sort(e.begin(), e.end());
	for (int c = 1, i = 0, j = 0; c <= 1000000 && j < (int) e.size(); c ++, i = j) {
		vector <int> v;
		for (j = i; j < (int) e.size() && e[j].first == e[i].first; j ++) {
			v.push_back(e[j].second.first);
			v.push_back(e[j].second.second);
		}
		sort(v.begin(), v.end());
		v.resize(unique(v.begin(), v.end()) - v.begin());
		vector <int> dsu;
		for (int k = 0; k < (int) v.size(); k ++)
			dsu.push_back(k);
		for (int k = i; k < j; k ++) {
			int x = lower_bound(v.begin(), v.end(), e[k].second.first) - v.begin();
			int y = lower_bound(v.begin(), v.end(), e[k].second.second) - v.begin();
			dsu[find(dsu, x)] = find(dsu, y);
		}
		vector <int> v1;
		for (int k = 0; k < (int) v.size(); k ++) {
			if (dsu[k] == k) v1.push_back(k);
		}
		sort(v1.begin(), v1.end());
		for (int k = 0; k < (int) v.size(); k ++) {
			int u = v[k];
			int v = cc + lower_bound(v1.begin(), v1.end(), find(dsu, k)) - v1.begin();
			// printf("%d %d\n", u, v);
			g[u].push_back(v);
			g[v].push_back(u);
		}
		cc += (int) v1.size();
	}
	queue <int> que;
	vector <int> dis;
	for (int i = 0; i < cc; i ++)
		dis.push_back(-1);
	dis[1] = 0;
	que.push(1);
	while (!que.empty()) {
		int u = que.front(); que.pop();
		for (int i = 0; i < (int) g[u].size(); i ++) {
			int v = g[u][i];
			if (!~dis[v]) {
				dis[v] = dis[u] + 1;
				que.push(v);
			}
		}
	}
	printf("%d\n", !~dis[n] ? -1 : dis[n] / 2);
	return 0;
}

Measured memory_bytes: 25456
N=int(input())
a=list(map(int, input().split()))
a.sort()
nums=[0]*(10**5+1)
counter=0
for i in range(N):
  if a[i]>10**5:
    counter+=1
  else:
    nums[a[i]]+=1
    
for i in range(10**5+1):
  if nums[i]>i:
    counter+=nums[i]-i
  elif nums[i]<i:
    counter+=nums[i]
print(counter)

Measured memory_bytes: 14692
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 N, W;
  cin >> N >> W;

  vector<i64> w(N + 1), v(N + 1);
  for(int i = 1;i <= N;i++) cin >> w[i] >> v[i];
  vector<vector<i64>> dp(N + 1, vector<i64>(W + 1, -1e18));
  dp[0][0] = 0;
  for(int i = 1;i <= N;i++) {
    for(int j = 0;j <= W;j++) {
      if(j - w[i] >= 0) {
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
      }
      else {
        dp[i][j] = dp[i - 1][j];
      }
    }
  }

  cout << *max_element(all(dp[N])) << endl;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
// atoi : atoi(変数名.c_str())
// to_string(数値)
// %0桁数d とすると表示桁数が「桁数」に満たない場合に0埋めされる
// find(): int i = 変数名.find(“文字列”) 何番目にあるかを得る
// cout << (条件 ? "Yes" : "No") << endl;
// printf("%02d:%02d:%02d",hour,minute,second);
// 降順 sort(a.begin(),a.end(),greater<int>());
// bitset<ビット数> 変数名;  // すべてのビットが0の状態で初期化される
// bitset<ビット数> 変数名("ビット列");  // 指定したビット列で初期化される
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  long d,g;
  cin >> d >> g;
  vector<int> p(d);
  vector<int> c(d);
  rep(i,d){
    cin >> p.at(i) >> c.at(i);
  }
  long ans = 1e8;
  for(int i = 0;i < (1 << d);i++){
    bitset<10> select(i);
    
    long sum = 0;
    long q = 0;
    int tmp = d;
    rep(j,d){
      if(select.test(j)){
        sum += p.at(j)*100*(j+1) + c.at(j);
        q += p.at(j);
      }else{
        tmp = j;
      }
    }
    if(sum >= g){
      ans = min(ans,q);
    }else if(tmp == d){
      continue;
    }else{
      if((tmp+1)*100*(p.at(tmp)-1) + sum < g) continue;
      else{
        long rest = g - sum;
        q += ( (rest + (tmp+1)*100 - 1) / ((tmp+1)*100) );
        ans = min(ans,q);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#define mp make_pair
#define pb push_back

using LL = long long;
using namespace std;

typedef pair<int, int> pii;

int N;
int memo[333][333];
vector<int>A;
int dp(int L, int R) {
	if (R - L <= 1) {
		return 0;
	}
	if (memo[L][R] >= 0) {
		return memo[L][R];
	}
	int ans = 0;
	for (int i = L + 1; i < R; ++i) {
		ans = max(ans, dp(L, i) + dp(i, R));
	}
	for (int i = L; i < R - 1; ++i) {
		if (abs(A[i] - A[i + 1]) <= 1) {
			ans = max(ans, dp(L, i) + dp(i + 2, R) + 2);
		}
	}
	if (dp(L + 1, R - 1) == R - L - 2) {
		if (abs(A[L] - A[R - 1]) <= 1) {
			ans = max(ans, R - L);
		}
	}
	return memo[L][R] = ans;
}

int main() {
	while (cin >> N, N) {
		memset(memo, 0xff, sizeof(memo));
		A.clear();
		for (int i = 0; i < N; ++i) {
			int tmp;
			cin >> tmp;
			A.push_back(tmp);
		}
		cout << dp(0, N) << endl;
	}
	return 0;
}


Measured memory_bytes: 3604
import java.util.ArrayList;
import java.util.Scanner;
class Main{


	static char[][] map;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力



		int N = sc.nextInt();
		int L = sc.nextInt();

		int[] data = new int[N];
		int sum = 0;
		int min = Integer.MAX_VALUE;
		
		for(int i = 0;i < N;i++){
			data[i] = L + i ;
			sum += data[i];
			
		}
		int ans = 0;
		for(int i = 0;i < N;i++){
			if(Math.abs(sum-(sum-data[i])) < min){
				min = Math.abs(sum-(sum-data[i]));
				ans = sum-data[i];
			}
		}
		
		
		System.out.print(ans) ;
		
		
		
		

	}

	static int rsearch(int y,int x){

		int count = 0;
		while(x < map[0].length && map[y][x] != '#'){
			count++;
			x++;
		}
		return count;	

	}

	static int csearch(int y,int x){

		int count = 0;
		while(y < map.length && map[y][x] != '#'){
			count++;
			y++;
		}
		return count;	
	}


	static boolean checkswitch(int bit,int[] k,ArrayList<ArrayList<Integer>> list,int[] p,int m){

		//		System.out.println("bit " + bit);

		for(int i = 0;i < m;i++){

			ArrayList<Integer> sub = list.get(i);
			int onnum = 0;						//onの数
			for(int j = 0;j < sub.size();j++){
				//				System.out.println("sub "+ sub.get(j));
				if((bit & (1 << sub.get(j))) != 0){				//目的のスイッチがついているか
					onnum++;
					//					System.out.println("on  ");
				}

			}
			if(onnum % 2 != p[i]){				//一個でも電球がつかなかったらout
				return false;
			}

		}


		return true;

	}

	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}





}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return  otherpair.end - end;
	}
}




Measured memory_bytes: 23380
#include <iostream>
 int main() {
  int a, b, c;
   std::cin >> a >> b >> c;

    if (a <= b && b <= c) {                               
     std::cout << a << " " << b << " " << c <<std::endl;
    } else if (c <= b && b <= a) {                        
     std::cout << c << " " << b << " " << a <<std::endl;
    } else if (a <= c && c <= b ) {                       
     std::cout << a << " " << c << " " << b <<std::endl;
    } else if (c <= a && a <= b) {                       
     std::cout << c << " " << a << " " << b <<std::endl;
    } else if (b <= a && a <= c) {                       
     std::cout << b << " " << a << " " << c <<std::endl;
    } else if (b <= c && c <= a) {                      
     std::cout << b << " " << c << " " << a <<std::endl;
    }





 return 0;





}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define pb push_back 
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,a,b) for(int i=a;i<b;i++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define printmp(b) for(auto y:b) {printP(y);}

#define print(a) for(auto x:a) cout<<x<<' ';cout<<endl;
#define printM(b) for(auto y:b) {print(y);}
#define printP(p) cout<<p.first<<' '<<p.second<<endl;
typedef long long int ll;
typedef unsigned long long int ull;

/* 

*/
ll apowb(ll a,ll b)
{
  if(b==0)
  return 1;
  if(b==1)
  return a;
  if(b%2==0)
  {
    return apowb(a*a,b/2);

  }else
  {
    return apowb(a*a,b/2)*a;

  }
  
}

void solve()

{
  ll sum=0;
 string s;
 cin>>s;

for(char x:s)
{
  sum+=x-'0';
}

if(sum%9==0)
cout<<"Yes";
else
cout<<"No";


   



   //cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;  
   
}


int main()
{
  /*
6
4 0
4 41
0 1000000
44 0
1 0
10000 1000000


  */
  fast;
  int t=1;
 //cin>>t;
  while(t--){
  
  solve();
 cout<<endl;
   
}
  
  
      
      return 0;
    }

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

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


int main() {
  string s;
  cin >> s;
  int count = 0;
  rep (i, s.size() / 2) {
    if (s.at(i) != s.at(s.size() - 1 - i)) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
 
using namespace std;
 
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
 
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
 
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
 
const double EPS = 1e-10;

int main() {
	int n;

	while(cin >> n, n) {
		int sum = 1;
		
		for(int i = 2; i*i < n; i++) {
			if(n%i == 0) {
				sum += i;
				sum += n/i;
			}
		}

		if(n == 1) {
			sum = 0;
		}

		if(sum == n) {
			cout << "perfect number" << endl;
		} else if(sum < n) {
			cout << "deficient number" << endl;
		} else {
			cout << "abundant number" << endl;
		}
	}
}

Measured memory_bytes: 0
#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>
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<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

struct edge{
    ll to, cap, rev;
};

struct Dinic{
    const ll INF = 1e9;
    int n;
    vector<vector<edge> > g;
    VL level, iter;

    void init(int x){
        n = x;
        g.resize(n);
        level.resize(n);
        iter.resize(n);
    }

    void add_edge(int from, int to, ll cap){
        g[from].push_back((edge){to, cap, (int)g[to].size()});
        g[to].push_back((edge){from, 0, (int)g[from].size() - 1});
    }

    void bfs(int s){
        fill(ALL(level), -1);
        queue<int> que;
        level[s] = 0;
        que.push(s);
        while (!que.empty()){
            int v = que.front();
            que.pop();
            for (edge &e : g[v]){
                if (e.cap > 0 && level[e.to] < 0){
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    ll dfs(int v, int t, ll f){
        if (v == t) return f;
        for (ll &i = iter[v]; i < g[v].size(); i++){
            edge &e = g[v][i];
            if (e.cap > 0 && level[v] < level[e.to]){
                ll d = dfs(e.to, t, min(f, e.cap));
                if (d > 0){
                    e.cap -= d;
                    g[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    ll max_flow(int s, int t){
        ll flow = 0;
        while (1){
            bfs(s);
            if (level[t] < 0) return flow;
            fill(ALL(iter), 0);
            ll f;
            while ((f = dfs(s, t, INF)) > 0){
                flow += f;
            }
        }
    }
};

int main() {
    int n;
    cin >> n;
    VL a(n+1);
    ll sum = 0;
    FOR(i,1,n){
        cin >> a[i];
        if (a[i] > 0) sum += a[i];
    }

    Dinic flow;
    flow.init(n+2);

    FOR(i,1,n){
        if (a[i] >= 0){
            flow.add_edge(0, i, 0);
            flow.add_edge(i, n+1, a[i]);
        }else{
            flow.add_edge(0, i, -a[i]);
            flow.add_edge(i, n+1, 0);
        }
        for (int x = 2 * i; x <= n; x += i){
            flow.add_edge(i, x, 1e18);
        }
    }

    cout << sum - flow.max_flow(0, n+1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<map>
#include<stack>
using namespace std;
int dx[] = { -1,0,0,1,-1,-1,1,1,0 };
int dy[] = { 0,1,-1,0,1,-1,1,-1,0 };
/*
int main()
{
	int r, c;
	cin >> r >> c;
	int sy, sx, gy, gx;
	vector<vector<char>>field(r,vector<char>(c));
	sy--, sx--, gy--, gx--;
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			cin >> field[i][j];
		}
	}
	queue<pair<int,int>>q;
	q.push({ sx,sy });
	vector<vector<int>>d(c, vector<int> (r, -1));
	d[sx][sy] = 0;

	while (!q.empty())
	{
		pair<int, int>p = q.front;
		q.pop();
		for (int i = 0; i < 4; i++)
		{
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx < 0 || ny < 0 || nx >= c || ny >= r || d[nx][ny] != -1 || field[nx][ny] == '#')continue;
			q.push({ nx,ny });
			d[nx][ny] = d[p.first][p.second] + 1;
		}
	}

	cout << d[gx][gy] << endl;
}*/


int main() 
{
	int n, x;
	cin >> n >> x;
	vector<int>l(n);
	for (int i = 0; i < n; i++)
	{
		cin >> l[i];
	}

	int lange = 0,ans=1;

	for (int i = 0; i < n; i++)
	{
		lange += l[i];
		if (lange <= x)
		{
			ans += 1;
		}
	}
	cout << ans << endl;

}



Measured memory_bytes: 3192
n=int(input())
l = [[0] for _ in range(n)]
lim=int(n**0.5)
l2=list(range(1, lim+1)) 
import itertools
for x in range(1, lim):
  for y in range(1, lim):
    for z in range(1, lim):
      d=x**2+y**2+z**2+x*y+x*z+y*z
      #print(d)
      #print(v)
      if d<=n:
        l[d-1][0]+=1
for i in l:
  print(i[0])

Measured memory_bytes: 10384
#include <map>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
using namespace std;
int main(){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*c,max(a*d,max(b*c,b*d)));
    return 0;
}

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    final static int N = 123456 * 2 + 1;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";

        int[] prim = new int[N];

        prim[0] = -1;
        for (int i = 2; i < N / 2; i++) {
            for (int j = 2; j < N / i + 1; j++) {
                if (prim[i] == 0) {
                    prim[i * j] = -1;
                }
            }
        }
        int count = 0;
        for (int i = 0; i < N; i++) {
            if (prim[i] == 0) {
                prim[i] = ++count;
            } else {
                prim[i] = count;
            }
        }

        while ((line = br.readLine()) != null && !line.isEmpty()) {
            int n = Integer.parseInt(line);
            if (n == 0) {
                break;
            }
            System.out.println(prim[n * 2] - prim[n]);
        }
    }
}

Measured memory_bytes: 21956
def main():
    #0.input
    s = input()
    K = int(input())
    
    #1. make subset
    subset = set()
    for k in range(1, min(len(s)+1, K+1)):
        start = 0
        while start <= len(s)-k:
            subset.add(s[start:start+k])
            start += 1
    
    subset_list = sorted(list(subset))
    print(subset_list[K-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 4592
def CountingSort(A, B, k):
    C = [ 0 for i in range(k + 1)]
    
    for i in range(len(A)):
        C[A[i]] += 1

    for j in range(1, len(C)):
        C[j] = C[j] + C[j - 1]

    for j in reversed(range(len(A))):
        B[ C[ A[j] ] - 1 ] = A[j]
        C[ A[j] ] -= 1

def Main():
    n = int(input())

    A = [int(a) for a in input().split()]
    B = [0 for i in range(len(A))]
    k = max(A) + 1

    CountingSort(A, B, k)

    print(*B)

Main()


Measured memory_bytes: 224224
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007
int main()
{
    int X,Y,Z;
    cin >> X >> Y >> Z;
    int num = 0;
    for(int i = 1;i < X;i++)
    {
        if(X >= Y * i + Z * i + Z)
            num = i;
        else
            break;
    }
    cout << num << '\n';
}



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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  vector<vector<ll>> dp(n+1, vector<ll>(2,0));
  dp[0][1] = 1;
  for(int i=0; i<n; ++i){
    if(s[i] == '1'){
      dp[i+1][0] = (dp[i][0] *3 + dp[i][1]) %MOD;
      dp[i+1][1] = dp[i][1] *2 %MOD;
    }else{
      dp[i+1][0] = dp[i][0] *3 %MOD;
      dp[i+1][1] = dp[i][1] %MOD;
    }
  }
  cout << (dp[n][0] +dp[n][1]) %MOD << endl;
}

Measured memory_bytes: 8816
// can i beat Mod Love? 
#include <bits/stdc++.h>

using namespace std;
#define int long long 
#define eps 1e-8
#define SZ(a) ((int32_t)a.size())
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
typedef long long ll;
ll bin(ll x, ll n, ll MOD) {ll ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = acos(-1.0);
constexpr ll mod = 1e9+7;
constexpr int maxn = 1e6+100; // remember to calculate.
int n, c[maxn];
string s[maxn];
ll v[55][22][2], f[55][22][2], ans = linf;
ll dp(int x, int y, int d){ // x 为串的编号，y 为位置， d为方向
	if(y == SZ(s[x])) return 0;
	ll &u = v[x][y][d], &v = f[x][y][d];
	if(u) return v;
	u = 1, v = linf;
	int fl = 1;
	if(!d){
		for(int j = y, k = SZ(s[x]) - 1; j < k; j++, k--){
			if(s[x][j] != s[x][k]) {
				fl = 0; break;
			}
		}
	}else{
		for(int j = y, k = 0; j > k; j--, k++){
			if(s[x][j] != s[x][k]) {
				fl = 0; break;
			}
		}
	}
	if(fl) {
		return v = 0;
	}
	for(int i = 1, j , k; i <= n; i++){ // 枚举另一方向接哪个串
		fl = 1;
		if(!d) {
			for(j = y, k = SZ(s[i]) - 1; j < SZ(s[x]) && k >= 0; j++, k--){
				if(s[x][j] != s[i][k]) {
					fl = 0;break;
				}
			}
			if(fl){
				if(k < 0) v = min(v , c[i]+dp(x , j , 0));
				else v = min(v, c[i] + dp(i , k , 1)); 
			}
		}else{
			for(j = y, k = 0; j >= 0 && k < SZ(s[i]); j--, k++){
				if(s[x][j] != s[i][k]) {
					fl = 0; break;
				}
			}
			if(fl) {
				if(j < 0) v = min(v , c[i] + dp(i , k , 0));
				else v = min(v , c[i] + dp(x , j , 1));
			}
		}
	}
	return v;
}
int32_t main()
{
	close;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> s[i] >> c[i];
	}
	for(int i = 1; i <= n; i++) {
		ans = min(ans , c[i] + dp(i , 0 , 0));
	}
	cout << (ans == linf ? -1 : ans) << endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n;
	string s; cin>>n>>s;
	cout<<(s.substr(0,n/2)+s.substr(0,n/2)==s?"Yes":"No")<<'\n';
	return 0;
}


Measured memory_bytes: 256
var stdin = require('fs').readFileSync('/dev/stdin', 'utf8');

var input = stdin.toString().trim().split('\n');

var S = parseInt(input[0], 10);
var h = Math.floor(S / (60 * 60));
var m = Math.floor(S % (60 * 60) / 60);
var s = S % 60;

console.log([h, m, s].join(':'));

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

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

u64 lcm(u64 a, u64 b) { return (a / gcd(a, b)) * b; }

int main() {
  u32 N;
  cin >> N;
  vector<u32> P(N), Q(N);
  ArrayInput(P);
  ArrayInput(Q);
  u32 res = 0;
  if (P < Q) {
    while (P != Q) next_permutation(P.begin(), P.end()), ++res;
  } else {
    while (P != Q) prev_permutation(P.begin(), P.end()), ++res;
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b;
	scanf("%d %d",&a,&b);
	
	if(a<b){
		printf("a < b\n");
	}else if(a>b){
		printf("a > b\n");
	}else{
		printf("a == b\n");
	}
		
	return 0;
	}

Measured memory_bytes: 580
N = int(input())
S_count = dict()

for _ in range(N):
    tmp = input()
    if tmp not in S_count:
        S_count[tmp] = 1
    else:
        S_count[tmp] += 1

M = int(input())
T_count = dict()

for _ in range(M):
    tmp = input()
    if tmp not in T_count:
        T_count[tmp] = 1
    else:
        T_count[tmp] += 1

max_v = 0

for e in S_count:
    t = 0 if e not in T_count else T_count[e]

    if S_count[e] - t > max_v:
        max_v = S_count[e] - t

print(max_v)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;

void PUNKS_NOT_DEAD() {
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0, mn = 2e9;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] <= mn) {
            ans++;
        }
        mn = min(mn, a[i]);
    }
    cout << ans;
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false), cin.tie(0);
    PUNKS_NOT_DEAD();
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
#define INF 100100100

typedef long long ll;
typedef pair<int, int> p;


int main(){
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  ll res = 0;
  vector<vector<int>> vv(n,vector<int>(m));

  for (int i = 0; i < n; i++) {
    int score = c;
    for (int j = 0; j < m; j++) {
      cin >> vv[i][j];
      score += b[j] * vv[i][j];
    }
    res += (score > 0);
  }
  cout << res << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(n) for(int i=0;i<n;i+=1)
#define fill(c,v) memset(c,v,sizeof(c));
#define _h cout<<"here"<<endl;
#define pr(a) cout<<a<<endl;
#define prarr(a,n) rep(n) cout<<a[i]<<" \n"[i==n-1]; 
#define fi first
#define se second
#define pu push_back
#define inf 1000000001
#define MOD 1000000007 
#define INF 100000000000001
// const int MAXN;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k;
    string s;
    cin>>s;
    cin>>k;
    int n = s.length();
    set<string> s1;
    vector<string> v;
    rep(n)
    {
    	for(int j = 1; j<=6;j++)
    	{
    		// if(i==0 && j==0) continue;
    		if(i+j<=n)
    		{
    			s1.insert(s.substr(i,j));
    		}
    	}
    }
    for(auto i : s1)
    	v.push_back(i);
    // sort(v.begin(), v.end());
    // rep(v.size())
    // {
    // 	cout<<v[i]<<endl;
    // }
    if(v.size()>=k)
    	cout<<v[k-1]<<endl;
    else
    	cout<<v.size()<<endl;
    return 0;

}


Measured memory_bytes: 2560
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long LL;
LL n, m, a, b, p;
LL sum = 0;
struct NOOD{
	LL a, b;
}num[100010];
bool cmp(NOOD x, NOOD y){
	return x.a < y.a;
}
int main()
{
	scanf("%lld%lld", &n, &m);
	for(int i = 1; i <= n; i++){
		scanf("%lld%lld", &num[i].a, &num[i].b);
	}
	sort(num + 1, num + n + 1, cmp);
	for(int i = 1; i <= n; i++){
		sum += num[i].b;
		if(sum >= m){
			p = num[i].a;break;
		}
	}
	printf("%lld\n", p);
}

Measured memory_bytes: 1664
#include <iostream>
#include <sstream>
#include <string>

#if defined SUBLIME
#  define ISTREAM ss
#else
#  define ISTREAM cin
#endif


using namespace std;
int main()
{
	string a;
	#if defined SUBLIME
		string str = "3 2\n2 2\n5 3\n0 0";
		stringstream ss;
		ss << str;
	#endif
	while(true)
	{
		int a, b, min, max;
		ISTREAM >> a >> b;
		if(a == 0 && b == 0)
		{
			break;
		}
		else if(a < b)
		{
			min = a;
			max = b;
		}
		else
		{
			min = b;
			max = a;
		}
		cout << min << " " << max << endl;
	}
}

Measured memory_bytes: 3024
#include <iostream>
#include <string>
using namespace std;
void reverse(string str)
{
	int n = str.size();
	for (int i = 0;i < n / 2;i++)
	{
		swap(str[i],str[n-1-i]);
	}
	cout << str;
}
int main ()
{
	long long n;
	cin >> n;
	string s = "";
	while (n--)
	{
		s+= 'a' + (n%26);
		n/=26;
	}
	reverse(s);
	return 0;
}

Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int main(){
	int a = 0;
	int b = 0;
	cin >> a >> b;
	if (a > b){
		cout << "a > b" << endl;
	}
	else if (a < b){
		cout << "a < b" <<endl;
	}
	else if (a == b){
		cout << "a == b" << endl;
	}
	return 0;
}

Measured memory_bytes: 3064