akhauriyash/Code-Regression huggingface dataset:
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

vector<string> edges;
ll n;

bool isBipartite() {
    vll color(n, -1);
    color[0] = 0;
    queue<ll> que; que.push(0);
    while (!que.empty()) {
        ll q = que.front(); que.pop();
        for (int i=0; i<n; i++) {
            if (edges[q][i] == '1') {
                if (color[i] == -1) {
                    color[i] = color[q]^1;
                    que.push(i);
                } else if (color[q] == color[i]) return false;
                else continue;
            }
        }
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    edges.resize(n);
    REP(i, n) cin >> edges[i];
    if (!isBipartite()) cout << -1 << '\n';
    else {
        vvll d(n, vll(n, 0));
        REP(i, n) REP(j, n) {
            if (i==j) d[i][j] = 0;
            else if (edges[i][j] == '1') d[i][j] = 1;
            else d[i][j] = HIGHINF;
        }
        ll maxd = 0;
        REP(k, n) REP(i, n) REP(j, n) if (d[i][j] > d[i][k] + d[k][j]) d[i][j] = d[i][k] + d[k][j];
        REP(i, n) REP(j, n) if (i != j) chmax(maxd, d[i][j]);
        cout << maxd+1 << '\n';
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
  int W;
  int H;
  int x;
  int y;
  int r;
  
  cin >> W >> H >> x >> y >> r;
  
  if(W>=(x+r) && (x-r)>=0 && H>=(y+r) && (y-r)>=0)
    cout << "Yes\n";
  else
    cout << "No\n";
}

Measured memory_bytes: 1124
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//const ll MOD = 1e9 + 7;

int main()
{
    
    ll n;ll k;
    cin>>n>>k;
    ll res  = 0;
    
    for(ll i=k;i<=n+1;i++)
    {
        res  += i*(n-i+1)+1;
        res = res%(1000000007);
    }
    cout<<res;
    
}

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

const int N = 105, W = 1e5+5;
int n, w;
long long dp[N][W];
std::pair<int, int> a[N];

int32_t main() {
  scanf("%d%d", &n, &w);

  for (int i = 1; i <= n; i++)
    scanf("%d%d", &a[i].first, &a[i].second);

  //std::sort(a, a+n);
  
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= w; j++) {
      const int wt = a[i].first, v = a[i].second;
      dp[i][j] = wt > j ? dp[i-1][j] : std::max(v + dp[i-1][j-wt], dp[i-1][j]);
    }
  }

  printf("%lld\n", dp[n][w]);
  return 0;
}


Measured memory_bytes: 79360
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, mod = 1e9 + 7;
int d[N];
vector < pair < int, int > > edges[N];
void dfs(int x, int p, int w){
    d[x] = d[p] + w;
    for(auto i : edges[x]){
        if(i.first == p)continue;
        dfs(i.first, x, i.second);
    }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for(int i = 1; i < n; i++){
        int a, b, c;
        cin >> a >> b >> c;
        edges[a].push_back({b, c & 1});
        edges[b].push_back({a, c & 1});
    }
    dfs(1, 0, 0);
    for(int i = 1; i <= n; i++){
        cout << d[i] % 2 << endl;
    }
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int N,X;
	cin>>N>>X;
	int arr[N];
	for(int i=0;i<N;i++){
		cin>>arr[i];
	}
	sort(arr,arr+N);
	int cnt=0;
	for(int i=0;i<N;i++){
		X-=arr[i];
		cnt++;
	}
	cnt+=X/arr[0];
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let t: Vec<i64> = read_vec();
    let a: Vec<i64> = read_vec();
    let b: Vec<i64> = read_vec();
    let af = a[0] * t[0] + a[1] * t[1];
    let bf = b[0] * t[0] + b[1] * t[1];
    let ah = a[0] * t[0];
    let bh = b[0] * t[0];
    if af == bf {
        println!("infinity");
        return;
    }
    /*
    if (ah - bh) * (af - bf) > 0 {
        println!("0");
    }
    println!("ah:{},af:{}", ah, af);
    println!("bh:{},bf:{}", bh, bf);
    */

    if (ah > bh && af > bf) || (bh > ah && bf > af) {
        println!("0");
        return;
    }

    let f;
    let s;
    if a[0] < b[0] {
        f = a;
        s = b;
    } else {
        f = b;
        s = a;
    }

    let dist = ((s[0] - f[0]) * t[0]) as u64;
    let diff = vec![(s[1] - f[1]) * t[1], (s[0] - f[0]) * t[0]];
    let dsum = -(diff[0] + diff[1]) as u64;

    /*
    println!("dist : {}", dist);
    println!("diff : {:?}", diff);
    println!("dsum : {}", dsum);
    */

    let ans: u64;

    if dist % dsum == 0 {
        ans = dist / dsum;
        println!("{}", 2 * ans);
    } else {
        ans = dist / dsum + 1;
        println!("{}", 2 * ans - 1);
    }
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 標準入力から値を取得してinput_lineに入れる
        String r = sc.nextLine();
      
      	int shuturyoku = Integer.parseInt(r) * Integer.parseInt(r);

        // 取得した値を標準出力するために"XXXXXX"をどう書き換える？
        System.out.println(shuturyoku);
    }
}

