akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
  Scanner scan = new Scanner(System.in);
   
  int A = scan.nextInt();
  int B = scan.nextInt();
  scan.close();

  	if(A + B >= 10){
  	System.out.println("error");
  	
  	}else{
  	System.out.println(A + B);
  	}
  }
}


Measured memory_bytes: 23636
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin>>s;
    vector<int>P;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0'){
            P.push_back(0);
        }
        else if(s[i]=='1'){
            P.push_back(1);
        }
        else{
            if(P.size()==0)continue;
            P.pop_back();
        }
    }
    for(int i=0;i<P.size();i++){
        cout<<P[i];
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef pair<ut,ut> prs;
const int SIZE=2*1e5;
const LL p=7+1e9;
LL A[SIZE];
inline void IN(ut &x){cin >> x;}
inline void INA(ut n,ut x[]){REP(i,n) cin >> x[i];}
inline void INE(ut m,VI edges[]){
	ut a,b;
	REP(i,m){
		cin >> a >> b;
		edges[a].PB(b);
		edges[b].PB(a);
	}
}
inline void INEC(ut m,Vpr edges[]){
	ut a,b,c;
	REP(i,m){
		cin >> a >> b >> c;
		edges[a].PB(pr(c,b));
		edges[b].PB(pr(c,a));
	}
}
int main(){
	LL N,M;
	cin >> N;
	INA(N,A);
	if(N==1){
		cout << 1 << endl;
		return 0;
	}
	LL now=0,ans=0;
	FOR(i,1,N){
		LL pn=now;
		if(A[i]>A[i-1]) now=1;
		else if(A[i]<A[i-1]) now=2;
		if(pn && pn!=now) {
			ans++;
			now=0;
		}
	}
	cout <<ans+1 << endl;
	return 0;
}

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

using namespace std;

int main(){
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    if(x * 2 == w && y * 2 == h){
        cout << double(w) * double(h) / 2.0 << " " << 1;
    }else cout << double(w) * double(h) / 2.0 << " " << 0;
    return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	static void swap(int[] a,int idx1,int idx2){
		int t = a[idx1]; a[idx1] = a[idx2];  a[idx2] = t;
	}
	
	static void quicksort(int[] a,int left,int right){
		int pl = left;
		int pr = right;
		int x = a[(pl + pr) / 2];
		
		do{
			while(a[pl] < x) pl++;
			while(a[pr] > x) pr--;
			if(pl <= pr) swap(a,pl++,pr--);
		} while(pl <= pr);
		
		if(left < pr) quicksort(a,left,pr);
		if(pl < right) quicksort(a,pl,right);
	}
	
	public static void main(String[] args){
		Scanner std = new Scanner(System.in);
		
		int nx = std.nextInt();
		int[] x = new int[nx];
		int k = std.nextInt();
		int sum = 0;
		
		for(int i = 0;i < nx;i++){
			x[i] = std.nextInt();
		}
		
		quicksort(x,0,nx-1);
		
		for(int i = x.length - 1;i >= nx - k;i--){
			sum += x[i];
		}
		System.out.print(sum);
	}
}

Measured memory_bytes: 20692
import math

N, K = map(int, input().split())

def f(n, k):
    return 0.5 ** math.ceil(math.log2(k/float(n)))
ans = 0
if K > N:
    for n in range(1, N+1):
       ans += f(n, K) * 1/N
       
else:
    for n in range(1, K):
        ans += f(n, K) * 1/N
    ans += float(N-K+1)/N
    
print(ans)


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

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

int main(){
    ll a;
    REP(i,10000){
        cin >> a;
        if(a==0)break;
        cout<< "Case " << i+1 << ": " << a<<endl;
    }
    return 0;
}


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

int n, m;
bool G[50][50], used[50];

void DFS(int now){
    if(used[now]) return;
    used[now] = true;
    REP(i, n){
        if(i == now) continue;
        if(G[now][i]) DFS(i);
    }
}

int main(){
    cin >> n >> m;
    vector<pair<int, int>> A(m);
    REP(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a][b] = true; G[b][a] = true;
        A[i] = make_pair(a, b); 
    }
    int ans = 0;
    for(auto x : A){
        int a, b;
        a = x.first;
        b = x.second;
        G[a][b] = false; G[b][a] = false;
        REP(i, n) used[i] = false;
        DFS(0);
        int cnt = 0;
        REP(i, n) if(used[i]) cnt++;
        if(cnt != n) ans++;
        G[a][b] = true; G[b][a] = true;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long a,b,c;
inline long long read()
{
	long long x=0,y=1;char ch=getchar();
	while (ch>'9'||ch<'0'){
		if (ch=='-')y=-1;
		ch=getchar();
	}
	while (ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x*y;
}

int main()
{
	a=read();b=read();c=read();
	c-=b+a;
	if (c<0){
		printf("No");
		return 0;
	}
	c*=c; 
	a=a*b*4;
	if (a<c) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var s = new List<long>();
            for (int i = 0; i < N; i++)
            {
                s.Add(ReadLong());
            }

            s = s.OrderBy(x => x).ToList();

            var sum = s.Sum();
            if (sum % 10 != 0) return sum;

            foreach (var item in s)
            {
                var subSum = sum - item;
                if (subSum % 10 != 0) return subSum;
            }

            return 0;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll inf = 1e18L + 5;

int store[200007];
ll csum[200007];

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) scanf("%d", &store[i]);
    //sort(store+1, store+n+1);

    for (int i = 1; i <= n; i++) csum[i] = csum[i-1] + store[i];

    ll ans = inf;
    ll sum = 0;
    for (int i = n; i >= 2; i--) {
        sum += store[i];
        ans = min(ans, abs(sum - csum[i-1]));
    }

    cout << ans << "\n";
}


Measured memory_bytes: 2560
// Gaurav Nuti
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define ar array
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define INF 1e9 

ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

ll power_without_mod(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x); 
        y = y>>1;
        x = (x*x); 
    } 
    return res; 
}

