akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn f(vs: &[i64], i: usize, k: i64) -> bool {
    let mut dp = vec![vec![false; k as usize]; vs.len()];
    dp[0][0] = true;

    let mut j = 0;
    for (n, &v) in vs.iter().enumerate() {
        if n == i {
            continue;
        }
        for l in 0..dp[j].len() {
            if v as usize <= l {
                dp[j + 1][l] = dp[j][l] || dp[j][l - v as usize]
            } else {
                dp[j + 1][l] |= dp[j][l]
            }
        }
        j += 1;
    }

    for (j, &b) in dp[vs.len() - 1].iter().enumerate() {
        if k - vs[i] <= j as i64 && b {
            return true;
        }
    }
    false
}

fn main() {
    let (_, k) = scan!(usize, i64);
    let mut vs = scan!(i64;;);
    vs.sort();

    let (mut left, mut right) = (0, vs.len());
    while left < right {
        let mid = (left + right) / 2;
        if f(&vs, mid, k) {
            right = mid
        } else {
            left = mid + 1
        }
    }

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


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

long long n;
vector<long long> a, now;

long long solve();

int main() {
  cin >> n;
  a.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  for(int i = 0; i < n; ++i) {
    auto it = upper_bound(now.begin(), now.end(), a[i],
                          greater<long long>());
    if(it == now.end())
      now.push_back(a[i]);
    else
      *(it) = a[i];
  }
  return now.size();
}

Measured memory_bytes: 2168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int[] W=new int[10];
		int[] K=new int[10];
		for(int i=0; i<10; i++) {
			W[i]=sc.nextInt();
		}
		for(int i=0; i<10; i++) {
			K[i]=sc.nextInt();
		}
		Arrays.sort(W);
		Arrays.sort(K);
		pl(W[9]+W[8]+W[7]+" "+(K[9]+K[8]+K[7]));
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


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

int main(){
	
	int k,s;cin>>k>>s;
	int ans = 0;
	rep(i,k+1)rep(j,k+1)
	{
		if(i+j>s)continue;
		if(s-i-j > k) continue;
		ans++;
	}
	
	cout <<ans<< endl;
	
}

//cout << ans << endl;

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int X, Y, Z;
	X = getint();
	Y = getint();
	Z = getint();

	pair<int, int> BA[100000];
	int CA[100000];
	int CB[100000];

	ll goukeiA = 0;
	rep(i, X + Y + Z) {
		int a, b, c;
		a = getint();
		b = getint();
		c = getint();
		BA[i] = mp(b - a, i);
		CA[i] = c - a;
		CB[i] = c - b;
		goukeiA += a;
	}

	sort(BA, BA + X + Y + Z);

	ll C[100000] = {};
	priority_queue<int> que;
	rep(i, X) {
		que.push(CA[BA[i].second]);
	}
	rep(i, Z) {
		que.push(CA[BA[X + i].second]);
		C[i + 1] = C[i] + que.top();
		que.pop();
	}

	priority_queue<int> que2;
	reverse(BA, BA + X + Y + Z);
	ll B[100000] = {};
	rep(i, Y) {
		B[0] += BA[i].first;
		que2.push(CB[BA[i].second]);
	}
	rep(i, Z) {
		que2.push(CB[BA[Y + i].second]);
		B[i + 1] = B[i] + BA[Y + i].first + que2.top();
		que2.pop();
	}

	ll saidai = 0;
	rep(i, Z + 1) saidai = max(saidai, goukeiA + B[i] + C[Z - i]);

	co(saidai);

	Would you please return 0;
}

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

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String n = br.readLine();
		String str = br.readLine();
		String[] s = str.split(" ");

		for(int m = Integer.parseInt(n)-1; m >= 0; m--){
			if(m != 0){
				System.out.print(s[m] + " ");
			}else{
				System.out.println(s[m]);
			}
		}
	}
}

Measured memory_bytes: 24472
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;