Measured memory_bytes: 22608
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, i = il()
    print(N-i+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;

class B
{
    static void Main()
    {
        var s = Console.ReadLine();
        var w = int.Parse(Console.ReadLine());
        Console.WriteLine(Enumerable.Range(0, 1 + (s.Length - 1) / w).Select(i => s[i * w]).ToArray());
    }
}

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

int main(){
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int cnt=0;
  rep(i,a+1)rep(j,b+1)rep(k,c+1)
    if(500*i+100*j+50*k==x)cnt++;
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3616
def selectionSort(A):
    count = 0
    for i in range(len(A)):
        minj = i
        for j in range(i,len(A)):
            if A[j] < A[minj]:
                minj = j
        if i != minj:
            A[i],A[minj] = A[minj],A[i]
            count += 1
    return A,count

N = int(input())
lst = list(map(int,input().split()))

lst,change = selectionSort(lst)
print(" ".join(map(str,lst)))
print(change)


Measured memory_bytes: 5600
import java.util.Scanner;

public class Main {
    static int A;
    static int B;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        A = scanner.nextInt();
        B = scanner.nextInt();
        scanner.close();
    }

    public static void main(String[] args) {
        init();
        // logic
        logic();
    }

    static void logic() {
        int avg = (int)Math.ceil((double)(A + B) / 2.0);
        System.out.println(avg);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
using namespace std;

int main(){
int i=1,x;
while(1){
cin>>x;
if(x!=0){
    cout<<"Case "<<i<<": "<<x<<endl;
    i++;
    continue;
}
break;

}
}


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

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int main()
{
    int A, B, C;

    cin >> A >> B >> C;
    cout << min(B / A, C) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sct(tc) scanf("%lld",&tc)
#define scl(n) scanf("%lld",&n)
#define scll(n,m) scanf("%lld%lld",&n,&m)
#define scs(ch) scanf("%s", ch)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
int main()
{
   ll X,Y,A,B,C,p,q,r,i,sum=0;
   scanf("%lld %lld %lld %lld %lld",&X,&Y,&A,&B,&C);
   vector<ll>v1;
   vector<ll>v2;
   vector<ll>v3;
   for(i=1;i<=A;i++)
   {
   	scanf("%lld",&p);
   	v1.pb(p);
   }
   for(i=1;i<=B;i++)
   {
   	scanf("%lld",&q);
   	v2.pb(q);
   }
   sort(v1.begin(),v1.end());
   sort(v2.begin(),v2.end());
   ll len1=v1.size();
   ll len2=v2.size();
   for(i=len1-1;i>=len1-X;i--)
   v3.pb(v1[i]);
   for(i=len2-1;i>=len2-Y;i--)
   v3.pb(v2[i]);
   for(i=1;i<=C;i++)
   {
   	 scanf("%lld",&r);
   	 v3.pb(r);
   }
   sort(v3.begin(),v3.end());
   ll len3=v3.size();
   ll n=X+Y;
   for(i=len3-1;i>=len3-n;i--)
   sum=sum+v3[i];
   printf("%lld\n",sum);
}

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

int main()
{
    int n, x;

    while (cin >> n >> x, n | x){
        int cnt = 0;

        for (int i = 1; i <= n; i++){
            for (int j = i + 1; j <= n; j++){
                for (int k = j + 1; k <= n; k++){
                    if (i + j + k == x) cnt++;
                }
            }
        }
        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) do{}while(0)
#endif




ll n, k;
vector<ll> a;

int main(){
	cin >> n >> k;
	
	a.resize(n);
	rep(i,n){
		cin >> a[i];
	}
	
	map<ll,ll> lastpos; // value -> last position
	vector<ll> posskip(n); //  pos -> skip
	rep(i,n*2){
		int k = i % n;
		ll ak = a[k%n];
		if ( lastpos.count(ak) ){
			if ( lastpos[ak] < n )
				posskip[lastpos[ak]] = i-lastpos[ak]+1;
		}
		lastpos[ak] = i;
	}
	
	ll realpos = 0;
	ll pos = 0;
	vector<ll> posk(n);
	
	ll remain = k*n;
	while ( posskip[pos] < remain ){
		if ( posk[pos] != 0 ){
			ll period = posk[pos] - remain;
			remain -= (remain/period)*period;
			break;
		}
		else {
			posk[pos] = remain;
		}
		remain -= posskip[pos];
		realpos += posskip[pos];
		pos = realpos % n;
	}
	
	
	vector<ll> result;
	while ( remain ){
		while ( remain && posskip[pos] <= remain ){
			remain -= posskip[pos];
			realpos += posskip[pos];
			pos = realpos % n;
		}
		
		if ( remain ){
			result.push_back(a[pos]);
			remain--;
			realpos++;
			pos = realpos % n;
		}
	}
	
	for ( auto it : result )
		cout << it << " ";
	cout << endl;
	
	return 0;
}




Measured memory_bytes: 22396
#include <iostream>

using namespace std;

int main() {

	long N, M;
	long ad = 0;

	cin >> N >> M;

	ad = (M - 2*N < 0) ? (M - 2*N - 1) / 2 : (M - 2*N) / 4;

	cout << N + ad << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
struct DisjointSet {
	vi rank, p;
	DisjointSet() {}
	DisjointSet(int size) {
		rank.resize(size, 0);
		p.resize(size, 0);
		rep(i, 0, size) makeSet(i);
	}
	inline void makeSet(int x) {
		p[x] = x;
		rank[x] = 0;
	}
	inline bool same(int x, int y) { return findSet(x) == findSet(y); }
	inline void unite(int x, int y) { link(findSet(x), findSet(y)); }
	inline void link(int x, int y) {
		if(rank[x] > rank[y]) p[y] = x;
		else {
			p[x] = y;
			if(rank[x] == rank[y]) ++rank[y];
		}
	}
	inline int findSet(int x) {
		if(x != p[x]) p[x] = findSet(p[x]);
		return p[x];
	}
};
struct Edge {
	int source = 0, target = 0, cost = 0;
	Edge(int source = 0, int target = 0, int cost = 0):
		source(source), target(target), cost(cost) {}
	inline bool operator < (const Edge &e) const { return cost < e.cost; }
};
inline int kruskal(int n, vector<Edge> &edges) {
	sort(all(edges));
	DisjointSet dset = DisjointSet(n + 1);
	rep(i, 0, n) dset.makeSet(i);
	Edge e;
	int totalCost = 0;
	rep(i, 0, len(edges)) {
		e = edges[i];
		if(!dset.same(e.source, e.target)) {
			totalCost += e.cost;
			dset.unite(e.source, e.target);
		}
	}
	return totalCost;
}
int main() {
	int n, m; cin >> n >> m;
	vector<Edge> edges;
	int source, target, cost;
	rep(i, 0, m) {
		cin >> source >> target >> cost;
		edges.eb(Edge(source, target, cost));
	}
	P(kruskal(n, edges));
	return 0;
}

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

// const int MOD = 1000000007;
const ll MOD = 1e9 + 7;

ll primeFactorization(int n) {
    ll ans = 1;
    vector<int> x(n + 1);

    for (int i = 2; i <= n; i++) {
        int num = i;
        for (int j = 2; j <= i; j++) {
            while (num % j == 0) {
                x.at(j)++;
                num /= j;
            }
        }
    }

    for (int i = 2; i <= n; i++) {
        ans *= x.at(i) + 1; // 使わない場合の+1
        ans %= MOD;
    }

    return ans;
}


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

    ll ans = 0;

    ans = primeFactorization(N);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>

using namespace std;

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

const int mo = 1e9 + 7;

struct Edge {
	int to, idx;
	Edge(int to, int idx) : to(to), idx(idx) {}
};

int N;
vector<Edge> G[100010];
int mx = 0;
int c[100010];
int p_c[100010];

void f(int cur, int par, int used_color)
{
	if (G[cur].size() == 1 and G[cur][0].to == par) { // leaf
		return;
	}

	int counter = 0;
	for (Edge &e : G[cur]) {
		if (e.to == par) continue;
		counter++;
		if (counter == used_color) counter++;
		c[e.idx] = counter;
		f(e.to, cur, counter);
	}

	mx = max(mx, counter);
}

signed main()
{
	cin >> N;
	
	rep(i, N-1) {
		int a, b; cin >> a >> b;
		--a, --b;
		G[a].push_back(Edge(b, i));
		G[b].push_back(Edge(a, i));
	}

	memset(c, -1, sizeof(c));
	f(0, -1, -1);

	cout << mx << endl;
	rep(i, N-1) {
		cout << c[i] << endl;
	}
}


Measured memory_bytes: 10112
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout <<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;

	VAR(int, n, m);
	int ans = 0;
	ans += min(m / 2, n);
  n -= ans;
	m -= ans * 2;

	ans += m/4;
	OUT(ans)BR;
	
  return 0;
}


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

int digit_sum(int n, int base = 10) {
    int res = 0;
    while (n > 0) res += n % base, n /= base;
    return res;
}

int main() {
    int n; cin >> n;
    int res = n;
    for (int i = 0; i <= n; i++) {
        int tmp = digit_sum(i, 6) + digit_sum(n - i, 9);
        res = min(res, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int N;
  cin>>N;
  int a[N];
  int saidai = 0;
  int saidai2 = 0;
  for(int i = 0;i<N;i++){
    cin>>a[i];
    saidai = max(saidai,a[i]);
  }
  int saidaiko = 0;
  for(int i = 0;i<N;i++){
    if(a[i] == saidai){
      saidaiko++;
    }
  }
  if(saidaiko > 1){
    for(int i = 0;i<N;i++){
      cout << saidai << endl;
    }
  }
  else{
    for(int i = 0;i<N;i++){
      if(a[i] != saidai){
        saidai2 = max(saidai2,a[i]);
      }
    }
    for(int i = 0;i<N;i++){
      if(a[i] != saidai){
        cout << saidai << endl;
      }
      else{
        cout << saidai2 << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

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 rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef ll Weight;
typedef vector<vector<Weight>> Graph;
void add_edge(vector<vector<Weight>>& g, Weight from, Weight to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

template<class T> inline bool chmax(T& a, T b) { if (a <= b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }

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

  int a,b,c,k; cin >> a >> b >> c >> k;
	while (k > 0 && a >= b) {
		b *= 2;
		k--;
	}

	while (k > 0 && b >= c) {
		c *= 2;
		k--;
	}
	if (a < b && b < c) cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>

typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	int s, w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe";
	} else {
		cout << "safe";
	}
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
void fastio(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(0);
	 cout.tie(0);
}
int main() {
	fastio();
	ll a,b,ans=0;
	cin>>a>>b;
	if(a==b)
	{
		cout<<a+b;
		return 0;
	}
	if(a>b)
	{
		ans+=a;
		a--;
	}
	else
	{
		ans+=b;
		b--;
	}
	ans+=max(a,b);
	cout<<ans;
	
	
	return 0;
}

Measured memory_bytes: 256
def add_edge(node, adj_lst, adj_rev, s1, s2):
  ind = 0
  max_len = min(len(s1), len(s2))
  while ind < max_len and s1[ind] == s2[ind]:
    ind += 1
  if ind == max_len:
    if max_len < len(s1):
      return True
    return False
  c1 = ord(s1[ind]) - ord("a")
  c2 = ord(s2[ind]) - ord("a")
  adj_lst[c1].add(c2)
  adj_rev[c2].add(c1)
  node.add(c1)
  node.add(c2)
  return False
def main():
  while True:
    n = int(input())
    if n == 0:
      break
    
    lst = [input() for _ in range(n)]
    node = set()
    adj_lst = [set() for _ in range(26)]
    adj_rev = [set() for _ in range(26)]
    blank_flag = False
    for i in range(n):
      for j in range(i + 1, n):
        blank_flag = blank_flag or add_edge(node, adj_lst, adj_rev, lst[i], lst[j])
    
    visited = [False] * 26
    cycle_flag = False
  
    def visit(n):
      ret = False
      if visited[n] == 2:
        return True
      elif visited[n] == 0:
        visited[n] = 2
        for to in adj_lst[n]:
          ret = ret or visit(to)
        visited[n] = 1
      return ret
    
    for n in node:
      cycle_flag = cycle_flag or visit(n)
    if cycle_flag or blank_flag:
      print("no")
    else:
      print("yes")

main()


Measured memory_bytes: 5640
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;

#define ll long long

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a < b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	if (a%b == 0)return b;
	return gcd(b, a%b);

}
//最大公約数

ll lcm(ll a, ll b) {

	return a / gcd(a, b)*b;

}
//最小公倍数

int main() {

	int D, N;
	cin >> D >> N;
	if (D == 0) {
		if (N == 100)cout << 101 << endl;
		else cout << N << endl;
	}
	else if (D == 1) {
		if (N == 100)cout << 100 * 100 + 100 << endl;
		else cout << 100 * N << endl;
	}
	else {
		if (N == 100)cout << 10000 * 100 + 10000 << endl;
		else cout << 10000 * N << endl;
	}

	return 0;
}


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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{
    fastio
    lli n , r ;
    cin >> n >> r ;
    cout << (n < 10 ? 100 * (10 - n) + r : r ) << endl ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a;
while(scanf("%d",&a)!=EOF)
	{
		int b;
		scanf("%d",&b);

		int temp=a+b;
		int ans=1;
		while((temp/=10)>0)
		{
			ans++;
		}
	printf("%d\n",ans);
	}
}

Measured memory_bytes: 0
N, *A = map(int, open(0).read().split())

ans = 0
acc = 0
r = 0
for l in range(N):
    while r < N and (acc ^ A[r]) == acc + A[r]:
        acc += A[r]
        r += 1

    ans += r - l

    if l == r:
        r += 1
    else:
        acc -= A[l]

print(ans)

Measured memory_bytes: 25052
import sys
input = sys.stdin.readline

def main():
    h,w,n = map(int,input().split())
    dg = 10**10
    d = dict()

    def f(x,y):
        if 2 <= x <= h-1 and 2 <= y <= w-1:
            return True
        else:
            False

    for i in range(n):
        a,b = map(int,input().split())
        
        if f((a-1),b-1):
            if (a-1)*dg + b-1 in d:
                d[(a-1)*dg + b-1] += 1
            else:
                d[(a-1)*dg + b-1] = 1
        
        if f((a-1),b):
            if (a-1)*dg + b in d:
                d[(a-1)*dg + b] += 1
            else:
                d[(a-1)*dg + b] = 1
        
        if f((a-1),b+1):
            if (a-1)*dg + b+1 in d:
                d[(a-1)*dg + b+1] += 1
            else:
                d[(a-1)*dg + b+1] = 1

        if f((a),b-1):
            if (a)*dg + b-1 in d:
                d[(a)*dg + b-1] += 1
            else:
                d[(a)*dg + b-1] = 1
        
        if f(a,b):
            if a*dg + b in d:
                d[a*dg + b] += 1
            else:
                d[a*dg + b] = 1
        
        if f((a),b+1):
            if (a)*dg + b+1 in d:
                d[(a)*dg + b+1] += 1
            else:
                d[(a)*dg + b+1] = 1
        
        if f((a+1),b+1):
            if (a+1)*dg + b+1 in d:
                d[(a+1)*dg + b+1] += 1
            else:
                d[(a+1)*dg + b+1] = 1
        
        if f((a+1),b):
            if (a+1)*dg + b in d:
                d[(a+1)*dg + b] += 1
            else:
                d[(a+1)*dg + b] = 1
        
        if f((a+1),b-1):
            if (a+1)*dg + b-1 in d:
                d[(a+1)*dg + b-1] += 1
            else:
                d[(a+1)*dg + b-1] = 1
        
        
        
        
    res = [0]*10
 
    for e in d:
        res[d[e]] += 1
 
    res[0] = (h-2)*(w-2)-sum(res)
 
    for e in res:
        print(e)
 
if __name__ == "__main__":
    main()


Measured memory_bytes: 152408
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

int ans;

int main(void) {
	int AB, BC, CD;
    scanf("%d %d %d", &AB, &BC, &CD);
    
    printf("%d\n", (BC * AB) / 2);

	return 0;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  string s;
  cin>>s;
  vector<int> a,z;
  rep(i,s.size()){
    if(s[i]=='A') a.push_back(i);
    if(s[i]=='Z') z.push_back(i);
  }
  
  cout<<z[z.size()-1]-a[0]+1<<endl;
 
}
///////////////////////////





Measured memory_bytes: 1364
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/
long long int gcd(long long int a, long long int b)
{
    long int c;
    while (a != 0)
    {
        c = a;
        a = b % a;
        b = c;
    }
    return b;
}

int main()
{
    int n;
    cin >> n;
    long long int ans;
    cin >> ans;
    rep(i, n-1)
    {
        long long int temp;
        cin >> temp;

        ans = ans * (temp / gcd(ans, temp));
    }
    cout << ans << endl;
    return 0;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int human[15];
vector<pair<int, int>> test[15];

void init(){
    rep(i, 15) human[i] = -1;
}

//正直 -> もう既に決まってて異なる時にfalse
//嘘 -> もう既に決まってて同じ時にfalse
//まだ決まってない時にはhuman[x] = y if 正直, else human[x] = !y
int solve(int N, vector<int>& A){
    int cnt = 0;
    rep(i, N) {human[i] = A[i]; if(human[i]) cnt++;}
    rep(i, N){
        rep(j, test[i].size()){
            int x = test[i][j].first;
            int y = test[i][j].second;
            if(A[i] == 1){
                if(human[x] != y) return 0;
            }
        }
    }
    return cnt;
}

int main(void){
    int N; cin >> N;
    
    rep(i, N){
        int num; cin >> num;
        rep(j, num){
            int x, y; cin >> x >> y; x--;
            test[i].push_back(make_pair(x,y));
        }
    }
    int loop = pow(2,N);
    int ans = 0;
    rep(i, loop){
        int val = i;
        vector<int> work;
        rep(j, N){
            work.push_back(val%2);
            val /= 2;
        }
        int eval = solve(N, work);
        ans = max(ans, eval);
        init();
    }
    
    cout << ans << endl;
    return 0;
}

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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

bool sieve[200010] = {false};
ll sum[100010];

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

    sieve[0] = sieve[1] = true;
    for (int n = 2; n <= 500; n++) {
        if (sieve[n]) continue;
        for (int m = 2; n*m <= 200005; m++) sieve[n*m] = true;
    }

    sum[0] = sum[1] = 0;
    for (int n = 2; n <= 100000; n++) {
        if (sieve[n] == false && sieve[(n+1)/2] == false) sum[n] = sum[n-1] + 1;
        else sum[n] = sum[n-1];
    }

    int Q;
    cin>>Q;
    for (int q = 0; q < Q; q++) {
        int l, r;
        cin>>l>>r;
        cout<<sum[r] - sum[l-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<vector<int>> arr(3,vector<int> (n));for(int i=0; i<n; i++)for(int j=0; j<3; j++)cin>>arr[j][i];

    
    for(int i=1; i<n; i++){
      arr[0][i]  = arr[0][i] + max(arr[1][i-1],arr[2][i-1]);
      arr[1][i]  = arr[1][i] + max(arr[0][i-1],arr[2][i-1]);
      arr[2][i]  = arr[2][i] + max(arr[0][i-1],arr[1][i-1]);
    }
    cout<<max(arr[0][n-1],max(arr[1][n-1],arr[2][n-1]))<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
int K;
using P = vector<int>;
P e;

P Rev(P p) {
  P rev(p.size());
  rep(i, N) {
    rev[p[i]] = i;
  }
  return rev;
}

P Conv(P p, P q) {
  P ret(N);
  rep(i, N) {
    ret[i] = p[q[i]];
  }
  return ret;
}

void Out(P p) {
  rep(i, N) {
    printf("%d%c", p[i]+1, " \n"[i == N-1]);
  }
}

int main() {
  scanf("%d%d", &N, &K);
  rep(i, N) e.eb(i);
  
  vector<int> p(N);
  vector<int> q(N);
  rep(i, N) {
    scanf("%d", &p[i]);
    --p[i];
  }
  rep(i, N) {
    scanf("%d", &q[i]);
    --q[i];
  }

  if (K == 1) {
    Out(p);
    return 0;
  }

  if (K == 2) {
    Out(q);
    return 0;
  }

  int L = K-4;
  P rp = Rev(p);
  P rq = Rev(q);
  P g = Conv(Conv(rp, rq), Conv(p, q));
  int t = L/6;

  if (K == 3) {
    Out(Conv(q, rp));
    return 0;
  }
  
  P h(q);
  rep(i, 30) {
    if (t >> i & 1) {
      h = Conv(h, g);
    }
    g = Conv(g, g);
  }

  P ans(e);
  switch(L%6) {
  case 0:
    ans = Conv(Conv(h, rp), Rev(h));
    break;
  case 1:
    h = Conv(h, rp);
    ans = Conv(Conv(h, rq), Rev(h));
    break;
  case 2:
    h = Conv(h, rp);
    ans = Conv(Conv(h, Conv(rq, p)), Rev(h));
    break;
  case 3:
    h = Conv(h, Conv(rp, rq));
    ans = Conv(Conv(h, p), Rev(h));
    break;
  case 4:
    h = Conv(h, Conv(Conv(rp, rq), p));
    ans = Conv(Conv(h, q), Rev(h));
    break;
  case 5:
    h = Conv(h, Conv(Conv(rp, rq), p));
    ans = Conv(Conv(h, Conv(q, rp)), Rev(h));
    break;
  default:
    assert(0);
  }
  Out(ans);
}


Measured memory_bytes: 6820
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = Console.ReadLine();
			if(!IsPalindrome(s))
			{
				Console.WriteLine("No");
				return;
			}
			if(!IsPalindrome(s.Substring(0, (s.Length - 1) / 2)))
			{
				Console.WriteLine("No");
				return;
			}
			if (!IsPalindrome(s.Substring((s.Length + 3) / 2 - 1, (s.Length - 1) / 2)))
			{
				Console.WriteLine("No");
				return;
			}
			Console.WriteLine("Yes");
		}

		private static bool IsPalindrome(string s)
		{
			for(int i = 0; i < s.Length / 2; i++)
			{
				if(s[i] != s[s.Length - i - 1])
				{
					return false;
				}
			}
			return true;
		}
	}
}


Measured memory_bytes: 11092
from operator import mul
from functools import reduce

mod = 10**9 + 7
n,k = map(int,input().split())

def cmb(n,r,mod):
  if r==0 or n==r:return 1
  r = min(n-r,r)
  ue = reduce(mul, range(n, n-r, -1))
  shita = reduce(mul, range(1,r+1))
  return (ue//shita)%mod

for i in range(1,k+1):
  try:print(cmb(n-k+1,i,mod)*cmb(k-1,k-i,mod)%mod)
  except:print(0)


Measured memory_bytes: 3944
#include <iostream>

int main(int argc, char const *argv[])
{
    int W, H, x, y, r;
    int circle_top, circle_bottom, circle_left, circle_right;

    std::cin >> W >> H >> x >> y >> r;

    circle_top = y + r;
    circle_bottom = y - r;
    circle_left = x - r;
    circle_right = x + r;

    if (circle_top <= H && circle_bottom >= 0 && circle_left >= 0 && circle_right <= W)
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}



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

void MAIN() {
    int n;
    scanf("%d", &n);
    std::vector<int> cost(201, 0);
    for(int i = 0; i < n; ++ i) {
        int now;
        scanf("%d", &now);
        for(int j = 0; j < 201; ++ j) {
            cost[j] += (j - 100 - now) * (j - 100 - now);
        }
    }
    int ans = INT_MAX;
    for(int now: cost) {
        ans = std::min(ans, now);
    }
    printf("%d\n", ans);
}

int main() {
    MAIN();
    return 0;
}


Measured memory_bytes: 256
n = int(input())
XY = []
ans = 0

for i in range(n):
    z = []
    
    for j in range(int(input())):
        x,y = map(int,input().split())
        z.append([x,y])
        
    XY.append(z)
        
for i in range(2**n):
    honest = 0
    mujunn = 0
    
    for j in range(n):
        if (i>>j) & 1:
            honest += 1
            
            for k in XY[j]:
                x = k[0] - 1
                y = k[1]
                
                if (i>>x)&1 != y:
                    mujunn = 1
                
    if mujunn == 0:
        ans = max(ans,honest)
        
print(ans)

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


int main() {

  string s;
  cin >> s;

  int min = 1000;

  for(int i=0; i<s.size()-2; i++){
    int n = stoi(s.substr(i, 3));
    int d = abs(753-n);
    if(d<min) min = d;
  }

  cout << min << endl;
}


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

int prime[123456*2];
int main(){
  memset(prime, 1, sizeof(prime));
  prime[0] = 0;
  prime[1] = 0;
  for(int i = 2; i <= sqrt(123456*2); i++){
    if(prime[i]){
      for(int j = i; i * j < 123456*2; j++){
        prime[i*j] = 0;
      }
    }
  }
  int n;
  while(cin >> n, n){
    int cnt = 0;
    for(int i = n+1; i <= 2*n; i++){
      if(prime[i]) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 4056
import sys
input=sys.stdin.readline


def main():
    N, S = map(int, input().split())
    *A, = map(int, input().split())
    dp = [[0]*(3001) for _ in range(N+1)]
    MOD = 998244353
    m = pow(2, MOD-2, MOD)
    dp[0][0] = pow(2, N, MOD)
    for i in range(1, N+1):    
        for j in range(3001):
            dp[i][j] += dp[i-1][j]
            if j-A[i-1]>=0:
                dp[i][j] += dp[i-1][j-A[i-1]]*m
            dp[i][j] %= MOD

    print(dp[N][S])


main()

Measured memory_bytes: 132692
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef long long ll;

int main() {
  ll a, b;
  cin >> a >> b;
  if (a > b)
    cout << a - 1 << endl;
  else
    cout << a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd ..

int main(void) {
  ll a, b, x;
  cin >> a >> b >> x;

  if (a == 0) {
    cout << (ll)b / x + 1 << endl;
    return 0;
  }

  cout << (ll) b / x - (ll) (a - 1) / x << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  string a;
  cin >> a;
  if (a[0] == a[1] && a[2] == a[0] && a[0] == a[3] ){
    cout << "No" << endl;
  }
  else if (a[0] == a[1] && a[2] == a[3]){
    cout << "Yes" << endl;
  }
  else if (a[0] == a[2] && a[1] == a[3]){
    cout << "Yes" << endl;
  }
  else  if (a[0] == a[1] && a[2] == a[3]){
    cout << "Yes" << endl;
  }
   else  if (a[0] == a[3] && a[2] == a[1]){
    cout << "Yes" << endl;
  }
   else  if (a[2] == a[1] && a[0] == a[3]){
    cout << "Yes" << endl;
  }
   else  if (a[3] == a[1] && a[2] == a[0]){
    cout << "Yes" << endl;
  }
   else  if (a[2] == a[3] && a[0] == a[1]){
    cout << "Yes" << endl;
  }else {
      cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

	int n;
	int a[101][101]={0};
	int sum[101][101]={0};
	int cal,ans;

	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>a[i][j];
		}
	}

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			sum[i][j]=a[i][j]+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];	
		}
	}

	ans=sum[1][1];

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=i;k<=n;k++){
				for(int l=j;l<=n;l++){
					cal=sum[k][l]-sum[i-1][l]-sum[k][j-1]+sum[i-1][j-1];
					if(cal>ans) ans=cal;
				}
			}
		}
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

int main() {
  int k;
  cin >> k;
  vector<ll> a;
  for (int i = 1; i <= 9; ++i) a.push_back(i);
  while (true) {
    if (k <= a.size()) {
      cout << a[k - 1] << endl;
      return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(old, a);
    for (ll x : old) {
      for (int i = -1; i <= 1; ++i) {
        int d = x % 10 + i;
        if (d < 0 || d > 9) continue;
        ll nx = x * 10 + d;
        a.push_back(nx);
      }
    }
  }
  return 0;
}

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

int main(){
    int a;
    cin >> a;
    int b;
    cin >> b;
    int c;
    cin >> c;
    if (a>=b && b>=c) {
        cout << c << " " << b << " " << a << endl;
    }else if (a>=c && b<=c){
        cout << b << " " << c << " " << a << endl;
    }else if (a<=b && c<=a) {
        cout << c << " " << a << " " << b << endl;
    }   else if (a<=c && c<=b) {
        cout << a << " " << c << " " << b << endl;
    } else if (a<=b && b<=c) {
        cout << a << " " << b << " " << c << endl;
    } else {
        cout << b << " " << a << " " << c << endl;
    }
    return 0;
}





Measured memory_bytes: 3116
using static System.Math;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;

namespace AtCoder
{
    class Program
    {
        private static long mod = 1000000007;
        static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            var line = ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();

            var sums = new long[line.Length + 1];
            for(var i = 0; i < line.Length; i++)
            {
                sums[i + 1] = (sums[i] + line[i]) % mod;
            }

            long sum = 0;
            for(var i = 0; i < line.Length - 1; i++)
            {
                var sub = sums.Last() - sums[i + 1];
                if(sub < 0)
                {
                    sub += mod;
                }
                sum += line[i] * sub % mod;
                sum %= mod;
            }

            WriteLine(sum);
        }
    }
}

Measured memory_bytes: 49276
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
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 chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please



int A[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N;
	scanf("%d ", &N);
	char S[4001];
	fread(S, 1, N, stdin);

	int R[4010], G[4010], B[4010];
	int r = 0, g = 0, b = 0;
	rep(i, N) {
		if (S[i] == 'R') R[r++] = i;
		if (S[i] == 'G') G[g++] = i;
		if (S[i] == 'B') B[b++] = i;
	}
	R[r] = 10000;
	G[g] = 10000;
	B[b] = 10000;

	ll kotae = ll(r) * g * b;
	int maer = 0;
	int maeg = 0;
	int maeb = 0;
	int tmp;
	rep(i, N) {
		if (S[i] == 'R') {
			while (G[maeg] < i) maeg++;
			tmp = maeg;
			while (G[tmp] * 2 - i < N) {
				kotae -= (S[G[tmp++] * 2 - i] == 'B');
			}

			while (B[maeb] < i) maeb++;
			tmp = maeb;
			while (B[tmp] * 2 - i < N) {
				kotae -= (S[B[tmp++] * 2 - i] == 'G');
			}
		}
		else if (S[i] == 'G') {
			while (B[maeb] < i) maeb++;
			tmp = maeb;
			while (B[tmp] * 2 - i < N) {
				kotae -= (S[B[tmp++] * 2 - i] == 'R');
			}

			while (R[maer] < i) maer++;
			tmp = maer;
			while (R[tmp] * 2 - i < N) {
				kotae -= (S[R[tmp++] * 2 - i] == 'B');
			}
		}
		else {
			while (G[maeg] < i) maeg++;
			tmp = maeg;
			while (G[tmp] * 2 - i < N) {
				kotae -= (S[G[tmp++] * 2 - i] == 'R');
			}

			while (R[maer] < i) maer++;
			tmp = maer;
			while (R[tmp] * 2 - i < N) {
				kotae -= (S[R[tmp++] * 2 - i] == 'G');
			}
		}
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 1768