bool comparep(pair<ll, ll> i1, pair<ll, ll> i2){
	return (i1.S < i2.S);
} 

ll modInverse(ll a)
{
    return power(a , mod - 2);
}

vector< vector<ll>> graph;
vector<ll> num;
vector<bool> visited;
vector<ll> dist;

void bfs(int u){
    queue<ll> q;
    q.push(u);
    visited[u] = 1;
    while(!q.empty()){
        int u1 = q.front();
        q.pop();
        for(auto i = graph[u1].begin();i!=graph[u1].end();i++){
            num[*i]--;
            dist[*i] = max(dist[u1] + 1,dist[*i]);
            if(!visited[*i] && num[*i] == 0){
                visited[*i] = 1;
                q.push(*i);
            }
        }
    }
}

// int next_lunlun(ll n){
//     vector<int> digits;
//     while(n){
//         digits.pb(n%10);
//         n /= 10;
//     }
//     // reverse(digits.begin(),digits.end());
//     ll num_digits = digits.size(); 
//     int count_9 = 0;
//     for(int i: digits)
//         if(i == 9)
//             count_9++;
//     if(count_9 == num_digits)
//         return ;
//     for(int i=0;i<(num_digits-1);i++){
//         if(digits)
//     }
// }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif  
	
    ll t;
    // cin>>t;
    t = 1;
    for(ll z=0;z<t;z++){
        ll n,m;
        cin>>n>>m;
        vector<vector<ll>> dp(n,vector<ll>(m));
        for(ll i=0;i<n;i++){
            for(ll j=0;j<m;j++){
                char x;
                cin>>x;
                if(i == 0 && j == 0)
                    dp[i][j] = (x == '.');
                if(x == '.' && i)
                    dp[i][j] += dp[i-1][j];
                if(x == '.' && j)
                    dp[i][j] += dp[i][j-1];
                dp[i][j] %= mod;
            }
        }
        cout<<dp[n-1][m-1];
    }
}