int main(){
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  std::vector<std::vector<pair<int,int>> > x(n);
  rep(i,n){
    std::cin >> a[i];
    rep(j,a[i]){
      int d,dd;
      std::cin >> d>>dd;
      d--;
      x[i].pb(mk(d,dd));
    }
  }
  int ans=0;
  for(int bit=0;bit<(1<<n);bit++){
    std::vector<int> h(n);
    int dum=0;
    bool han=1;
    rep(i,n){
      if(bit&(1<<i)){
        h[i]=1;
        dum++;
      }else h[i]=0;
    }
    rep(i,n){
      if(bit&(1<<i)){
        rep(j,a[i]){
          if(h[x[i][j].fi]!=x[i][j].se)han=0;
        }
      }
    }
    if(han)ans=max(ans,dum);
  }
  std::cout << ans << std::endl;
}

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

int main() {
  int K;
  std::cin >> K;

  std::queue<long int> lunlun_que;
  for (int i = 1; i < 10; i++) lunlun_que.push(i);
  std::vector<long int> lunlun;

  for (int i = 0; i < K; i++) {
    long int v = lunlun_que.front();
    lunlun_que.pop();
    lunlun.push_back(v);

    long int r{v % 10};
    if (r != 0) lunlun_que.push(10 * v + r - 1);
    lunlun_que.push(10 * v + r);
    if (r != 9) lunlun_que.push(10 * v + r + 1);
  }
  std::sort(lunlun.begin(), lunlun.end());
  std::cout << lunlun[K - 1] << std::endl;
}

Measured memory_bytes: 2548
#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
#define PI  3.14159265

 
main()
{
	long long int t;
 cin >> t;
 long long int x = t%10;
 if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9)
 cout << "hon";
 else if(x == 3)
 cout << "bon";
 else
 cout << "pon";
 

return 0;	
}

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

int libgirl();
int girl(int x, int y, int point);

int main(){
	int times;
	int i;
	cin >> times;
	for(i = 0; i < times; i++){
		cout << libgirl() << endl;
	}
}

int libgirl(){
	string shelve_input;
	int N, i;
	vector<vector<int>> shelve;
	int upper = 0;
	int downer = 0;
	int start = 1;
	int end = 1;
	int walk = 0;
	
	cin >> N;
	cin >> shelve_input;
	for(i = 0; i < 2*N; i++){
		shelve.push_back({0,0});
	}
	for(i = 0; i < 2*N; i++){
		if(shelve_input[i] == 'Y'){
			shelve[i][0] = 1;
			upper++;
		}else{
			shelve[i][0] = 0;
		}
	}
	for(i = 2*N; i < 4*N; i++){
		if(shelve_input[i] == 'Y'){
			shelve[i-2*N][1] = 1;
			downer++;
		}else{
			shelve[i-2*N][1] = 0;
		}
	}
	for(i = 0; i < 2*N; i++){
		if(shelve[i][0] == 1){
			start = 0;
			break;
		}else if(shelve[i][1] == 1){
			break;
		}
	}
	for(i = 2*N-1; i >= 0; i--){
		if(shelve[i][0] == 1){
			end = 0;
			break;
		}else if(shelve[i][1] == 1){
			break;
		}
	}
	for(i = 2; i < 2*N; i = i + 2){
		if(shelve[i][0] == 1 && shelve[i-1][0] == 1){
			upper--;
		}
		if(shelve[i][1] == 1 && shelve[i-1][1] == 1){
			downer--;
		}
	}
	walk = upper + downer + N + start + end;
	return walk;
}

Measured memory_bytes: 2572
#include <iostream>

using namespace std;
long long dp[2010][2010]={0},dpb[4010][2010]={0},dpw[4010][2010]={0},a[4010],b[2010],w[2010];
char c[4010];

