akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define repp(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define popcnt __builtin_popcount
#define all(v) v.begin(),v.end()
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?GCD(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/GCD(a,b);}

int main(){
    ll a,b,c; cin >> a >> b >> c;
    long double cb = (float)sqrt(c)-(float)sqrt(a);

    if(sqrt((long double)a/(long double)c) + sqrt((long double)b/(long double)c) < 1) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

void solve() {
	string str; cin >> str;
	for (auto& c : str) {
		c = (c == '?') ? 'D' : c;
	}
	cout << str << "\n";
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	#endif
	solve();
	return 0;
}


Measured memory_bytes: 3780
use rand::Rng;
fn main() {
    let start=std::time::Instant::now();
    proconio::input! {
        d: usize,
        c: [i64;26],
        s: [[i64;26];d],
    }
    let mut t=vec![0;d];
    let mut last=[0;26];
    for (i,t) in t.iter_mut().enumerate() {
        let mut m=std::i64::MIN;
        let mut k=0;
        for j in 0..26 {
            let p=last[j];
            let mut v=0;
            v+=s[i][j];
            last[j]=i+1;
            for (&c,&last) in c.iter().zip(last.iter()) {
                v-=c*(i+1-last)as i64;
            }
            if m<v {
                m=v;
                k=j;
            }
            last[j]=p;
        }
        last[k]=i+1;
        *t=k;
    }
    let mut v=f(&c,&s,&t);
    let mut rng = rand::thread_rng();
    while start.elapsed().as_secs_f64()<1.8 {
        let r: usize=rng.gen_range(0, d*26);
        let i=r/26;
        let q=r%26;
        let p=t[i];
        t[i]=q;
        let w=f(&c,&s,&t);
        if w>v {
            v=w;
        }
        else {
            t[i]=p;
        }
    }
    for t in t {
        println!("{}",t+1);
    }
}
fn f(c: &Vec<i64>, s: &Vec<Vec<i64>>, t: &Vec<usize>) -> i64 {
    let mut last=[0;26];
    let mut v=0;
    for (i,&t) in t.into_iter().enumerate() {
        v+=s[i][t];
        last[t]=i+1;
        for (&c,&last) in c.iter().zip(last.iter()) {
            v-=c*(i+1-last)as i64;
        }
    }
    v
}

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

using namespace std;

int main(){
    int n; cin >> n;
    int max_h=-1, ans=0;
    for(int i=0; i<n; ++i){
        int h; cin >> h;
        if(h>=max_h) ++ans;
        max_h=max(max_h, h);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 47588
#include <iostream>
using namespace std;
#define MAX 100000

int parent(int k) { return k / 2; }
int left(int k) { return 2 * k; }
int right(int k) { return 2 * k + 1; }
int main() {
	int H, A[MAX + 1];

	cin >> H;
	for (int i = 1; i <= H; i++) cin >> A[i];

	for (int i = 1; i <= H; i++) {
		cout << "node " << i << ": key = " << A[i] << ", ";
		if (parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
		if (left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
		if (right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
		cout << endl;
	}
}


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

using namespace std;

const int MAX = 20 * 20 * 20 * 20;
int coin[4] = {10, 50, 100, 500};

int change(int a, int b, int c, int d, int p) {
  int sum = 10 * a + 50 * b + 100 * c + 500 * d - p;
  if (sum < 0) return MAX + 1;

  int res = 0;
  for (int i = 3; i >= 0; i--) {
    res += sum / coin[i];
    sum %= coin[i];
  }

  return res;
}

int main(void) {
  int p;
  bool flag = false;
  while (cin >> p, p) {
    if (flag) cout << endl;

    vector<int> c(4);
    int sumc = 0;
    for (int i = 0; i < 4; i++) {
      cin >> c[i];
      sumc += c[i];
    }

    int minc = MAX + 1;
    int ans[4] = {};
    for (int i = 0; i <= c[0]; i++) {
      for (int j = 0; j <= c[1]; j++) {
        for (int k = 0; k <= c[2]; k++) {
          for (int l = 0; l <= c[3]; l++) {
            int payc = i + j + k + l;
            if (sumc - payc + change(i, j, k, l, p) < minc) {
              ans[0] = i, ans[1] = j, ans[2] = k, ans[3] = l;
              minc = sumc - payc + change(i, j, k, l, p);
            }
          }
        }
      }
    }

    for (int i = 0; i < 4; i++) {
      if (ans[i]) {
        cout << coin[i] << " " << ans[i] << endl;
      }
    }

    flag = true;
  }

  return 0;
}


Measured memory_bytes: 3088
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;


int n;
int a[100002];
int fron[100002];
int bak[100002];
int main(){
	scanf("%d",&n);
	for (int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	sort(a,a+n);
	fron[0] = a[0];
	for (int i=1;i<n;i++){
		fron[i] = __gcd(a[i], fron[i-1]);
	}
	bak[n-1] = a[n-1];
	for (int i=n-1;i>0;i--){
		bak[i-1] = __gcd(a[i-1], bak[i]); 
	}
	int maxi = max(fron[n-2], bak[1]);

	for (int i=1;i<n-1;i++){
		maxi = max(maxi, __gcd(fron[i-1], bak[i+1]));
	}
	printf("%d\n",maxi);
	return 0;
}
	

Measured memory_bytes: 1280
#include <stdio.h>
#include <algorithm>

using namespace std;

typedef long long lli;

lli a[100001], A, B;
int n;

int main() {
	scanf("%d %lld %lld",&n,&A,&B);
	for(int i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
	}
	lli res=0;
	for(int i=2;i<=n;i++) {
		res+=min(B,(a[i]-a[i-1])*A);
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	int x,y;
	scanf("%x",&x);
	scanf("%x",&y);
	if(x<y)puts("<");
	else if(x>y)puts(">");
	else puts("=");
	return 0;
}

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

int main(){
  char s[100006];
  bool f = false;
  bool same = false;

  scanf("%s", s);

  int n;
  n = strlen(s);

  if(n % 2 == 0) f = true;
  if(s[0] == s[n - 1]) same = true;

  if(f^same) printf("Second\n");

  else printf("First\n");

  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#include <tuple>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000000; //10^18
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}



int main(void) {

  ll x, k, d;
  cin >> x >> k >> d;

  if (x < 0) x = -x;

  if (x/d >= k) cout << x - d*k << endl;
  else {
    k -= x/d;
    x -= d*(x/d);
    if (k % 2 == 0) cout << x << endl;
    else cout << d-x << endl;
  }

  return 0;

}
      


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

int main(void){
    int i,j,r,c,tmp,tmp2=0;
    int col[100]={0};
    cin >> r >> c;
    for(i=0;i<r;i++){
        tmp2=0;
        for(j=0;j<c;j++){
            cin >> tmp;
            col[j] += tmp;
            tmp2 += tmp;
            cout << tmp << " ";
        }
        cout << tmp2 << endl;
    }
    tmp=0;
    for(i=0;i<c;i++){
        cout << col[i] << " ";
        tmp += col[i];
    }
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 3084
//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(long long int i=0;i<n;i++)
#define FORR(i,n) for(long long int i=n;i>=0;i--)
#define pb push_back
#define vlli vector<long long int>
#define slli set<long long int>
#define mlli map<long long int,long long int>
#define lli long long int 
#define test lli tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define MOD 1000000007
using namespace std;
lli n,arr[100001][3],dp[100001][3];
lli go(lli ind,lli prev){
	if(ind==n) return 0;
	if(dp[ind][prev])return dp[ind][prev];
	else{
		lli a=INT_MIN;
		FOR(i,3){
			if(i!=prev)
				a=max(a,go(ind+1,i)+arr[ind][i]);
		}
		dp[ind][prev]=a;
		return dp[ind][prev];
	}
	
}
void solve(){

	cin>>n;
	FOR(i,n){
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
	}
	
	cout<<go(0,-1);
}


int32_t main() {
    	solve();
    return 0;
}

// Problem : C - Vacation
// Contest : Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)



Measured memory_bytes: 11136
#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 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main(){
    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200){
        cout << s << endl;
    }
    else{
        cout << "red" << endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i < N; i++) {
    cin >> a.at(i);
  }
  int gray=0, blown=0, green=0, aqua=0, blue=0, yellow=0, orange=0, red=0, anycolor=0;
  int zero_count = 8;
  for (int i=0; i < N; i++) {
    if (a.at(i) < 400){
      if (gray == 0) {
        zero_count -= 1;
      }
      gray += 1;
    }
    else if (a.at(i) < 800) {
      if (blown == 0) {
        zero_count -= 1;
      }
      blown += 1;
    }
    else if (a.at(i) < 1200) {
      if (green == 0) {
        zero_count -= 1;
      }
      green += 1;
    }
    else if (a.at(i) < 1600) {
      if (aqua == 0) {
        zero_count -= 1;
      }
      aqua += 1;
    }
    else if (a.at(i) < 2000) {
      if (blue == 0) {
        zero_count -= 1;
      }
      blue += 1;
    }
    else if (a.at(i) < 2400) {
      if (yellow == 0) {
        zero_count -= 1;
      }
      yellow += 1;
    }
    else if (a.at(i) < 2800) {
      if (orange == 0) {
        zero_count -= 1;
      }
      orange += 1;
    }
    else if (a.at(i) < 3200) {
      if (red == 0) {
        zero_count -= 1;
      }
      red += 1;
    }
    else {
      anycolor += 1;
    }    
  }
  int min_colors, max_colors;
  int nontop_ranks = (8-zero_count);
  if (anycolor == N) {
    min_colors = 1;
  }
  else {
    min_colors = nontop_ranks;
  }
  max_colors = nontop_ranks + anycolor;
  cout << min_colors << " " << max_colors << endl;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.security.cert.CollectionCertStoreParameters;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
 
	int[] f;
	boolean[] cycle;
	ArrayList<Integer>[] g;
	int n;
	int[] p;
 
	public void run() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		p = new int[n];
		g = new ArrayList[n];
		cycle = new boolean[n];
		f = new int[n];
		for (int i = 0; i < n; ++i) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < n; ++i) {
			p[i] = sc.nextInt();
			--p[i];
			g[p[i]].add(i);
		}
 
		int v = 0;
		for (int i = 0; i < n; ++i) {
			v = p[v];
		}
		for (int i = 0; i < n; ++i) {
			cycle[v] = true;
			v = p[v];
		}
		Arrays.fill(f, -1);
		for (int i = 0; i < n; ++i) {
			if (!cycle[i] && f[i] == -1) {
				dfs(i);
			}
		}
 
		boolean ans = false;
		ArrayList<Integer> lis = new ArrayList<>();
		for (int dst : g[v]) {
			if (f[dst] != -1)
				lis.add(f[dst]);
		}
		ans |= solve(v, fgrundy(lis));
		ans |= solve(v, sgrundy(lis));
		System.out.println(ans ? "POSSIBLE" : "IMPOSSIBLE");
	}
 
	boolean solve(int v, int val) {
		int[] h = Arrays.copyOf(f, n);
		h[v] = val;
		for (int u = p[v]; u != v; u = p[u]) {
			ArrayList<Integer> lis = new ArrayList<>();
			for (int dst : g[u]) {
				lis.add(h[dst]);
			}
			h[u] = fgrundy(lis);
		}
		ArrayList<Integer> lis = new ArrayList<>();
		for (int d : g[v]) {
			lis.add(h[d]);
		}
		return fgrundy(lis) == val;
	}
 
	int sgrundy(ArrayList<Integer> lis) {
		lis.add(fgrundy(lis));
		return fgrundy(lis);
	}
 
	int fgrundy(ArrayList<Integer> lis) {
		Collections.sort(lis);
		if (lis.isEmpty() || lis.get(0) != 0)
			return 0;
		else {
			for (int i = 1; i < lis.size(); ++i) {
				if (lis.get(i - 1) + 1 < lis.get(i)) {
					return lis.get(i - 1) + 1;
				}
			}
			return lis.get(lis.size() - 1) + 1;
		}
	}
 
	void dfs(int cur) {
		ArrayList<Integer> lis = new ArrayList<>();
		for (int dst : g[cur]) {
			if (f[dst] == -1)
				dfs(dst);
			lis.add(f[dst]);
		}
		f[cur] = fgrundy(lis);
	}
 
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

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

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

	int n;
	long long int c,k,t;
	vector <long long int> v;

	cin >> n >> c >> k;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		v.push_back(t);
	}

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

	int res = 1;
	long long int time = 0;
	long long int num = 1;

	time = v[0] + k;

	for(int i=1;i<n;i++)
	{
		if(time < v[i])
		{
			res++;
			num = 1;
			time = v[i] + k;
		}
		else
		{
			if(num == c)
			{
				res++;
				num = 1;
				time = v[i] + k;
			}
			else
			{
				num += 1;
			}
		}
	}

	cout << res << '\n';
	
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=1000000007;

int main(){
	int n;
	cin>>n;
	int a[n];
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	bool p[1000001]={};
	int ans=0;
	rep(i,n){
		if(p[a[i]])continue;
		int j=1;
		while(a[i]*j<1000001){
			p[a[i]*j]=true;
			j++;
		}
		if(i<n&&a[i]!=a[i+1])ans++;
	}
  puts(ans);
}


Measured memory_bytes: 5388
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define mod 1000000007
#define inf 2147483647
#define range(x,a,b) (a)<=x&&x<=(b)
int main(){
	string s;
	cin>>s;
	if(s[1]=='B')s[1]='R';
	else s[1]='B';
	cout<<s;
	return 0;
}

Measured memory_bytes: 3616
# inserton
n=int(input())
lists=list(map(int,input().split()))
flag=True
for i in range(n):
    if i+1<lists[i]:
        flag=False
        break
if not flag:
    print(-1)
else:
    #if flag
    ans=[]
    for i in range(n):
        for j in range(n-1-i,-1,-1):
            if lists[j]==j+1:
                ans.append(lists[j])
                del lists[j]
                break
    ans=ans[::-1]
    for some in ans:
        print(some)
                
            
        

Measured memory_bytes: 3064
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

void solve(long long a_I, long long a_O, long long a_T, long long a_J,
           long long a_L, long long a_S, long long a_Z) {
  ll ans = 0;
  ans += (a_I / 2) * 2;
  ll a_I_rest = a_I % 2;

  ans += a_O;

  ans += (a_J / 2) * 2;
  ll a_J_rest = a_J % 2;

  ans += (a_L / 2) * 2;
  ll a_L_rest = a_L % 2;

  ll rest = a_I_rest + a_J_rest + a_L_rest;
  if (rest == 3) {
    ans += 3;
  } else if (rest == 2) {
    if (a_I_rest == 1) {
      if (a_J_rest == 1) {
        if (a_L > 0) {
          ans++;
        }
      } else {
        if (a_J > 0) {
          ans++;
        }
      }
    } else {
      if (a_I > 0) {
        ans++;
      }
    }
  }

  print(ans);
}

int main() {
  long long a_I;
  scanf("%lld", &a_I);
  long long a_O;
  scanf("%lld", &a_O);
  long long a_T;
  scanf("%lld", &a_T);
  long long a_J;
  scanf("%lld", &a_J);
  long long a_L;
  scanf("%lld", &a_L);
  long long a_S;
  scanf("%lld", &a_S);
  long long a_Z;
  scanf("%lld", &a_Z);
  solve(a_I, a_O, a_T, a_J, a_L, a_S, a_Z);
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int s = 0;
    reps(i, n - 1) s ^= (a[0] ^ a[i]);
    rep(i, n) cout << (a[i] ^ s) << " ";
    cout << endl;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}

Measured memory_bytes: 4748
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vvint st(n,vint(10,0));
    REP(i,n){
        string s;
        cin >> s;
        REP(j,10){
            st[i][j]=s[j]-'a';
        }
        sort(ALL(st[i]));
    }
    sort(ALL(st));
    ll now=1;
    ll ans = 0;
    for(int i=1;i<n;i++){
        bool same = true;
        REP(j,10){
            if(st[i][j]!=st[i-1][j]){
                same=false;
                break;
            }
        }
        if(same){
            now++;
        }else{
            ans+=(now)*(now-1)/2;
            now=1;
        }
    }
    ans+=(now)*(now-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7296
N = int(input())
H = list(map(int, input().split()))

fl = True
for i in range(1,N):
    if H[i]-H[i-1]>0:
        H[i] -= 1

for i in range(1,N):
    if H[i]-H[i-1]<0:
        fl = False
        break

print('Yes') if fl else print('No')

Measured memory_bytes: 14252
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define ld long double
#define F first
#define S second
//
#define int long long
#define ll long long
#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 db4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define db5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define db6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
//
#define mem(x,y) memset(x,y,sizeof(x))
#define bitcount    __builtin_popcount
//
#define pii pair<int, int>
#define all(v) v.begin(),v.end()
//
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define vi vector<int>
#define vvi vector< vector<int> >
#define si set<int>
#define pb push_back
#define lp(i,a,b) for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define mk make_pair
const int N=2e5+3;
const int mod=1e9+7;
const int mod1=998244353;
const int inf=1e16+7;
using namespace std;

void solve(){
    int n;
    cin>>n;
    string s;
    unordered_map<string, int> mp;
    while(n--){
        cin>>s;
        mp[s]++;
    }
    cout<<mp.size();
}
 

int32_t main() {
    IOS;
    int t;
   // cin>>t;
    
    t=1;
    for(int i=1;i<=t;i++){
       // cout<<"Case #"<<i<<": ";
        solve();
        cout<<'\n';
    }
   
}

















Measured memory_bytes: 17648
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] strs = sc.nextLine().split("");
        final String NG = "x";
        int cnt = 0;
        for (String str : strs) {
            if (str.equals(NG)) {
                cnt++;
                if (cnt == 8) {
                    System.out.println("NO");
                    return;
                }
            }
        }
        System.out.println("YES");
    }
}

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

int main(){
  int n,x;
  cin >> n >> x;
  int ans = 0;
  vector<int> d(n);
  for(int i = 0; i < n; i++){
    cin >> d[i];
    x -= d[i];
    ans++;
  }
  int m = *min_element(d.begin(),d.end());
  ans += x / m;
  cout << ans << endl;
}

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

int main(){
  int day;
  cin >> day;
  day += 3;
  day %= 7;
  switch(day){
    case 0: cout << "mon" << endl;  break;
    case 1: cout << "tue" << endl;  break;
    case 2: cout << "wed" << endl;  break;
    case 3: cout << "thu" << endl;  break;
    case 4: cout << "fri" << endl;  break;
    case 5: cout << "sat" << endl;  break;
    case 6: cout << "sun" << endl;  break;
  }
}



Measured memory_bytes: 3116
using System;

namespace Volume0_0010
{
    class Program
    {
        static void Main(string[] args)
        {
            int len = Convert.ToInt32(Console.ReadLine());

            for(int i = 0; i < len;i++)
            {
                String[] inputs = Console.ReadLine().Split(' ');
                double x1 = Convert.ToDouble(inputs[0]);
                double y1 = Convert.ToDouble(inputs[1]);
                double x2 = Convert.ToDouble(inputs[2]);
                double y2 = Convert.ToDouble(inputs[3]);
                double x3 = Convert.ToDouble(inputs[4]);
                double y3 = Convert.ToDouble(inputs[5]);

                double a1 = 2 * (x2 - x1);
                double b1 = 2 * (y2 - y1);
                double c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
                double a2 = 2 * (x3 - x1);
                double b2 = 2 * (y3 - y1);
                double c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;

                double x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
                double y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
                double r = Math.Sqrt(Math.Pow((x1-x),2)+(Math.Pow(y1-y,2)));

                x = (Math.Round(x * 1000)) / 1000;
                y = (Math.Round(y * 1000)) / 1000;
                r = (Math.Round(r * 1000)) / 1000;

                Console.WriteLine(x.ToString("F3") + " " + y.ToString("F3") + " " + r.ToString("F3"));
            }
        }
    }
}

Measured memory_bytes: 5808
r, c = map(int, input().split())
a = [[0 for i in range(c+1)] for j in range(r+1)]
for i in range(r):
    j = 0
    for line in input().split():
        a[i][j] = int(line)
        a[i][c] += a[i][j]
        j += 1
for i in range(c+1):
    for j in range(r):
        a[r][i] += a[j][i]
for i in range(r+1):
    for j in range(c+1):
        if j == c:
            print(a[i][j])
        else:
            print(a[i][j], end=" ")

Measured memory_bytes: 8344
#include<bits/stdc++.h>
#define M 1000000007
#define pb push_back
#define ll long long int
using namespace std;

int main()
{
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	int i;
	for(i=0;i<n;i++)
		cin>>a[i]>>b[i]>>c[i];

	int dp1[n],dp2[n],dp3[n];
	dp1[0] = max(b[0],c[0]);
	dp2[0] = max(a[0],c[0]);
	dp3[0] = max(a[0],b[0]);
	for(i=1;i<n;i++)
	{
		dp1[i] = max(b[i]+dp2[i-1] , c[i]+dp3[i-1]);
		dp2[i] = max(a[i]+dp1[i-1] , c[i]+dp3[i-1]);
		dp3[i] = max(a[i]+dp1[i-1] , b[i]+dp2[i-1]);
	}
	int ans = dp1[n-1];
	ans = max(ans,dp2[n-1]);
	ans = max(ans,dp3[n-1]);
	cout<<ans;
}


Measured memory_bytes: 5920
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
	int n;

	cin >> n;

	if (n % 111 == 0) {
		cout << (n / 111) * 111 << endl;;
	}
	else {
		cout << (n / 111 + 1) * 111 << endl;
	}


	return 0;
}

Measured memory_bytes: 256
class BIT():

    def __init__(self, n):
        '''
        n = 要素数
        添字は i = 0 ~ n-1 となる
        '''
        self.n = n
        self.bit = [0] * (n + 1)

    def add(self, i, x):
        '''i番目の要素にxを加算する'''
        i = i + 1
        while i <= self.n:
            self.bit[i] += x
            i += i & -i

    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def get(self, i, j):
        '''[i, j)の和を求める'''
        return self._sum(j) - self._sum(i)


n, k = map(int, input().split())
a = [int(input()) for _ in range(n)]

#いい感じに式変形した結果の配列をつくる
#cumsum_a[i] <= cumsum_a[j]を満たすi<jの組の個数が答えになる
cumsum_a = [0]*(n+1)
for i in range(n):
    cumsum_a[i+1] = cumsum_a[i] + a[i]
for i in range(n+1):
    cumsum_a[i] = cumsum_a[i] - k*i

#座標圧縮したリストを返す
def compress(list1):
    list2 = sorted(set(list1))
    memo = {value : index for index, value in enumerate(list2)}
    for i in range(len(list1)):
        list1[i] = memo[list1[i]]
    return list1

cumsum_a = compress(cumsum_a)

bit = BIT(n+1)
ans = 0
for i in range(n+1):
    ans += bit.get(0, cumsum_a[i] + 1)
    bit.add(cumsum_a[i], 1)
print(ans)

Measured memory_bytes: 51340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int N,M;
    cin >> N >> M;
    int cnt = 0;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        int A;
        cin >> A;
        cnt += A;
        vec.at(i) = A;
    }
    int cnt2 = 0;
    for(int i = 0;i < N;i++) {
        if(vec.at(i) >= (cnt + 4 * M - 1) / (4 * M)) {
            cnt2++;
        }
    }
    if(cnt2 >= M) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    int ansa = 0, ansb = 0, ansc = 0, ansd = 0;
    double total = 0.0;
    for (int a = 0; a <= F / (100 * A); ++a)
    {
        for (int b = 0; b <= (F - 100 * a * A) / (100 * B); ++b)
        {
            for (int c = 0; c <= (E * (a * A + b * B) / C) && c <= (F - 100 * (a * A + b * B)) / C; ++c)
            {
                int d = MAX(MIN(E * (a * A + b * B) - c * C, F - 100 * (a * A + b * B) - c * C), 0) / D;
                double prob = (double)(c * C + d * D) / (double)(100 * (a * A + b * B) + (c * C + d * D));
                if (total < prob)
                {
                    ansa = a; ansb = b; ansc = c; ansd = d;
                    total = prob;
                }
            }
        }
    }

    if (ansa == 0 && ansb == 0 && ansc == 0 && ansd == 0) ansa = 1;
    cout << 100 * (ansa * A + ansb * B) + ansc * C + ansd * D << " " << ansc * C + ansd * D << "\n";
    return 0;
}



Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
a = Array.new m
b = Array.new m 
hash = {}
m.times do |i|
  _a, _b = gets.split.map(&:to_i)
  a[i] = _a 
  b[i] = _b
  hash[_a] ||= []
  hash[_a].push(_b)
  hash[_b] ||= []
  hash[_b].push(_a)
end

queue = [1]

result = {1 => 0}
while q = queue.shift do
  hash[q].each do |x|
    unless result[x]
      result[x] = q
      queue.push x
    end
  end
end

if result.size  == n
  puts "Yes"
  2.upto(n) do |i|
    puts result[i]
  end
else
  puts "No"
end

Measured memory_bytes: 42920
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

const int MAX_M = 55560;

int main() {
    int N;
    cin >> N;
    vector<bool> is_prime(MAX_M, true);
    is_prime[0] = is_prime[1] = false;

    for (int i = 2; i * i < MAX_M; ++i) {
        if (is_prime[i]) {
            for (int j = 2 * i; j < MAX_M; j += i) {
                is_prime[j] = false;
            }
        }
    }

    vector<int> res;
    int cur = 0;
    while (res.size() < N && cur < MAX_M) {
        while (!is_prime[cur]) cur++;
        if (cur % 5 == 1) {
            res.push_back(cur);
        }
        ++cur;
    }

    assert(res.size() == N);
    for (int i = 0; i < N; ++i) {
        cout << res[i] << endl;
    }
    return 0;
}

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

int m;
double *v;
double a[2];
double tmp;

int main(){
	while(true){
		for(int k=0; k<2; k++){
			cin >> m;
			if(!m)
				return 0;

			a[k] = 0;
			tmp = 0;

			v = new double[m];
			for(int i=0; i<m-1; i++){
				cin >> v[i];
				tmp += v[i];
			}
			v[m-1] = 360-tmp;

			for(int i=0; i<m; i++)
				a[k] += sin(v[i]*M_PI/360)*cos(v[i]*M_PI/360);
			delete[] v;
		}

		if(a[0] == a[1])
			cout << 0 << endl;
		else if(a[0] > a[1])
			cout << 1 << endl;
		else
			cout << 2 << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  
  if(a%3==0 || b%3==0 || (a+b)%3==0) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}


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

int count(int n, int x){
    int cnt = 0;
    for (int i = 1; i <= n-2; i++){
        for (int j = i+1; j <= n-1; j++){
            for (int k = j+1; k <= n; k++){
                if(i + j + k == x)cnt ++;
            }
        }
    }
    return cnt;
}

int main(){
    int n,x;
    
    while(1){
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        cout <<count(n, x) << endl;
    }
    return 0;
}


Measured memory_bytes: 3000
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CReplacingInteger {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N, K;
        cin >> N >> K;

        if (N >= K) {
            cout << min(N % K, K - (N % K)) << endl;
        } else {
            cout << min(K - N, N) << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CReplacingInteger solver;
    solver.solve(in, out);
    return 0;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int N, L; cin >> N >> L;
	vector< string > str(N);
	for_(i,0,N) cin >> str[i];
	sort(str.begin(), str.end());
	cout << accumulate(str.begin(), str.end(), string("")) << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int counter = 0;
  for(int i = 0; i < n; i += 2) {
    if(v[i] % 2 == 1) {
      counter++;
    }
  }
  cout << counter << '\n';
}


Measured memory_bytes: 3560
#include <iostream>
#include <algorithm> 
#include <vector>
#include <cmath>


using namespace std;

int main () {
    int N;
    cin >> N;
    vector <int>h(N);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    
    vector <int>dp(N);
    dp[0] = 0;
    for (int i = 1 ; i < N; i++)
    {
        dp[i] = i > 1 ? min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i])) : abs(h[0] - h[1]);
    }
    cout << dp[N - 1] <<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

    int n = s.size();
    int m = t.size();

    vector<set<int>> vs(26);
    rep(i, s.size()) {
        int ci = s[i] - 'a';
        vs[ci].insert(i);
    }

    ll ans = 0;
    int pos = -1;
    rep(i, m) {
        int x = t[i] - 'a';

        // t[i]がsに存在しない
        if (vs[x].empty()) {
            cout << -1 << endl;
            return 0;
        }

        auto ub = vs[x].upper_bound(pos);
        if (ub != vs[x].end()) {
            ans += *ub - pos;
            pos = *ub;
        } else {
            ans += n - pos;
            auto ub = vs[x].upper_bound(-1);
            ans += *ub;
            pos = *ub;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String Sei = sc.nextLine();
		String[] array = Sei.split("/");
		String Str = "";
		for(int i = 0;i < array.length;i++) {
			Str +=array[i];
		}
		int in = Integer.parseInt(Str);
		if(in <= 20190430) {
			System.out.println("Heisei");
		}else {
			System.out.println("TBD");
		}
	}

}


Measured memory_bytes: 22480
#include <stdio.h>

main()
{
    int a, b, w;

    scanf("%d %d %d", &w, &a, &b);

    if(b>a+w) printf("%d\n", b-a-w);

    else if(b<=a+w && b+w>=a) printf("%d\n", 0);

    else if(b+w<a) printf("%d\n", a-b-w);




}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<vector>
#define N_ 100100
using namespace std;
int n, m;
int UF[N_];
vector<int>G[N_];
int Find(int a) {
	if (a == UF[a])return a;
	return UF[a] = Find(UF[a]);
}
void Merge(int a, int b) {
	a = Find(a), b = Find(b);
	if (a != b)UF[a] = b;
}
int main() {
	int i, j, c, a;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++) {
		scanf("%d", &c);
		UF[i] = i;
		while (c--) {
			scanf("%d", &a);
			G[a].push_back(i);
		}
	}
	for (i = 1; i <= m; i++) {
		for (j = 1; j < G[i].size(); j++) {
			Merge(G[i][j - 1], G[i][j]);
		}
	}
	for (i = 1; i <= n; i++) {
		if (Find(i) != Find(1)) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
}

Measured memory_bytes: 5372
import math

def f(b, n):
    if n < b:
        return n
    return f(b, n // b) + (n % b)

"""
kari1 = 87654
kari2 = 30          #10
kari1 = 87654
kari2 = 138         #100
kari1 = 87654
kari2 = 45678       #-1
kari1 = 31415926535
kari2 = 1           #31415926535
kari1 = 1
kari2 = 31415926535 #-1
n = int(kari1)
s = int(kari2)
"""
n = int(input())
s = int(input())

if n < s:
    print(-1)
elif n == s:
    print(n + 1)
else:
    b = 2
    while b * b <= n:
        if s == f(b, n):
            is_b = True
            break
        b += 1
    if b * b <= n:
        print(b)
    else:
        p = 1
        ans = -1
        while p * p <= n:
              if (n - s) % p != 0:
                    p += 1
                    continue
              else:
                    b = (n - s) // p + 1
                    if s == f(b, n):
                        ans = min(b, ans) if ans != -1 else b
              p += 1
        print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define INX(x) (cin >> x)
#define OUTX(x) (cout << x << endl)

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>


int main()
{
    ll N;
    INX(N);

    ll base;
    INX(base); //最初はA0でそれより高いものが現れたら更新

    ll result = 0;
    for (ll i = 1; i < N; i++)
    {
        ll tmp;
        INX(tmp); //Ai

        if(base < tmp)
        {
            base = tmp;
        }
        else if(base > tmp)
        {
            result += base - tmp;
        }
    }
    OUTX(result);



    return 0;
}


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

int main() {
    cout << fixed << setprecision(10);
  double a,b; cin>>a>>b;
  cout<<a/b<<endl;
}


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

using namespace std;

int main() {
	int N,min,ans=1;
	cin >> N;
	vector<int> A(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A.at(i);
	}
	min = A.at(0);
	for (size_t i = 1; i < N; i++)
	{
		if (A.at(i)<=min)
		{
			min = A.at(i);
			ans++;
		}
	}
	cout << ans;

}

Measured memory_bytes: 1024
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    map<int,int>m;
    for(int i=0;i<n;i++){
        m[a[i]]++;
        m[a[i]-1]++;
        m[a[i]+1]++;
    }
    int ans=0;
    for(int i=0;i<=100000;i++){
        chmax(ans,m[i]);
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin >> S;
    for(int i = 0; i < 2; i++){
        if(S[i] != S[i+1]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No"  << endl;
}


Measured memory_bytes: 256
#include<map>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define gt getchar()
#define ll long long
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
inline int in()
{
	int k=0;char ch=gt;
	while(ch<'-')ch=gt;
	while(ch>'-')k=k*10+ch-'0',ch=gt;
	return k;
}
const int N=3005,YL=1e9+7,inv2=5e8+4;
inline int MO(const int &x){return x>=YL?x-YL:x;}
inline int ksm(int a,int k){int r=1;while(k){if(k&1)r=1ll*r*a%YL;a=1ll*a*a%YL,k>>=1;}return r;}
int a[N],f[N][N],g[4][N];
int main()
{
	int n=in(),Q=in();int ans=ksm(2,Q);
	for(int i=1;i<=n;++i)a[i]=in();
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			f[i][j]=(a[i]<a[j]);
	while(Q--)
	{
		int x=in(),y=in();
		for(int i=1;i<=n;++i)g[0][i]=f[x][i],g[1][i]=f[y][i];
		for(int i=1;i<=n;++i)g[2][i]=f[i][x],g[3][i]=f[i][y];
		for(int i=1;i<=n;++i)f[y][i]=f[x][i]=1ll*inv2*MO(g[0][i]+g[1][i])%YL;
		for(int i=1;i<=n;++i)f[i][x]=f[i][y]=1ll*inv2*MO(g[2][i]+g[3][i])%YL;
		f[x][y]=f[y][x]=1ll*inv2*MO(g[0][y]+g[1][x])%YL;
	}
	int sum=0;
	for(int i=1;i<=n;++i)
		for(int j=1;j<i;++j)
			sum=MO(sum+f[i][j]);
	printf("%lld\n",1ll*ans*sum%YL);
	return 0;
}


Measured memory_bytes: 35456
S=input()
N=len(S)
A="".join([str(i%2) for i in range(N)])
B="".join([str((i+1)%2) for i in range(N)])
print(min(sum([1 for i in range(N) if S[i]!=A[i]]),sum([1 for i in range(N) if S[i]!=B[i]])))

Measured memory_bytes: 9588