Measured memory_bytes: 11056
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: usize,
      aa: [[usize; n]; n],
    }

    let mut ans = 0;
    for i in 0..n {
        for j in i+1..n {
            let a = aa[i][j];

            let mut d = a+1;
            for k in 0..n {
                if k == i || k == j { continue }
                let c = aa[i][k] + aa[k][j];
                d = min(d, c);
            }

            if d < a {
                return println!("{}", -1)
            }

            if d != a {
                ans += a;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n = I()
A = sorted(LI())
B = sorted(LI())
C = sorted(LI())

ans = 0
for b in B:
    a = bisect_left(A, b)
    c = bisect_right(C, b)
    ans += a*(n-c)
print(ans)


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

int digit(int64_t x){
    int ret = 0;
    for(;x>0;ret++) x /= 10;

    return ret;
}

void matpow(const int64_t *X, int64_t *ans, int64_t n, int64_t mod){
    if(n==0){
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                ans[i*3+j] = (i==j ? 1 : 0);
            }
        }
    }else if(n==1){
        for(int i=0;i<9;i++) ans[i] = X[i] % mod;
    }else if(n%2 == 0){
        int64_t XX[9];
        for(int i=0;i<3;i++){
            for(int k=0;k<3;k++){
                XX[i*3+k] = 0;
                for(int j=0;j<3;j++){
                    XX[i*3+k] = (XX[i*3+k] + X[i*3+j] * X[j*3+k] % mod) % mod;
                }
            }
        }
        matpow(XX, ans, n/2, mod);
    }else{
        int64_t XX[9];
        for(int i=0;i<3;i++){
            for(int k=0;k<3;k++){
                XX[i*3+k] = 0;
                for(int j=0;j<3;j++){
                    XX[i*3+k] = (XX[i*3+k] + X[i*3+j] * X[j*3+k] % mod) % mod;
                }
            }
        }
        matpow(XX, ans, n/2, mod);
        for(int i=0;i<9;i++){
            XX[i] = ans[i];
            ans[i] = 0;
        }
        for(int i=0;i<3;i++){
            for(int k=0;k<3;k++){
                for(int j=0;j<3;j++){
                    ans[i*3+k] = (ans[i*3+k] + XX[i*3+j] * X[j*3+k] % mod) % mod;
                }
            }
        }
    }
}

int main(){   
    int64_t L, A, B, M;
    cin >> L >> A >> B >> M;

    pair<int64_t,int64_t> pos[19];
    for(int i=1;i<=18;i++){
        int64_t l = -1, r = L;
        while(r-l > 1){
            int64_t m = (l+r) / 2;
            if(digit(A + m*B) < i) l = m;
            else r = m;
        }
        pos[i].first = r;
        l = -1; r = L;
        while(r-l > 1){
            int64_t m = (l+r) / 2;
            if(digit(A + m*B) <= i) l = m;
            else r = m;
        }
        pos[i].second = r;
    }

    A %= M; B %= M;
    int64_t s = 0, n = A, d = 1;
    for(int i=1;i<=18;i++){
        d *= 10;
        int64_t X[9] = {0}, Xp[9];
        X[0] = d % M;
        X[1] = X[4] = X[5] = X[8] = 1;
        matpow(X, Xp, pos[i].second - pos[i].first, M);
        s = (Xp[0]*s%M + Xp[1]*n%M + Xp[2]*B%M) % M;
        n = (Xp[3]*s%M + Xp[4]*n%M + Xp[5]*B%M) % M;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
A=[0]*n
maxd = 0
smax = 0
for i in range(n):
	A[i] = int(input())
	if A[i] >= maxd:
		smax = maxd
		maxd =A[i]
	elif A[i] >= smax:
		smax = A[i]
for i in range(n):
	if A[i]==maxd:
		print(smax)
	else:
		print(maxd)

Measured memory_bytes: 12508
#include<stdio.h>
int main(void)
{
	int a[100],N,flag=0;
	scanf("%d",&N);

	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
	}

	for(int i=0;i<N;i++){
		if(a[i]%2==0){
			if(a[i]%3!=0 && a[i]%5!=0){
				flag=1;
			}
		}
	}
	if(flag==0) printf("APPROVED");
	else printf("DENIED");

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
	int N,n,sum;
	vector<int> point;
	while(1){
		cin>>N;
		if(N==0) break;
		sum=0;

		while(!point.empty()){
			point.pop_back();
		}

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

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

		for(int i=1;i<point.size()-1;i++){
			sum+=point[i];
		}
		cout<<sum/(point.size()-2)<<endl;
	}
	return 0;
}	

Measured memory_bytes: 1216
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#define INF 2000000000
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define mk make_pair
#define en endl
#define RE return 0
#define int ll
#define P pair<int,int>
using namespace std;
int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0};
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
int lcm(int a,int b){if(a==0){return b;} return a/gcd(a,b)*b;}

pair<P, int> G[45] ; // 物質の情報

int dp[50][510][510];

signed main(){
	int n,m1,m2; cin>>n>>m1>>m2;
	int sum_a=0,sum_b=0,s=0;
	for(int i=0; i<n; i++){
		int c,d,e; cin>>c>>d>>e;
		sum_a+=c; sum_b+=d; s+=e;
		G[i]=mk(mk(c,d), e);
	}
	
	for(int k=0; k<=43; k++) for(int i=0; i<=500; i++) for(int j=0; j<=500; j++) dp[k][i][j]=INF;
	
	dp[0][0][0]=0;
	for(int i=0; i<n; i++){
		int a=G[i].first.first,b=G[i].first.second,c=G[i].second;
		for(int j=0; j<=sum_a; j++){
			for(int k=0; k<=sum_b; k++){
				if(j-a>=0&&k-b>=0) dp[i+1][j][k]=min(dp[i+1][j][k], dp[i][j-a][k-b]+c);
				dp[i+1][j][k]=min(dp[i+1][j][k], dp[i][j][k]);
			}
		}
	}
	int ans=INF;
	for(int i=1; i<=sum_a; i++){
		for(int j=1; j<=sum_b; j++){
			if(i*m2==j*m1){
				ans=min(ans, dp[n][i][j]);
			}
		}
	}
	if(ans<INF) cout<<ans<<en;
	else cout<<-1<<en;
}



Measured memory_bytes: 90368
#include <bits/stdc++.h>
using namespace std;
int main(){
  string t;cin>>t;
  string g = "Yes";
  for(int i=0; i<t.size(); i++){
    if(i%2==0 && t[i]=='L')g = "No";
    if(i%2==1 && t[i]=='R')g = "No";
  }
  cout<<g<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> p(n), rev(n), sorted(n, 0);
    for(int i = 0; i < n; i++)  cin >> p[i], rev[p[i]] = i;
    for(int i = 1; i < n; i++){
        if(p[i-1] < p[i])   sorted[i] = 1;
        sorted[i] += sorted[i-1];
    }
    set<int> s;
    for(int i = 0; i < k; i++){
        s.insert(p[i]);
    }
    int ans = 0, flat = 0;
    if(sorted[k-1] == k-1)  flat++;
    else                    ans++;
    for(int i = 1; i <= n-k; i++){
        bool flag = (p[i-1] != *s.begin());
        s.erase(p[i-1]);
        s.insert(p[i+k-1]);
        flag |= (p[i+k-1] != *s.rbegin());
        if(sorted[i+k-1]-sorted[i] == k-1)  flat = 1;
        else if(flag)                       ans++;
    }
    cout << ans+flat << endl;
    return 0;
}

Measured memory_bytes: 12032
#include <iostream>
#include <string>
using namespace std;
int main()
{
 int h,w;
 cin >> h >> w;
 string s[h];
 for(int i = 0;i < h;i++)
  cin >> s[i];
 for(int i = 0;i < h;i++)
  cout << s[i] << endl << s[i] << endl;
 return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
import math

n = int(input())
a = list(map(int, input().split()))
m = max(a)
fre = [0 for _ in range(m+1)]

for i in range(n):
    fre[a[i]] += 1

# pairwise coprime
pairwise = True
for i in range(2, len(fre)):
    cnt = 0 
    for j in range(i, m+1, i): 
        cnt += fre[j]
    if cnt > 1:
        pairwise = False
if pairwise:
    print('pairwise coprime')
    exit()

# setwise coprime
ans = math.gcd(a[0],a[1])
for i in range(2, n): 
   ans = math.gcd(ans, a[i])
if ans == 1:
    print('setwise coprime')
    exit()

print('not coprime')


Measured memory_bytes: 220652
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp;

use std::collections::{BTreeMap, BTreeSet};
fn divisor(n: i64) -> BTreeSet<i64> {
    let mut i = 1;
    let mut div = BTreeSet::new();
    while i * i <= n {
        if n % i == 0 {
            div.insert(i);
            if n / i != i {
                div.insert(n / i);
            }
        }
        i += 1;
    }
    div
}

#[fastout]
fn main() {
    input! {
        n: usize,
        mut a: [i64; n],
    }
    a.sort();
    let mut popl = BTreeMap::new();
    for &x in &a {
        *popl.entry(x).or_insert(0) += 1;
    }
    let mut set = BTreeSet::new();
    let mut ans = 0;
    for &x in &a {
        if popl[&x] > 1 {
            set.insert(x);
            continue;
        }
        let mut ok = true;
        for &d in &divisor(x) {
            if set.contains(&d) {
                ok = false;
                break;
            }
        }
        if ok {
            ans += 1;
        }
        set.insert(x);
    }

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


Measured memory_bytes: 14588
import copy

# a = get_int()
def get_int():
    return int(input())

# a = get_string()
def get_string():
    return input()

# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]

# a_list = get_string_list():
def get_string_list():
    return input().split()

# a, b = get_int_multi()
def get_int_multi():  # a, b = get_int_multi()
    return map(int, input().split())

# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))

# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():
    k = get_int()
    prev = 7 % k
    ret = -1

    amari = prev

    if amari == 0:
        ret = 1
    else:

        for i in range(1, k):
            prev = (prev * 10) % k
            amari = (amari + prev) % k

            if amari == 0:
                ret = i+1
                break

    print(ret)


def check(bunshi, k):
    return (bunshi % k == 0)


if __name__ == '__main__':
    main()




Measured memory_bytes: 9260
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set('display_errors', 'Off');

// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d %d %d", $A, $B, $C);

if ($A == $B) {
    echo $C . PHP_EOL;
} elseif ($A == $C) {
    echo $B . PHP_EOL;
} else {
    echo $A . PHP_EOL;
}


Measured memory_bytes: 4604
mcxi = "mcxi"
mcxinum = [1000, 100, 10, 1]

n = int(input())
for z in range(n):
    nums = list(input().split())

    ans = 0
    for num in nums:
        for ind, c in enumerate(mcxi):
            if c in num:
                prestr, num = num.split(c)
                pre = 1
                if prestr:
                    pre = int(prestr)
                ans += pre * mcxinum[ind]

    ansstr = ""
    for j in range(4):
        dig = mcxinum[j]
        if ans >= dig:
            dign = ans // dig
            if dign > 1:
                ansstr += str(dign)
            ansstr += mcxi[j]
            ans %= dig

    print(ansstr)


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double W,H,x,y;
    cin >> W >> H >> x >> y;
    cout <<W*H/2<< "\n";
    if(W/2 == x && H/2 == y){
        cout <<"1"<< "\n";
    }else{
        cout <<"0"<< "\n";
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <random>
#include <stdio.h>
#include <bitset>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl


#
void func() {
  LL N;
  cin >> N;
  LL WWW;
  cin >> WWW;

  vector<LL> W(N);
  vector<LL> V(N);
  REP(i, N) {
    cin >> W[i];
    cin >> V[i];
  }

  vector<vector<LL>> M(N+1, vector<LL>(WWW+1));
  REP(i, N) {
    REP(w, WWW + 1) {
      if (w - W[i] >= 0) {
        M[i+1][w] = max(M[i][w - W[i]] + V[i], M[i][w]);
      }
      else {
        M[i + 1][w] = M[i][w];
      }
    }
  }

  //REP(i, N+1) {
  //  PRINTSP(M[i]);
  //}
  cout << M[N][WWW];

}

#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





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

using namespace std;

const double pi = acos(-1.0);

int main()
{
	double res, a, b, h, m, t, x, y, z;
	cin>>a>>b>>h>>m;
	t = h * 60 + m;
	x = 2 * pi * t / 720;
	y = 2 * pi * m / 60;
	if (x > y) z = x - y; else z = y - x;
	if (x > pi) x -= pi;
	res = sqrt(a * a + b * b - 2 * a * b * cos(z));
	cout<<fixed<<setprecision(20)<<res<<endl;
	return 0;
}

Measured memory_bytes: 4228
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long H = sc.nextLong();
		Main main = new Main();
		List<Knife> list = new ArrayList<Knife>();
		for (int i=0;i<N;i++) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			Knife ak = main.new Knife();
			ak.damage = a;
			ak.count = 100;
			Knife bk = main.new Knife();
			bk.damage = b;
			bk.count = 1;
			list.add(ak);
			list.add(bk);
		}
		Collections.sort(list);
		long count =0;
		for (int i=list.size()-1;i>=0;i--) {
			Knife knife = list.get(i);
			if (knife.count==1) {
				count++;
				H-=knife.damage;
				if (H<=0) {
					break;
				}
			} else {
				while (H>0) {
					count++;
					H-=knife.damage;
				}
				break;
			}
		}
		System.out.println(count);
	}

	public class Knife implements Comparable<Knife>{
		long damage;
		int count;
		@Override
		public int compareTo(Knife o) {
			if(this.damage-o.damage>0) {
				return 1;
			}
			if (this.damage==o.damage) {
				return 0;
			}
			return -1;
		}


	}
}

Measured memory_bytes: 98656
//C
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 10;
int n,m,k;
char G[maxn][maxn];
char tmp[maxn][maxn];
bool vis[1024][1024];
int cal(int x,int y){
	int ans = 0;
	memcpy(tmp,G,sizeof(G));
	for(int i = 0;i <= n;i++)if((1<<i)&x){
		for(int j = 1;j <= m;j++)tmp[i+1][j] = 'X';
	}
	for(int i = 0;i <= m;i++)if((1<<i)&y){
		for(int j = 1;j <= n;j++){
			tmp[j][i+1] = 'X';
		}
	}
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= m;j++){
			if(tmp[i][j] == '#')ans++;
		}
	}
	return ans;
}
int main(){
	cin >> n >> m >> k;
	for(int i = 1;i <= n;i++){
		string s;
		cin >> s;
		for(int j = 1;j <= m;j++)G[i][j] = s[j-1];
	}
	ll ans = 0;
	for(int i = 0;i <= (1<<(n+1)-1) - 1;i++){
		for(int j = 0;j <= (1<<(m+1)-1)-1;j++){
			if(cal(i,j) == k){
				ans++;
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3632
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

pub fn factorize(mut x: i64) -> BTreeMap<i64, i64> {
    let mut ms = BTreeMap::new();
    let r = (x as f64).sqrt() as i64 + 1;

    for p in 2..r as i64 {
        let mut m = 0;

        while x >= p && x % p == 0 {
            x /= p;
            m += 1;
        }

        if m > 0 {
            ms.insert(p, m);
        }
    }

    // `x` can have a prime factor larger than √x at most one.
    if x > 1 {
        ms.insert(x, 1);
    }

    ms
}

fn main() {
    let mut scan = Scan::new();

    let mut N = scan.word::<i64>();
    let mut q = vec![];

    for (p, m) in factorize(N) {
        let mut t = p;
        for _ in 1..=m {
            q.push(t);
            t *= p;
        }
    }

    q.sort();
    let mut count = 0;

    for z in q.drain(..) {
        if z > N {
            break;
        }
        if N % z != 0 {
            continue;
        }

        N /= z;
        count += 1;
    }

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


Measured memory_bytes: 2188
N = int(input())
h = list(map(int,input().split()))
x = [0]*N
x[0]=0
x[1]=abs(h[1]-h[0])
for i in range(2,N):
    x[i] = min(x[i-1]+abs(h[i]-h[i-1]),x[i-2]+abs(h[i]-h[i-2]))
print(x[N-1])


Measured memory_bytes: 13980
K = int(input())

if K <= 10:
    print(K)
    exit()


dp = [[0]*10 for _ in range(10)]    # i の最大値は　3234566667の10桁よりi = 9
i = 0
flg = False

for k in range(10):
    dp[0][k] = 1

S = 8
while True:
    i += 1
    for k in range(10):
        if k==9:
            dp[i][k] = dp[i-1][k] + dp[i-1][k-1]
        elif k == 0:
            dp[i][k] = dp[i - 1][k + 1] + dp[i - 1][k]
        else:
            dp[i][k] = dp[i - 1][k + 1] + dp[i - 1][k] + dp[i - 1][k - 1]
        if k != 0:
            S += dp[i][k]
        if S >= K-1:
            flg = True
            break
    if flg:
        break
i_max, k_max = i, k
i_max -= 1
res = [k_max]
for i in range(i_max, -1, -1):
    for k in reversed(range(k_max-1,k_max+2)):
        if k > 9 or k < 0:
            continue
        if S - dp[i][k] >= K-1:
            S -= dp[i][k]
        else:
            break
    k_max = k
    res.append(k)

print(*res, sep="")


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

using namespace std;

const int N = 1e5 + 5;

#define all(x) x.begin(), x.end()

vector<int> p[3];

int X, Y, n[3];

typedef long long ll;

ll res = 0;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> X >> Y >> n[0] >> n[1] >> n[2];
    for (int i = 0; i < 3; i++) {
        p[i].assign(n[i], 0);
        for (auto &x : p[i]) cin >> x;
        sort(all(p[i]));
        reverse(all(p[i]));
    }
    int cnt[] = {0, 0, 0}; int top[] = {X, Y, X + Y};
    for (int i = 1; i <= X + Y; i++) {
        int v = -1, k = 0;
        for (int j = 0; j < 3; j++) {
            if (cnt[j] >= top[j]) continue;
            if (p[j][cnt[j]] > v)
                v = p[j][cnt[j]], k = j;
        }
        res += v;
        cnt[k] += 1;
    }
    cout << res << endl;
    return 0;
}


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

int main() {
    long long n;
    cin >> n;
    long long a[3*n];
    for(long long i=0;i<3*n;i++) cin >> a[i];
    sort(a,a+3*n);
    long long ans=0;
    for(long long i=n;i<3*n;i+=2){
        ans+=a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <bitset>
#include <cstdlib>

int main()
{
    char num[4];
    for(int i=0; i<4; i++) scanf("%c", &num[i]);
    int A = num[0] - '0';
    int B = num[1] - '0';
    int C = num[2] - '0';
    int D = num[3] - '0';

    // printf("%d %d %d %d\n", A, B, C, D);
    char out[3];
    int S;
    for(int i=0; i<8; i++){
        std::bitset<3> op(i);
        S = A;
        S += (op[0] == true) ? B : -B;
        S += (op[1] == true) ? C : -C;
        S += (op[2] == true) ? D : -D;
        if(S==7){
            out[0] = (op[0] == true) ? '+' : '-';
            out[1] = (op[1] == true) ? '+' : '-';
            out[2] = (op[2] == true) ? '+' : '-';
            break;
        }
    }

    printf("%d%c%d%c%d%c%d=7\n", A, out[0], B, out[1], C, out[2], D);
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main {

	
	int lcs(char[] X, char[] Y, int m, int n) 
    { 
        int table[][] = new int[m + 1][n + 1]; 
  
        for (int i = 1; i <= m; i++) { 
            for (int j = 1; j <= n; j++) { 
                if (X[i - 1] != Y[j - 1]) {
                	table[i][j] = max(table[i - 1][j], table[i][j - 1]);}
                else {
                     table[i][j] = 1 + table[i - 1][j - 1];}
            } 
        } 
        return table[m][n]; 
    } 
	
	int max(int a, int b) {
		if (a > b) {
			return a;
		}
		else {
			return b;
		}
	}
	
	public static void main(String[] args) {
		Main test1 = new Main();
	    Scanner in = new Scanner(System.in);
	    int total = in.nextInt();
	    
	    for(int i = 0; i < total; i++) {
	    	String a1 = in.next();
	    	String a2 = in.next();
	    	char[] a=a1.toCharArray(); 
	    	char[] b=a2.toCharArray(); 
	    	int m = a.length; 
	    	int n = b.length;
	    	System.out.println(test1.lcs( a, b, m, n ) );}
	    
	    
	}
}



Measured memory_bytes: 64228
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const double pi = 3.14159265358979323846;
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
  char x;
  cin>>x;
  
  if(isupper(x))
    cout<<"A";
  else
    cout<<"a";
  return 0;
}

Measured memory_bytes: 3632
N = int(input())

dList = [int(i) for i in input().split()]
ispossible = True

if dList[0] != 0:
    ispossible = False
dList.pop(0)

amari = 998244353
dList.sort()

if dList[0] <= 0:
    ispossible = False


sameDistanceCount = 1
prevdistance = 0
branch = 1
count = 1

for i in range(N-1):
    nowdistance = dList[i]
    if nowdistance - prevdistance >= 2:
        ispossible = False
        break
    elif nowdistance == prevdistance + 1:
        for j in range(sameDistanceCount):
            count *= branch
            count %= amari
        branch = sameDistanceCount
        prevdistance = nowdistance
        sameDistanceCount = 1
    else:
        sameDistanceCount += 1


for i in range(sameDistanceCount):
    count *= branch
    count %= amari

if ispossible:
    print(count)
else:
    print(0)


Measured memory_bytes: 53036
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,x,st[N],top=0;
int main() {
    cin>>n>>x;n=2*n-1;
    if(x==1||x==n) puts("No");
    else {
        puts("Yes");
        for(int i=1;i<=x-2;i++) st[++top]=i;
        for(int i=x+2;i<=n;i++) st[++top]=i;
        int mid=(n+1)/2;
        for(int i=1;i<=mid-2;i++) printf("%d\n",st[top--]);
        printf("%d\n%d\n%d\n",x-1,x,x+1);
        for(int i=mid+2;i<=n;i++) printf("%d\n",st[top--]);
    }
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


Measured memory_bytes: 2304
#include <iostream>
using namespace std;
int main(){
    //int n[10000];
    for(int i = 1; i < 10001;i++){
        int j = 0;
        cin>>j;
        if(j > 0){
            cout<<"Case "<<i<<": "<<j<<endl;
        }else{
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int flag=0;
    for(int i=1; i<=b; i++){
        if(a*i%b==c){
            cout << "YES";
            flag=1;
            break;
        }
    }
    if(flag==0){
        cout << "NO";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>

using namespace std;

int main(void){
    int a, b;
    string op;

    while(cin >> a >> op >> b){
        if(op == "?")
            break;
        else if(op == "+")
            cout << a + b <<endl;
        else if(op == "-")
            cout << a - b <<endl;
        else if(op == "*")
            cout << a * b <<endl;
        else
            cout << a / b <<endl;
    }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define lb(v,x) lower_bound(all(v),x)
#define ub(v,x) upper_bound(all(v),x)
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}

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

const int N = 3005;

double p[N];
double dp[N][N];

int main(){
    IOS
    
    int n;
    cin>>n;
    FOR(i,1,N+1){
        cin>>p[i];
    }
    dp[0][0]=1;
    FOR(i,1,n+1){
        dp[i][0]=dp[i-1][0]*(1-p[i]);
        FOR(j,1,i+1){
            dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
        }
    }
    double ans=0;
    FOR(i,n/2+1,n+1){
        ans+=dp[n][i];
    }
    cout<<fixed<<setprecision(9)<<ans;
    cerr<<1.0/CLOCKS_PER_SEC<<endl;
    return 0;
}

Measured memory_bytes: 68992
s = input().strip()

prev = None
ans1, ans2 = 0, 0
for _s in s:
  if prev is None:
    prev = _s
  elif prev != _s:
    ans1 += 1
    prev = _s
prev = None
for _s in s[::-1]:
  if prev is None:
    prev = _s
  elif prev != _s:
    ans2 += 1
    prev = _s
print(min(ans1, ans2))

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int n; cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        if(a%2) {
            cout << "first" << endl;
            return;
        }
    }

    cout << "second" << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

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

int main() {
    int A, B; cin >> A >> B;
    int ans = 0;
    int now = 1;
    while(now < B){
        now += A-1;
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <list>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <vector>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
// const ll MOD = 1000000009;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << std::fixed << setprecision(15);
    auto unit_r = 180.0 / M_PI;

    int64_t n;
    
    cin >> n;

    vector<tuple<ll,ll, ll, ll>> ab(n-1);
    for (ll i = 0; i < n-1; ++i) {
        ll a, b;
        cin >> a >> b;
        ab[i] = make_tuple(i, a, b, 0);
    }

    sort(ab.begin(), ab.end(), []( const auto &x, const auto &y )
         {
             return get<1>( x ) != get<1>( y ) ? get<1>( x ) < get<1>( y ) : get<2>( x ) < get<2>( y );
         });

    // for (ll i = 0; i < n-1; ++i) {
    //     cerr << "ab[" << i << "] == " << get<1>(ab[i]) << ", " << get<2>(ab[i]) << endl;
    // }

    ll m = 0;
    ll curVertex = 0;
    ll curColor = 0;
    vector<ll> color(n+10, 1);
    color[1] = 0;
    for (ll i = 0; i < n-1; ++i) {
        auto v = get<1>(ab[i]);
        if (v != curVertex) {
            curColor = 1;
            curVertex = v;
        } else {
            curColor = curColor + 1;
        }
        if (color[v] == curColor) curColor++;
        m = max(m, curColor);
        get<3>(ab[i]) = curColor;
        color[get<2>(ab[i])] = curColor;
    }

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

    cout << m << endl;
    for (ll i = 0; i < n-1; ++i) {
        cout << get<3>(ab[i]) << endl;
    }

}


Measured memory_bytes: 4352
S = input()
if S == 'SUN':  print(7)
elif S == 'MON':  print(6)
elif S == 'TUE':  print(5)
elif S == 'WED':  print(4)
elif S == 'THU':  print(3)
elif S == 'FRI':  print(2)
elif S == 'SAT':  print(1)

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    string t;
    cin >> t;
    rep(i,t.size()){
        if(t[i] == '?') t[i] = 'D';
    }
    dunk(t);
    return 0;
}

Measured memory_bytes: 3752
using System;
using System.Collections.Generic;

class Program {
    static void Main( string[] args )
    {
        List<int> l = new List<int>();

        for ( int i = 1; i < 10001; ++i ) {
            int n = int.Parse( Console.ReadLine() );

            if ( 0 == n ) {
                break;
            }

            l.Add( n );
        }

        for ( int i = 0; i < l.Count; ++i ) {
            Console.WriteLine( "Case {0}: {1}", i + 1, l[ i ] );
        }
    }
}

Measured memory_bytes: 9424
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll w[100005];
ll s[100005];
ll ans = 0;
ll mxw,n;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n>>mxw;
    ll sum =  0 ;
    vector<ll>dp(mxw+1,0);

    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>s[i];
        for(int j=mxw-w[i];j>=0;j--)
        {
            dp[j+w[i]]=max(dp[j+w[i]],dp[j]+s[i]);
            ans=max(ans,dp[j+w[i]]);
        }
    }


        for(int i=0;i<=mxw;i++)
        {
            ans=max(ans,dp[i]);
        }
        cout<<ans<<endl;
}


Measured memory_bytes: 3996
def solve(inp):
    N = int(inp.readline().strip())

    return str((int(N / 2) + (N % 2)) / N)


def test(s):
    from io import StringIO
    print(solve(StringIO(s)))


def main():
    import sys
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    # test('50\n' + '100 ' * 50)
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

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

using namespace std;

int main(){
    int p, q, r;
    cin >> p >> q >> r;
    int ans = 10000000;
    ans = min(p+q, p+r);
    ans = min(q+r, ans);
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    if (n % 2 == 0)
        cout << n << endl;
    else
        cout << 2 * n << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define m (int)1e9



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

  int s;
  cin>>s;

  if(s==(int)1e18){
    cout<<0<<' '<<0<<' ';
    cout<<0<<' '<<m<<' ';
    cout<<m<<' '<<m<<endl;
    return 0;
  }


  cout<<0<<' '<<0<<' ';
  cout<<m<<' '<<m-s%m<<' ';
  cout<<1<<' '<<s/m+1<<endl;
}

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

using ll = long long;

void solve(long long N, std::vector<long long> A){
    vector<ll> dp(N, 1000);

    for(int i = 0;i < N - 1;i++){ 
        for(int j = i + 1;j < N;j++){
            if(A[i] < A[j]){
                dp[j] = max((dp[i] / A[i] * A[j]) + (dp[i] % A[i]), dp[j]);
            }
        }
        dp[i + 1] = max(dp[i + 1], dp[i]);
    }
    cout<<dp[N - 1]<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 3672