int main(){
    int n,i,j;
    cin >> n;
    for(i=0;i<2*n;i++){
        cin >> c[i] >> a[i];
        if(c[i]=='B') b[a[i]] = i;
        if(c[i]=='W') w[a[i]] = i;
    }

    for(i=0;i<=n;i++){
        if(c[0]=='W'){
            if(a[0]>=i){
                dpw[0][i] = 1;
            }
        }else{
            if(a[0]>=i){
                dpb[0][i] = 1;
            }
        }
    }

    for(i=1;i<2*n;i++){
        for(j=1;j<=n;j++){
            if(c[i]=='W'){
                if(a[i]>=j){
                    dpw[i][j] = dpw[i-1][j] + 1;
                }else{
                    dpw[i][j] = dpw[i-1][j];
                }
                dpb[i][j] = dpb[i-1][j];
            }
            if(c[i]=='B'){
                if(a[i]>=j){
                    dpb[i][j] = dpb[i-1][j] + 1;
                }else{
                    dpb[i][j] = dpb[i-1][j];
                }
                dpw[i][j] = dpw[i-1][j];
            }
        }
    }

    dp[0][0] = 0;
    for(i=1;i<=n;i++){
        for(j=0;j<b[i];j++){
            if(a[j]>i && c[j]=='B'|| c[j]=='W'){
                dp[0][i]++;
            }
        }
        for(j=0;j<w[i];j++){
            if(a[j]>i && c[j]=='W' || c[j]=='B'){
                dp[i][0]++;
            }
        }
        dp[0][i] += dp[0][i-1];
        dp[i][0] += dp[i-1][0];
    }

    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            dp[i][j] = min(dp[i-1][j] + dpw[w[i]][i+1] + dpb[w[i]][j+1],dp[i][j-1] + dpb[b[j]][j+1] + dpw[b[j]][i+1] );
        }
    }
    cout << dp[n][n] << endl;
}

Measured memory_bytes: 157824
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;

int main() {
	int a,b;
	cin >> a >> b;
	cout << (a%b != 0) << endl;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b;
  cin >> a >> b;
  if(a%2==1&&b%2==1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a[3][3];
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>a[i][j];
		}
	}
	int t,b;
	cin>>t;
	while(t--)
	{
		cin>>b;
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
				if(a[i][j]==b)
				  a[i][j]=0;
			}
		}
	}
	bool flag1=0,flag2=0,flag3=0;
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			if(a[i][j])
			  break;
			if(j==2&&a[i][j]==0)
			  flag1=1;
		}
	}
	for(int j=0;j<3;j++)
	{
		for(int i=0;i<3;i++)
		{
			if(a[i][j])
			  break;
			if(i==2&&a[i][j]==0)
			  flag2=1;
		}
	}
	for(int i=0;i<3;i++)
	{
		if(a[i][i])
		  break;
		if(i==2&&a[i][i]==0)
		  flag3=1;
	}
	for(int i=0;i<3;i++)
	{
		if(a[i][2-i])
		  break;
		if(i==2&&a[i][2-i]==0)
		  flag3=1;
	}
	if(flag1||flag2||flag3)
	  cout<<"Yes"<<endl;
	else
	  cout<<"No"<<endl;
 } 

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

int wts[100010];
tuple<int,int,int> edges[100010];
vector<int> etree[100010];
bool valid[100010];

int p[100010],r[100010],ce[100010];
long long w[100010];


int findS(int x){
    if(p[x] != x) p[x] = findS(p[x]);
    return p[x];
}
void dfs(int u){
    if(u == -1) return;
    valid[u] = true;
    for(auto v: etree[u]) dfs(v);
    etree[u].clear();
}
void mergeS(int x,int y,int e){
    x = findS(x); y = findS(y);
    if(x == y){
        etree[e].push_back(ce[x]);
        ce[x] = e;
        return;
    }

    etree[e].push_back(ce[x]);
    etree[e].push_back(ce[y]);
    if(r[x] > r[y]){
        w[x] += w[y];
        p[y] = x;
        ce[x] = e;
    }else{
        w[y] += w[x];
        p[x] = y;
        ce[y] = e;
    }

    if(r[x] == r[y]) r[y] += 1;
}

int main(){
    int N,M; cin>>N>>M;
    for(int i=1;i<=N;i++) cin>>wts[i];
    for(int i=0;i<M;i++){
        int x,y,w;cin>>x>>y>>w;
        edges[i] = make_tuple(w,x,y);
    }

    sort(edges,edges+M);
    for(int i=1;i<=N;i++){
        p[i] = i;
        w[i] = wts[i];
        ce[i] = -1;
    }

    for(int i=0;i<M;i++){
        int cw = get<0>(edges[i]),x = get<1>(edges[i]), y = get<2>(edges[i]);
        mergeS(x,y,i);
        int pi = findS(x);
        if(w[pi] >= cw) dfs(ce[pi]);
    }

    int rm = 0;
    for(int i=0;i<M;i++) if(valid[i] == false) rm += 1;
    cout<<rm<<endl;
    return 0;
}

Measured memory_bytes: 9984
#include <stdio.h>
#include <bitset>
#include <set>
using namespace std;
const int N=1000000;
int main(){
    int n,x,temp;
    bitset<N>b;
    set<int> prime;
    bool f;
    b.reset();
    prime.insert(2);
    for(long long int i=3;i<1000000;i+=2)if(!b[i]){
        prime.insert(static_cast<int>(i));
        for(long long int j=i*i;j<1000000;j+=i*2)b[j]=true;
    }
    while(true){
        scanf("%d%d",&n,&x);
        if(n==0&&x==0)return 0;
        b.reset();
        b[0]=true;
        while(n--){
            scanf("%d",&temp);
            while(temp<=x){
                b|=b<<temp;
                temp<<=1;
            }
        }
        f=true;
        for(set<int>::iterator u=prime.upper_bound(x);f&&u!=prime.begin();){
            u--;
            if(b[*u]){
                f=false;
                printf("%d\n",*u);
            }
        }
        if(f)printf("NA\n");
    }
}


Measured memory_bytes: 6708
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  string S;cin>>S;
  ll cnt=0;
  int i=0;
  for(int tmp = 0; tmp < (1 << S.size()-1); tmp++){
    bitset<9> A(tmp);
    i=0;
    for(int j=0;j<S.size()-1;j++){
      if(A[j]){
        cnt+=stoll(S.substr(i,j-i+1));
        i=j+1;
      }
    }
    cnt+=stoll(S.substr(i,S.size()-i));
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
typedef pair<ll, int> P;
ll A[100000];
ll B[100000];
int cnt[100000];
int main() {
	int N;
	cin >> N;
	vector<P> vec;
	ll ans = 1LL << 60;
	ll sumA = 0, sumB = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
		sumA += A[i];
		sumB += B[i];
		vec.emplace_back(A[i], i);
		vec.emplace_back(B[i], i);
	}
	ans = min(ans, sumA);
	ans = min(ans, sumB);
	sort(vec.begin(), vec.end());
	for (int i = 0; i < N; i++) cnt[vec[i].second]++;
	bool exist = 0;
	for (int i = 0; i < N; i++) {
		if (cnt[i] == 2) {
			exist = 1;
			break;
		}
	}
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		sum += vec[i].first;
	}
	if (exist) {
		ans = min(ans, sum);
	}
	else {
		for (int i = 0; i < N; i++) {
			ll t = sum;
			if (A[i] <= B[i]) {
				t -= A[i];
				if (vec[N].second != i) t += vec[N].first;
				else t += vec[N + 1].first;
			}
			else {
				t -= B[i];
				if (vec[N].second != i) t += vec[N].first;
				else t += vec[N + 1].first;
			}
			ans = min(ans, t);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 7408
#include <bits/stdc++.h>
 
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))
 
typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b;
  cin>>a>>b;
  
  int rem = b%a;
  
  if (rem==0) {
    cout<<a+b;
  } else {
    cout<<b-a;
  }
    
  return 0;
}

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

int main(){
    int N,M;
    cin >> N >> M;
    if(N==M){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import static java.lang.System.out;
import java.util.Scanner;


public class Main{
    public static void main(String[] args){
        String str = new Scanner(System.in).nextLine();
        String[] list = str.split(" ");
        String x = list[0];
        String y = list[1];

        int a = Integer.parseInt(x);
        int b = Integer.parseInt(y);

        int sum = a * b;
        int cm = (a + b) * 2;

        out.println(sum + " " + cm);
    }
}

Measured memory_bytes: 26044
n, m = list(map(int, input().split()))
# a, b, c = list(map(int, input().split()))
a = [int(input()) for i in range(m)]

mod = pow(10, 9)+7
point = [0]*(n+1)
point[0] = 1
j = 0
if 1 in a:
    point[1] = 0
    if m >= 2:
        j += 1
else:
    point[1] = 1

if m == 0:
    a = [0]

for i in range(2, n+1):
    if i == a[j]:
        if j < m-1:
            j += 1
    else:
        point[i] = point[i-1]+point[i-2]
        point[i] %= mod

print(point[-1] % mod)


Measured memory_bytes: 7848
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int r;
  cin >> r;
  cout << r*r << endl;

  return 0;
}


Measured memory_bytes: 256
N=int(input())
L1=list(map(int,input().split()))
L2=list(map(int,input().split()))

ans=0
for i in range(N):
    sum=0
    for j in range(i+1):
        sum+=L1[j]
    for k in range(i,N):
        sum+=L2[k]
    if sum>ans:
        ans=sum
print(ans)
            


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N, C, K;
    cin >> N >> C >> K;
    int T[N];
    for(int i = 0; i < N; i++) cin >> T[i];
    sort(T, T + N);
    int ans = 0, people = 1, first = T[0];
    for(int i = 1; i < N; i++) {
        if(T[i] - first > K || people == C) {
            ans++;
            people = 1;
            first = T[i];
        } else
            people++;
    }

    cout << ans + 1 << "\n";
    return 0;
}

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

int bubbleSort(int A[],int N){
  int sw = 0;
  bool flag  = 1;
  for ( int i = 0; flag ; i++) {
    flag  = 0 ;
    for(int j = N-1;j >= i+1; j--){
      if ( A[j] < A[j-1] ){
        swap(A[j],A[j-1]);
        flag =1;
        sw++;
}
}
}
  return sw;
}

int main(){
  int A[100],N,sw;
  cin >>N;
  for( int i =0; i<N;i++) cin >>A[i];

  sw = bubbleSort(A,N);
  for (int i=0 ; i<N; i++){
    if (i) cout << " ";
    cout << A[i];
}
  cout << endl;
  cout << sw <<endl;
  return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	int a;
	cin >> a;
	int b, c,d;
	d = a / 100;
	b = (a - d * 100) / 10 ;
	c = a- d*100 - b * 10;

	if (d == 7) {
		cout << "Yes";
	}
	else{
		if (b == 7) {
			cout << "Yes";
		}
		else {
			if (c == 7) {
				cout << "Yes";
			}
			else {
				cout << "No";
			}
		}
	}




}

Measured memory_bytes: 3096
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    //final List<Integer> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    long r = sc.nextLong();
    long d = sc.nextLong();
    long x = sc.nextLong();

    for(int i = 0; i < 10 ; i++){
        x = r * x - d;
        System.out.println(x);
    }



    



   
    





}
}

Measured memory_bytes: 35544
#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: 1160
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
  int n,x;
  cin >> n >> x;
  int m[110];
  for (int i=0; i<n; i++) cin >> m[i];
  sort(m,m+n);
  
  int sum = 0;
  for (int i=0; i<n; i++) {
    sum += m[i];
  }
  int nokori = x - sum;
  int a = nokori / m[0];
  
  cout << a + n << endl;
}


Measured memory_bytes: 256
//  Lightest Mobile.cpp
//  2013/01/03.

#if 1

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int B[128][4];

int __lcm(int a, int b)
{	return a / __gcd(a, b) * b; }

int rec(int idx)
{
	int a = (B[idx][2] == 0 ? 1 : rec(B[idx][2]-1));
	int b = (B[idx][3] == 0 ? 1 : rec(B[idx][3]-1));
	
	int p = B[idx][0];
	int q = B[idx][1];
	
	int lcm = __lcm(p*a, q*b);
	
	return lcm / p + lcm / q;
}

int main()
{
    for(int n; cin >> n && n; )
	{
		vint pflag(n+1, true);
		
		rep(i, n)
		{
			rep(j, 4) cin >> B[i][j];
			
			pflag[B[i][2]] = false;
			pflag[B[i][3]] = false;
		}
		
		rep(i, n) if(pflag[i+1]) cout << rec(i) << endl;
	}
}

#endif

Measured memory_bytes: 1196
#include "bits/stdc++.h"
#define ll long long
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define pl pair<ll,ll>
#define rep(i,b) for(ll i=0;i<b;i++)

using namespace std;

int main() {
    std::cout<<std::fixed<<std::setprecision(10);
    ll N, K, L, R;
    string s,t,u;
    cin>>s>>t;
    cin>>N>>K;
    cin>>u;
    if(u==s)N--;
    if(u==t)K--;
    cout<<N<<" "<<K<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define rall(x) (x).rbegin() , (x).rend()
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace2(a,b) cerr <<"a is " << a << " b is " << b << el;
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;

int main()
{
    ios;
    unordered_map<char,ll> mpp ;
    string s ;
    cin >> s ;
    for(auto &x : s){
        mpp[x]++;
    }
    ll foo =1 ;
    for(auto &x : mpp){
        if(x.se % 2 == 1){
            foo = 0 ;
            br ;
        }
    }
    if(foo) cout << "Yes\n" ;
    else cout << "No\n" ;
    ro ;
}



























Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

    int a[n];
    int b[n];
    int c[n];

    c[n - 1] = 0;

    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    for(int i = 0; i < n - 1; i++){
        cin >> c[i];
    }

    int result = 0;
    int former = a[0];
    int later;

    for(int i = 0; i < n; i++){
        result += b[a[i] - 1];
        later = a[i];
        if(later == former + 1){
            result += c[former - 1];
        }
        former = a[i];
    }

    cout << result;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }



int main(){
    LL q;
    cin >> q;
    multiset<LL> left, right;
    LL bias = 0;
    LL left_total = 0;
    LL right_total = 0;
    for(LL i = 0; i < q; ++i){
        LL type, a, b;
        cin >> type;
        if(type == 1){
            cin >> a >> b;
            bias += b;
            if(left.empty() || a < *left.rbegin()){
                left.insert(a);
                left_total += a;
            }else{
                right.insert(a);
                right_total += a;
            }
            if(left.size() < right.size()){
                auto it = right.begin();
                LL x = *it;
                right.erase(it);
                left.insert(x);
                right_total -= x;
                left_total += x;
            }else if(left.size() > right.size() + 1){
                auto it = --left.end();
                LL x = *it;
                left.erase(it);
                right.insert(x);
                left_total -= x;
                right_total += x;
            }
        }else{
            LL x = *left.rbegin();
            LL val = bias + ((LL)(left.size()) - right.size()) * x - left_total + right_total;
            cout << x << " " << val << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define INF INT_MAX
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  if(a>=13){
    cout<<b<<endl;
  }else if(12>=a && a>=6){
    cout<<b/2<<endl;
  }else{
    cout<<"0"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a[3];
	int i,j,min,x,sum;
	for(i=0;i<3;i++){
		scanf("%d",&a[i]);
	}
	x=0;
	for(i=0;i<3-1;i++){	
		for(j=i+1;j<3;j++){
			if(a[i]>a[j]){
				x=a[i];
				a[i]=a[j];
				a[j]=x;
			}
		}
	}
	for(i=0;i<3;i++){
		sum=a[0]+a[1];
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 128
k, a, b = gets.split.map(&:to_i)

t, rest = k.divmod(a + 1)

if (b - 1) < (a + 1)
  puts 1 + t * (a + 1) + rest
else
  if (b - 1) < a
    puts 1 + t * (b - 1) + rest
  else
    l, m = (k - a - 1).divmod(2)
    puts b + (b - a) * l + m
  end
end


Measured memory_bytes: 3836
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define HEAP priority_queue
#define heap(T) priority_queue<T,vector<T>,greater<T> >
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=2005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
const int BufferSize=1<<25;
char buffer[BufferSize],*Bufferhead,*Buffertail;
int Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T> inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){c=Getchar();rev|=c=='-';if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	x=rev?-x:x;
	return 1;
}
template<class T>inline void print(T x,const char c){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[10];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

struct node{int x,y;}p[N];
int n,m,res,last[N],vis[N];
char s[N];
bool a[N][N];

inline bool cmp(node a,node b){return a.x<b.x;}

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	res=max(n,m);
	for(int i=1;i<=n;i++){
		scanf("%s",s+1);
		for(int j=1;j<=m;j++)
			a[i][j]=(s[j]=='#');
	}
	for(int i=1;i<n;i++)
		for(int j=1;j<=m;j++)
			a[i][j]^=a[i+1][j];
	for(int j=1;j<m;j++) last[j]=n;
	for(int i=n-1;i;i--){
		for(int j=1;j<m;j++)
			if(a[i][j]!=a[i][j+1]) last[j]=i;
		for(int j=1;j<m;j++)
			p[j]=(node){last[j],j};
		sort(p+1,p+m,cmp);
		set<int> s;s.insert(0);s.insert(m);
		clr(vis,0);vis[m]=1;
		int ans=m;
		for(int j=1;j<m;j++){
			if(p[j].x!=p[j-1].x) gmax(res,ans*(p[j].x-i+1));
			int k=p[j].y;
			if(p[j].x==n) break;
			s.insert(k);
			set<int>::iterator it=s.find(k);
			int l=*(--it);
			int r=*(++++it);
			vis[r-l]--;vis[k-l]++;vis[r-k]++;
			while(!vis[ans]) ans--;
		}
	}
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 4480
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            var k = int.Parse(s[0]);
            var x = int.Parse(s[1]);

            Console.WriteLine(500 * k >= x ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11092
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine();
            var num = int.Parse(input);

            for (int i = 1; i <= num; i++)
            {
                var x = i;
                if (x % 3 == 0)
                {
                    Console.Write(" {0}", i);
                    continue;
                }
                while (x != 0)
                {
                    if (x % 10 == 3)
                    {
                        Console.Write(" {0}", i);
                        break;
                    }
                    x /= 10;
                }
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 5768
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  string a, b ; cin >> a >> b ;

  rep(i,a.size()){
    cout << a[i];
    if(b.size() >= (i+1)) cout << b[i];
  }
  cout << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//struct _ { ios_base::Init i; _() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); } } ___;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << "  ";
    __f(comma + 1, args...);
}

#define ll long long int
#define pii pair<int,int>
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ff first
#define ss second
#define endll '\n'
#define rep(i,n) for(int i=0;i++<n;)
#define scl(i) scanf("%lld",&i)
#define int long long int
#define all(n) n.begin(),n.end()
#define mem(n,i) memset(n,i,sizeof n)
#define em(a) emplace_back(a)
#define pb(a) push_back(a)
#define srep(vv,it) for(auto &it : vv)
#define prep(vv,it) for(auto it : vv)
//vector<vector<int>>arr(n + 5, vector<int>(m + 5,0));

typedef vector<int> vii;
typedef vector<string> vss;
/*

*/

int arr[10000005];
void call()
{
    for (int i = 1; i < 10000002; i++)
        for (int j = i; j < 10000002; j += i)
            arr[j]++;
}

signed main()
{

    call();
    int n; cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += arr[i] * i;
    }
    cout << ans << endll;
}


Measured memory_bytes: 81720
#include <iostream>
#include <queue>
#include <vector>

using namespace std;
using LL = long long;

class Solution {
public:
	LL league(const vector<vector<int>>& A) {
		const int n = A.size();
		vector<vector<int>> adjLists(n * n);
		for (int i = 0; i < n; ++i) {
			const int playerX = i;
			int prev = -1;
			for (int j = 0; j < n - 1; ++j) {
				const int playerY = A[i][j] - 1;
				int curr = min(playerX, playerY) * n + max(playerX, playerY);
				if (prev != -1) {
					adjLists[prev].push_back(curr);
#if 0
					cout << "depedency: " << prev / n << "," << prev % n << "->";
					cout << curr / n << "," << curr % n << endl;
#endif
				}
				prev = curr;
			}
		}

		vector<int> nIndegree(n * n);
		for (const auto& adjList : adjLists) {
			for (int u : adjList)
				++nIndegree[u];
		}

		queue<int> Q;
		for (int i = 0; i < n * n; ++i) {
			if (!nIndegree[i])
				Q.push(i);
		}

		int ans = 0, nMatched = 0;
		for (int depth = 1; !Q.empty(); ++depth) {
			for (int i = Q.size(); i > 0; --i) {
				const int u = Q.front();
				Q.pop();
				++nMatched;
				for (int v : adjLists[u]) {
					if (!--nIndegree[v])
						Q.push(v);
				}
			}
			ans = max(ans, depth);
		}
		if (nMatched < n * n)
			return -1; /* failed */
		return ans;
	}
};

int main() {
	int n;
	cin >> n;
	vector<vector<int>> A(n, vector<int>(n - 1));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n - 1; ++j)
			cin >> A[i][j];
	}

	Solution sol;
	LL ans = sol.league(A);
	cout << fixed << ans << endl;
	return 0;
}


Measured memory_bytes: 49152
a_i,a_o,a_t,a_j,a_l,a_s,a_z=map(int,input().split())
ans1=a_o
if min(a_i,a_j,a_l)==0:
  ans2=2*(a_i//2+a_j//2+a_l//2)
else:
  ans2=max(2*(a_i//2+a_j//2+a_l//2),3+2*((a_i-1)//2+(a_j-1)//2+(a_l-1)//2))
print(ans1+ans2)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

double dp[305][305][305];
ll N;

double rec(ll x, ll y, ll z){
	if(dp[x][y][z]>=0) return dp[x][y][z];
	if(x==0 && y==0 && z==0) return 0.0;

	double val = 0.0;
	double px=0.0, py=0.0, pz=0.0;
	if(x>0){
		px = rec(x-1, y+1, z);
		val += (px+1.0) * (1.0*x/N);
	}
	if(y>0){
		py = rec(x, y-1, z+1);
		val += (py+1.0) * (1.0*y/N);
	}
	if(z>0){
		pz = rec(x, y, z-1);
		val += (pz+1.0) * (1.0*z/N);
	}
	if(x+y+z<N){
		double p = 1.0*(N-x-y-z)/N;
		val += p;
		val /= (1.0-p);
	}

	dp[x][y][z] = val;
	return val;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i, 305)REP(j, 305)REP(k, 305) dp[i][j][k] = -1;

    cin >> N;
    vector<ll> cnt(3, 0);

    REP(i, N){
    	ll tmp;
    	cin >> tmp;
    	cnt[tmp-1]++;
    }
    double res = rec(cnt[2], cnt[1], cnt[0]);
    printf("%.10f\n", res);
    return 0;
}

Measured memory_bytes: 221952
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

set<ll> divisor(ll n)
{
    set<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.insert(i);
            if (i * i != n)
                ret.insert(n / i);
        }
    }

    return (ret);
}

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

    int ans = 0;

    for (int i = 1; i <= n; i++)
    {
        if (divisor(i).size() == 8 && i & 1)
        {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3624
N = int(input())
A = list(map(int,input().split()))
ans = []

for i in range(N-1):
    if A[i] > A[i+1]:
        youso = A[i] - A[i+1]
        A[i+1] += youso
        ans.append(youso)
    else:
        pass

print(sum(ans))


Measured memory_bytes: 100092
#include <iostream>

 

using namespace std;

 

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m =( i - h * 3600 ) / 60 ;
   s =( i - h * 3600 - m * 60);
   
   
   cout << h << ":"  << m << ":" << s << endl; 
   
   return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <queue>

using namespace std;

int p[100+10][100+10];
int D[100+10],e[100+10];
int n,a,b,c;

int main(){
	cin >> n;
	for (int i=1; i<=n; i++){
		cin >> a >> b;
		for (int j=1; j<=b; j++){
			cin >> c;
			p[a][c] = 1;
		}
	}
	for (int i=1; i<=n; i++){
		D[i] = -1;
	}
	
	queue<int> Q;
	Q.push(1);
	D[1] = 0;
	e[1] = 1;
	while(!Q.empty()){
		int m = Q.front();
		Q.pop();
		for (int i=1; i<=n; i++){
			if (p[m][i]==1 && e[i]==0){
				D[i] = D[m]+1;
				Q.push(i);
				e[i] = 1;
			}
		}
	}
	
	for (int i=1; i<=n; i++){
		cout << i << ' ' << D[i] << endl;
	}
}

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

using namespace std;
using ll = long long;
int main(int argc, const char *argv[]) {
  ll k;
  cin >> k;

  ll cur = 7 % k, cnt = 1, ans;
  while (cur != 0 && cnt <= k + 10) {
    cur = (cur * 10 % k + 7) % k;
    cnt++;
  }

  if (cur == 0) {
    cout << cnt << '\n';
  } else {
    cout << "-1" << '\n';
  }

  return 0;
}

Measured memory_bytes: 3628
N, M = map(int, input().split())
l = 0
r = 10 ** 13
while r - l > 1:
    m = (l+r) // 2
    a = max(m - N, 0)
    if M - 2 * a >= 2 * m:
        l = m
    else:
        r = m
print(l)

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

int main(){
    int64_t h;
    cin >> h;
    int64_t ans = 0;
    int64_t count = 1;
    while(true){
        ans += count;
        count *= 2;
        if(h==1)break;
      	h/=2;
    }

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

Measured memory_bytes: 3616
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <iomanip>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  long double L;
  std::cin >> L;

  std::cout << std::setprecision(12);

  std::cout << (L / 3) * (L / 3) * (L / 3) << std::endl;

  return 0;
}


Measured memory_bytes: 256