akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

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

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

use std::cmp;

fn main() {
    input! {
        n: i32,
        s: String,
    }
    let (ans, count) = s.chars().fold((0, 0), |(mut an, mut co),  c| {
            if c == 'D' { co -= 1 } 
            if c == 'I' { co += 1 }
            an = cmp::max(an, co);
            (an, co)
            
    });

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





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

  int n;
  cin>>n;

  vector<int> p(n);
  rep(i,n){
    cin>>p[i];
  }

  vector<int> q(n,1);
  rep(i,n){
    q[ub(q,-p[i])]=-p[i];
  }

  int ans=0;
  rep(i,n){
    if(q[i]!=1) ans++;
  }
  cout << ans << endl;

}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



int main(){
	
	int N;
	cin>>N;
	
	string S;
	cin>>S;
	
	int ok = 0;
	int ng = N+1;
	
	while(ng-ok>1){
		int mid = (ng+ok)/2;
		map<string,int> mp;
		bool f = false;
		for(int i=0;i<N+1-mid;i++){
			string s = S.substr(i,mid);
			if(mp[s]==0)mp[s]=i+1;
			else{
				if(i+1-mp[s]>=mid){
					f=true;
					break;
				}
			}
		}
		if(f)ok=mid;
		else ng=mid;		
	}
	
	cout<<ok<<endl;
	
	return 0;
}

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

typedef long long ll;

int n, k;
string s;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k >> s;
    s[k - 1] -= ('A' - 'a');
    cout << s << endl;

    return 0;
}



Measured memory_bytes: 256
N=int(input())
*A, = map(int,input().split())

ans = 0
l = 0
ud = 0
for a in A:
  if l==0:
    ans += 1
    l+=1
  elif l==1:
    if b<a:
      ud = 1
      l+=1
    elif b>a:
      ud = -1
      l+=1
  else:
    if b<a and ud == -1:
      ans += 1
      l = 1
    elif b>a and ud == 1:
      ans += 1
      l = 1
  b = a
print(ans)


Measured memory_bytes: 14224
use std::io::prelude::*;

const MOD : u64 = 1_000_000_007;
enum State { X(u64), Y1(u64), Y2(u64), }

fn main(){
  let mut buf = String::new();
  std::io::stdin().read_to_string(&mut buf).expect("fail to read");
  let mut lines = buf.lines();
  
  let n : usize = lines.next().unwrap().parse().unwrap();
  let S : Vec<&[u8]> = lines.map(|s| s.as_bytes()).collect();

  use State::*;
  let s0 = if S[0][0] == S[1][0] { X(3) } else { Y1(6) };
  
  let ans = (1 .. n).fold(s0, |s, i| {
    if S[0][i] == S[1][i] {
      match s {
        X(v) => X(v * 2 % MOD),
        Y2(v) => X(v),
        Y1(v) => unreachable!(),
      } 
    } else {
      match s {
        X(v) => Y1(v * 2 % MOD),
        Y2(v) => Y1(v * 3 % MOD),
        Y1(v) => Y2(v),
      }
    }
  });
  
  match ans {
    X(v) => println!("{}", v),
    Y2(v) => println!("{}", v),
    _ => unreachable!(),
  }
  
}

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

void Main() {
	double A, B;
	long long N, maxY, tmp;
	cin >> A >> B >> N;
	tmp = B - 1;
	if (N < tmp) {
		tmp = N;
	}
	cout << static_cast<long long>(floor(A * tmp / B) - A * floor(tmp / B)) << endl;
}

int main() {
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,y,z,k; cin >> x >> y >> z >> k;
	vector<ll> a(x),b(y),c(z);
	rep(i,x) cin >> a.at(i);
	rep(i,y) cin >> b.at(i);
	rep(i,z) cin >> c.at(i);
	vector<ll> sum1(x * y);
	rep(i,x){
		rep(j,y){
			sum1.at(i * y + j) = a.at(i) + b.at(j);
		}
	}
	sort(sum1.rbegin(),sum1.rend());
	vector<ll> sum2(min(k, x * y) * z);
	rep(i,min(k, x * y)){
		rep(j,z){
			sum2.at(i * z + j) = sum1.at(i) + c.at(j);
		}
	}
	sort(sum2.rbegin(),sum2.rend());
	rep(i,min(k, x * y * z)){
		cout << sum2.at(i) << endl;
	}
}


Measured memory_bytes: 31616
import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int s = sc.nextInt();

    int a = s;
    for (int i=0; i<=1000000; i++) {
      if (a == 4 || a == 2 || a == 1) {
        System.out.println(i + 4);
        return;
      }
      if (a % 2 == 0) {
        a = a / 2;
      } else {
        a = 3 * a + 1;
      }
    }

  }

}

Measured memory_bytes: 22996
#include <cstdio>
#include <cmath>

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

char s[100001];
int k;

int main() {
	scanf("%s", s);
	scanf("%d", &k);
	
	for(int i = 0; ; i++) {
		if(s[i + 1] != '\0') {
			if(s[i] != 'a' && 'z' + 1 - s[i] <= k) {
				k -= 'z' + 1 - s[i];
				s[i] = 'a';
			}
		} else {
			k %= 26;
			s[i] = 'a' + (s[i] - 'a' + k) % 26;
			break;
		}
	}
	
	printf("%s\n", s);
	
	return 0;
}


Measured memory_bytes: 512
n, m = list(map(int, input().split(" ")))
c = list(map(int, input().split(" ")))
dp = [10**5 for i in range(n + 1)]
dp[0] = 0

for i in range(0, n+1):
    for coin in c:
        if i >= coin:
            dp[i] = min(dp[i-coin] + 1, dp[i])
print(dp[n])



Measured memory_bytes: 7380
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
bool CAN=true;
using namespace std;

int main(){
  ll N,ans=0;
  cin>>N;
  ll A[N+1],POS[N+1];
  for(int i=1; i<=N; ++i){
    cin>>A[i];
    POS[A[i]]=i;
  }
  
  set<ll> S={0,N+1};
  
  for(int i=1; i<=N; ++i){
    ll R,L;
    
    auto itr=S.lower_bound(POS[i]);
    R=*itr;
    // lower_boundで右端を調べる(upper_boundでもいい)
    L=*(--itr);
    // その1個手前が左端
    
    ans+=i*(POS[i]-L)*(R-POS[i]);
    S.insert(POS[i]);
  }
  
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;


int main () {

	int n, k;
	scanf("%d %d", &n, &k);

	vector <int> a (n);
	for (int &x : a) scanf("%d", &x);

	vector <int> dp (k + 1);

	for (int stones = 0; stones <= k; ++stones) {
		
		for (int x : a) {
			if (stones - x >= 0 && !dp[stones-x]) {
				dp[stones] = true; 
			}
		
		}
		
	}

	puts (dp[k] ? "First" : "Second");


	return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null) {
			int n = Integer.parseInt(line);
			System.out.println(n * (n + 1) / 2 + 1);
			line = null;
		}

	}

}

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

using namespace std;
using ll = long long;

int main() {
	
	int N, tmp;
	vector<int> v;
	double t = 0;
	
	cin >> N;
	for(int i=0; i<N; i++) {
		cin >> tmp;
		v.push_back(tmp);
	}
	
	sort(v.begin(), v.end());
	t = v[0];
	for(int i=1; i<N; i++) {
		t = (t + v[i]) / 2.0;
	}
	
	cout << t << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lp 2*pos+1
#define rp 2*pos+2
#define m (l+r)/2
#define N 200009
#define ll long long
using namespace std;
ll seg[N*4],a[N];
ll qu(int pos,int l,int r,int b)
{
    if(r<b)return 0;
    if(b<=l)return seg[pos];
    ll x=0,y=0;
    x=qu(lp,l,m,b);
    y=qu(rp,m+1,r,b);
    return max(x,y);
}
void upd(int pos,int l,int r,int v,ll val)
{
    if(l==r)
    {
        seg[pos]=val;
        return;
    }
    if(m>=v)upd(lp,l,m,v,val);
    else upd(rp,m+1,r,v,val);
    seg[pos]=max(seg[lp],seg[rp]);
    return;
}
int n,h[N];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=n-1;i>=0;i--)
    {
        ll x=a[i]+qu(0,0,n-1,h[i]);
        upd(0,0,n-1,h[i],x);
        //cout<<x<<"\n";
    }
    cout<<seg[0];
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define dscf(n) scanf("%lf",&n)
#define lpri(n) printf("%lld ",n)
#define dpri(n) printf("%lf ",n)
#define dprin(n) printf("%lf\n",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;
 
void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

ll bs(ll a[],ll b[],ll i,ll n)
{
      ll low=i+1,high=n-1;
      
}

int main()
{
     int n;
     scf(n);
     int a[n+1];
     int count=0;
     rep(i,1,n+1) {
     scf(a[i]);
     if(i%2!=0&&a[i]%2!=0)
     count++; }
     pri(count);
}

Measured memory_bytes: 3820
n = int(input())
p = []
g = 0
ans = 0

for i in range(n):
    p.append(int(input()))

for i in p:
    g += i
    
if p[0] * n == g:
    ans = g - p[0] // 2
else:
    disc = max(p) // 2
    ord = g - max(p)
    ans = disc + ord

print(ans)

Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
ans = 1
for i in range(n):
    if a[i] == 0:
        print(0)
        exit()
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 21644
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] abx = br.readLine().split(" ");
        long a = Long.parseLong(abx[0]);
        long b = Long.parseLong(abx[1]);
        long x = Long.parseLong(abx[2]);
        
        /*int count = 0;
        for (long i = a; i <= b; i++) {
            if (i % x == 0) count++;
        }*/
        
        long ans = b/x - a/x;
        
        System.out.println(a%x==0?ans+1:ans);
    }
}


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

#ifdef ONLINE_JUDGE
#define lld I64
#endif

#define endl '\n'
#define ii pair<int,int>
#define ll long long
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define add push_back

int main(){ios_base::sync_with_stdio(false);
    
    int n, k, d, x;
    cin >> n >> k;
    set<int> s;
    while(k--){
        cin >> d;
        while(d--){
            cin >> x;
            s.insert(x);
        }
    }
    
    cout << (n-s.size()) << endl;

    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(all(p));
    int sum = 0;
    for(int i = 0; i < k; i++) {
        sum += p[i];
    }
    cout << sum << endl;
}

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

bool dp[110000]; // dp[k] = true : when stone is k, first will win
int N;
int a[100];

int main() {
    int N,K; cin >> N >> K;
    for(int i=0;i<N;++i) cin >> a[i];
    dp[0] = false; // first loses when K = 0
    for(int i = 1; i <= K; ++i){
        for(int j = 0; j < N; ++j){
            if(a[j] <= i) dp[i] |= !dp[i-a[j]];
        }
    }
    cout << (dp[K] ? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int r=scanner.nextInt();
    int D=scanner.nextInt();
    int x=scanner.nextInt();

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

  }
}


Measured memory_bytes: 21716
#include <iostream>
#include <map>

using namespace std;

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

	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;

		table[x] = 1;
	}

	cout << table.size() << endl;

	return 0;
}

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

	static int max,d,w;
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(true) {
			d=in.nextInt();w=in.nextInt();
			if(d==0)break;
			int G[][]=new int[d][w]; max=0;
			for(int i=0;i<d;i++) {
				for(int j=0;j<w;j++)G[i][j]=Integer.parseInt(in.next());
			}
			
			for(int i=0;i<=d-3;i++) {
				for(int j=0;j<=w-3;j++)solve(G,i,j,3,3);
			}
			System.out.println(max);
		}
	}
	
	static void solve(int[][] A,int y,int x,int dep,int wid) {
		if(y+dep>d || x+wid>w)return;
		//int g[][]=new int[dep-y-2][wid-x-2];
		int edgmin=9,lkmax=0,maxv=0;
		for(int i=y;i<dep+y;i++) {
			for(int j=x;j<wid+x;j++) {
				if(i==y || i==dep+y-1 || j==x || j==wid+x-1)edgmin=Math.min(edgmin,A[i][j]);
				else {
					//maxv+=A[i][j];
					lkmax=Math.max(lkmax, A[i][j]);
				}
			}
		}
		if(edgmin>lkmax) {
			for(int i=y+1;i<dep+y-1;i++) {
				for(int j=x+1;j<x+wid-1;j++)maxv+=edgmin-A[i][j];
			}
		}
		//System.out.printf("y=%d x=%d dep=%d wid=%d edge=%d lake=%d sum=%d\n",y,x,dep,wid,edgmin,lkmax,maxv);
		max=Math.max(max, maxv);
		solve(A,y,x,dep+1,wid);
		solve(A,y,x,dep,wid+1);
	}

}



Measured memory_bytes: 35176
#include<bits/stdc++.h>
#define N 100010

using namespace std;

int main(){
	int n, k, h[N], cost[N];

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

	//alg
	cost[0]=0;
	for(int i=1;i<n;i++){
		cost[i] = int(1e9);
		for(int j=i-1;j>=max(0,i-k);j--){
			cost[i] = min(cost[i],cost[j]+abs(h[i]-h[j]));	
		}
	}

	cout << cost[n-1] << '\n';

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
	long long A, B, C, K;
	cin >> A >> B >> C >> K;

	if (K < A){
		cout << K << endl;
	} else if (K <= A + B){
		cout << A << endl;
	} else {
		cout << A - (K - A - B) << endl;
	}
	return 0;
}


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

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

# from Kiri8128
# https://qiita.com/Kiri8128/items/eca965fe86ea5f4cbb98#%E7%B4%A0%E5%9B%A0%E6%95%B0%E5%88%86%E8%A7%A3%E3%82%92-on14-%E3%81%A7%E3%81%99%E3%82%8B

def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret


GCD=A[0]
for a in A:
    GCD=gcd(GCD,a)

if GCD!=1:
    print("not coprime")
    sys.exit()

SET=set()
for a in A:
    S=set(primeFactor(a))
    #print(S,SET)

    if SET & S !=set():
        print("setwise coprime")
        sys.exit()
    SET|=S

print("pairwise coprime")



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

vector<string> split(string &s, char delimiter){
  vector<string> res;
  int prev_split_point = 0;
  for (int i = 0; i < s.length(); i++) {
    while(s[i] != delimiter && i < s.length())i++;
    string add = s.substr(prev_split_point, i - prev_split_point);
    if(!add.empty())res.push_back(add);
    prev_split_point = i + 1;
  }
  return res;
}

int main(int argc, char *argv[]){
  string s;
  cin >> s;
  vector<string> key = split(s, '.');
  vector<string> yaml;
  cin.ignore();
  int indent = 0, p = 0;
  while(getline(cin, s))yaml.push_back(s);
  for (int i = 0; i < key.size() && p < yaml.size(); i++) {
    while(p < yaml.size() &&
          key[i] != yaml[p].substr(indent, key[i].length())){
      p++;
    }
    while(i < key.size() - 1 &&
          p + 1 < yaml.size() && yaml[p + 1][indent] == ' ')indent++;
    if(i < key.size() - 1 && p < yaml.size())p++;
  }
  int len = key[key.size() - 1].length()+ 2;
  if(p == yaml.size()){
    std::cout << "no such property" << std::endl;
  }else if(yaml[p].length() <= indent + len){
    std::cout << "object" << std::endl;
  }else{
    std::cout << "string \"" << yaml[p].substr(indent + len) << "\"" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1292
// AOJ 1371: Infallibly Crack Perplexing Cryptarithm
// 2018.1.8 bal4u@uu

#include <stdio.h>
#include <string.h>
#include <ctype.h>

#define INF 0x7fffffff

int sz;
char org[35], str[35], *p; int len;
char tr[128];
char token[9] = "()01+-*="; int tlen = 8;
char assign[8];
char used[8];
int ans;

int expr();

int num()
{
	int n = 0;

	if (*p == '0') { p++; if (*p == '0' || *p == '1') return INF; }
	else if (*p == '1') {
		while (*p == '0' || *p == '1') n = (n << 1) + (*p++ & 1);
	} else n = INF;
	return n;
}

int factor()
{
	int x;

	if (*p == '-') {
		p++;
		if ((x = factor()) == INF) return INF;
		return -x;
	}
	if (*p == '(') {
		p++; if ((x = expr()) == INF) return INF;
		if (*p++ != ')') return INF;
	} else x = num();
	return x;
}

int term()
{
	int x, y;

	if ((x = factor()) == INF) return INF;
	while (1) {
		if (*p != '*') break;
		p++;
		if ((y = factor()) == INF) return INF;
		x *= y;
	}
	return x;
}

int expr()
{
	int x, y, op;

	if ((x = term()) == INF) return INF;
	while (1) {
		if      (*p == '+') op = 1;
		else if (*p == '-') op = 0;
		else break;
		p++;
		if ((y = term()) == INF) return INF;
		if (op) x += y; else x -= y;
	}
	return x;
}

void calc()
{
	int par, eq, a, b;
	char *eq_p;

	strcpy(str, org);
	par = 0, eq = 0;
	for (p = str; *p; p++) {
		if (isalpha(*p)) *p = assign[tr[*p]];
		if (*p == '=') eq = 1, eq_p = p;
		else if (*p == '(') par++;
		else if (*p == ')') par--;
	}

	if (!eq || par) return;
	if (*str == '=' || *(str+len-1) == '=') return;

//printf("str %s\n", str);
	*eq_p++ = 0;
	p = str, a = expr();
	if (a == INF || *p != 0) return;
	p = eq_p, b = expr();
	if (b == INF || *p != 0) return;
	if (a == b) ans++;
//printf("a %d, b %d, ans %d\n", a, b, ans);
}

void rec(int k)
{
	int i;

	if (k == sz) { calc(); return; }
	for (i = 0; i < tlen; i++) {
		if (used[i]) continue;
		used[i] = 1;
		assign[k] = token[i];
		rec(k+1);
		used[i] = 0;
	}
}

int main()
{
	int eq;

	eq = 0;
	memset(tr, -1, sizeof(tr));
	fgets(org, 35, stdin);
	for (p = org; *p > ' '; p++) {
		if (*p == '=') eq = 1;
		else if (isalpha(*p)) { if (tr[*p] < 0) tr[*p] = sz++; }
	}
	*p = 0, len = p-str;

	if (sz + eq > 8) { puts("0"); return 0; }
	if (eq) tlen = 7;
	rec(0);
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;

const int MOD = 1000000007;
const int MAX32 = 2147483647;
const double PI = 3.14159265358979323846;

int main() {
  long long n, d, cnt = 0, x, y;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    if (d - sqrt(x*x+y*y) >= 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3668
#include <iostream>

using namespace std;

bool right(int a, int b, int c) {
    return a*a+b*b == c*c;
}

int main() {
    int n;
    cin >> n;
    while(n--) {
        int a, b, c;
        cin >> a >> b >> c;
        if(right(a,b,c) || right(a,c,b) || right(b,c,a)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#![allow(non_snake_case)]
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let r:usize = sc.read();
    println!("{}", r*r);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n, k, ans;
	cin>>n>>k;
	ans = k;
	for(int i = 0; i < n - 1; ++i){
		ans *= k - 1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

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

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn f(s1: usize, s2: usize, s3: usize) -> usize {
    let s_max = max(s1, max(s2, s3));
    let s_min = min(s1, min(s2, s3));
    s_max - s_min
}

fn calc(H: usize, W: usize) -> usize {
    let mut min_d = std::usize::MAX;

    for i in 1..H {
        let s1 = i * W;

        // 平行に割る。
        for d in 0..5 {
            let j = (i + (H - i) / 2 + d).saturating_sub(2);
            if i < j && j < H {
                let s2 = (j - i) * W;
                let s3 = (H - j) * W;
                min_d = min(min_d, f(s1, s2, s3));
            }
        }

        // 垂直に割る。
        for d in 0..5 {
            let j = (W / 2 + d).saturating_sub(2);
            if 0 < j && j < W {
                let s2 = j * (H - i);
                let s3 = (W - j) * (H - i);
                min_d = min(min_d, f(s1, s2, s3));
            }
        }
    }

    min_d
}

fn main() {
    let (H, W) = read!(usize, usize);
    println!("{}", min(calc(H, W), calc(W, H)));
}


Measured memory_bytes: 4352
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#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 SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	long double n,d,m;
	cin>>n>>m>>d;
	long double ans=(m-1)/n;
	if(n<2*(n-d) && d!=0){
		ans+=(n-2*d)*(m-1)/(n*n);
	}
	cout<<fixed<<setprecision(10);
	cout<<ans<<endl;
	
	return 0;
}

















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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  
  if(a.at(a.size() - 1) == b.at(0) && b.at(b.size() - 1) == c.at(0)){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl

bool palin(string s,ll x,ll y)
{
    ll i=x;
    ll j=y;
    while(i<j)
    {
        if(s[i]!=s[j])
        {
            return false;
        }
        i++;
        j--;
    }
    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll n=s.size();
    if(palin(s,0,n-1) && palin(s,0,(n-2)/2) && palin(s,n/2+1,n-1))
    {
        cout<<"Yes"<<nl;
    }
    else
        cout<<"No"<<nl;
}


Measured memory_bytes: 256
package main
 
import (
	"fmt"
	"sort"
)
 
// 4 3
// 3 3 -4 -2
func main() {
	var N, K int
	fmt.Scanf("%d %d\n", &N, &K)
 
	A := make([]int, N)
	for i := 0; i < N; i++ {
		var a int
		fmt.Scanf("%d", &a)
		A[i] = a
	}
	sort.Ints(A)
	ld, rd := int(-1e18), int(1e18)
	for rd-ld > 1 {
		mid := (ld + rd) / 2
		//fmt.Println(ld, rd, mid)
		cnt := 0
		for i := 0; i < N; i++ {
			l, r := -1, N
			if A[i] >= 0 {
				for r-l > 1 {
					m := (l + r) / 2
					//fmt.Println(l, r, m)
					if A[i]*A[m] >= mid {
						r = m
					} else {
						l = m
					}
					//time.Sleep(time.Second * 2)
				}
				cnt += r
			} else {
				for r-l > 1 {
					m := (l + r) / 2
					//fmt.Println(l, r, m)
					if A[i]*A[m] >= mid {
						l = m
					} else {
						r = m
					}
					//time.Sleep(time.Second * 2)
				}
				cnt = cnt + N - r
			}
			if A[i]*A[i] < mid {
				cnt -= 1
			}
		}
		cnt = cnt / 2
		//fmt.Println(cnt, ld, rd, mid)
 
		if cnt >= K {
			rd = mid
		} else {
			ld = mid
		}
		//time.Sleep(time.Second * 2)
	}
	fmt.Println(ld)
}


Measured memory_bytes: 5760
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
char wea[][10]={"Sunny","Cloudy","Rainy"};
int main()
{
    char a[10];
    scanf("%s",a);
    for(int i=0;i<3;i++)
    {
        if(strcmp(a,wea[i])==0){
            printf("%s\n",wea[(i+1)%3]);
            break;}
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=10000009;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,k,x,y;
	int ans;
	cin>>n>>k>>x>>y;
	if(n<=k){
		ans=x*n;
	}
	else{
		ans=x*k+y*(n-k);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 764
//C
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

struct man { int id, num; } p[maxn];

inline bool cmp(man x, man y) { return x.num < y.num; }

int main() {
    reg int n = read();
    for (reg int i = 1; i <= n; i++) p[i].num = read(), p[i].id = i;
    sort(p + 1, p + n + 1, cmp);
    for (reg int i = 1; i <= n; i++) cout << p[i].id << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
#include <cassert>
using namespace std;

static long long getDays(long long y, long long m, long long d)
{
  if(m <= 2){
    --y;
    m += 12;
  }
  long long dy = 365 * (y - 1);
  long long c = y / 100;
  long long dl = (y >> 2) - c + (c >> 2);
  long long dm = (m * 979 - 1033) >> 5;
  return dy + dl + dm + d - 1;
}

int main(){
	string s;
	while(cin >> s && s != "#"){
		if( count(s.begin(),s.end(),'.') == 2 ){
			// seireki
			int y,m,d;
			sscanf(s.c_str(),"%d.%d.%d",&y,&m,&d);
			long long days = getDays(y,m,d) - getDays(2012,12,21);
			days %= 20 * 18 * 20 * 20 * 13;
			int b,ka,t,w,ki; int wei = 20 * 18 * 20 * 20;
			b = days / wei; days %= wei; wei /= 20;
			ka= days / wei; days %= wei; wei /= 20;
			t = days / wei; days %= wei; wei /= 18;
			w = days / wei; days %= wei; wei /= 20;
			ki = days / wei; days %= wei;
			cout << b << "." << ka << "." << t << "." << w << "." << ki << endl;
		}else{
			// maya
			int b,ka,t,w,ki;
			sscanf(s.c_str(),"%d.%d.%d.%d.%d",&b,&ka,&t,&w,&ki);
			int days = 0;
			int wei = 1;
			days += wei * ki; wei *= 20;
			days += wei * w;  wei *= 18;
			days += wei * t;  wei *= 20;
			days += wei * ka; wei *= 20;
			days += wei * b;  wei * 13;
			int y = 2012 , m = 12 , d = 21;
			int table[] = {-1,31,28,31,30,31,30,31,31,30,31,30,31};
			while(days--){
				d++;
				if( d > table[m] + (m == 2 && ( y % 400 == 0 || (y % 4 == 0 && y % 100 != 0)) ) ){
					m++;
					d = 1;
				}
				if( m > 12 ){
					y++;
					m = 1;
				}
			}
			cout << y << "." << m << "." << d << endl;
		}
		
	}
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mk make_pair
#define all(c) (c).begin(),(c).end()
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define debug2(x,y) cerr<<"("<<#x<<","<<#y<<") = ("<<x<<","<<y<<")\n";
#define debugM(x,n,m) rep(i,0,n){ rep(j,0,m) cerr<<x[i][j]<<" ";cerr<<endl;}
#define debugV(x,n) rep(i,0,n){cerr<<x[i]<<" ";}cerr<<endl; 
#define pi 3.14159265358979323846264338
typedef pair<int,int> ii;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;
const int MOD = 1e9+7;

int n;
ll a[100100],b[100100];

ll minll(ll a,ll b){
	if(a > b) return b;
	return a;
}

int main(){
	scanf("%d",&n);
	rep(i,0,n+1) scanf("%lld",&a[i]);
	rep(i,0,n) scanf("%lld",&b[i]);
	ll ans=0;
	rep(i,0,n){
		ll dif = minll(b[i],a[i]);
		ans+=dif;
		if(b[i] > a[i]){
		   b[i]-=dif,a[i]=0;
		   dif = min(a[i+1],b[i]);
		   ans+=dif;
		   a[i+1]-=dif;
		} 		
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int n=s.length(), digitsum=0;
  for(int i=0; i<n; i++)
  {
    digitsum+=(s[i]-'0');
  }
  if(digitsum%9==0) cout<<"Yes"<<endl;
  else
    	cout<<"No"<<endl;
}

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

int main(void) {
  int N;
  cin >> N;
  bool can = false;
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      can |= i * j == N;
    }
  }
  cout << (can ? "Yes" : "No") << endl;
  return 0;
}

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


int main(){
 int a[3][3],n;
 for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
    cin>>a[i][j];
    cin>>n;int b[n];
 for(int i=0;i<n;i++)cin>>b[i];
    for(int k=0;k<n;k++)
    {
        int cur=b[k];
        for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
    {
        if(a[i][j]==cur)a[i][j]=0;
    }
    }
    bool p=0;int c=0;
     for(int i=0;i<3;i++)
     {
         c=0;
    for(int j=0;j<3;j++)
    {
        if(a[i][j]==0)c++;
    }
    if(c==3){cout<<"Yes";return 0;}
     }
     for(int j=0;j<3;j++)
     {
         c=0;
    for(int i=0;i<3;i++)
    {
        if(a[i][j]==0)c++;
    }
    if(c==3){cout<<"Yes";return 0;}
     }c=0;
     for(int k=0;k<3;k++)
     {
         if(a[k][k]==0)c++;
     }
     if(c==3){cout<<"Yes";return 0;}
     c=0;
     for(int k=0;k<3;k++)
     {
         if(a[k][3-k-1]==0)c++;
     }
     if(c==3){cout<<"Yes";return 0;}
     cout<<"No";
    return 0;
}


Measured memory_bytes: 256
import math

a, b, x = map(int, input().split())
if x > a**2*b/2:
  degree = math.degrees(math.atan2(2*a**2*b-2*x, a**3))
  print(degree)
else:
  degree = math.atan2(2*x, a*(b**2))
  degree = math.pi/2 - degree
  print(math.degrees(degree))

Measured memory_bytes: 3188
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:

*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 200010;
const int MAXK = 110;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int n = SZ(s);
    s = " " + s;
    FOR(i,1,n) {
        if (i % 2) {
            if (s[i] == 'L') {
                cout << "No";
                return 0;
            }
        }
        else {
            if (s[i] == 'R') {
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;

typedef modint998244353 mint;

const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
//const ll MOD = 1e9 + 7;
const ll MOD = 998244353;

const ll MAX = 1e9 + 5;


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

	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	vector<ll> b(m);
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	vector<ll> c = convolution(a, b);
	for (ll ci : c) {
		cout << ci % MOD << " ";
	}
	cout << endl;


}

Measured memory_bytes: 27180
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	var count int
	if s[0:1] == "1" {
		count++
	}
	if s[1:2] == "1" {
		count++
	}
	if s[2:3] == "1" {
		count++
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int n,a[250005],is[505][505];
int dx[4]={0,-1,0,1},dy[4]={1,0,-1,0},ans=0;
int dis[505][505]={0};
struct Pair{
	int x,y;
};
void bfs(int x,int y){
	deque<Pair> q; 
	q.push_back({x,y});
	while(!q.empty()){
		Pair now=q.front();
		q.pop_front();
		for(int i=0;i<4;i++){
			Pair tmp={now.x+dx[i],now.y+dy[i]};
			if(tmp.x<1||tmp.y>n||tmp.y<1||tmp.x>n)continue;
			if(is[tmp.x][tmp.y]){
				if(dis[tmp.x][tmp.y]<=dis[now.x][now.y])continue;
				q.push_front(tmp);
				dis[tmp.x][tmp.y]=dis[now.x][now.y];
			}
			else {
				if(dis[tmp.x][tmp.y]<=dis[now.x][now.y]+1)continue;
				q.push_back(tmp);
				dis[tmp.x][tmp.y]=dis[now.x][now.y]+1;
			}
		}
	}
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n*n;i++)scanf("%d",&a[i]);
	for(int i=0;i<=n+1;i++){
		for(int j=0;j<=n+1;j++){
			dis[i][j]=min(min(i-1,n-i),min(j-1,n-j));
		}
	}
	for(int i=1;i<=n*n;i++){
		int x=(a[i]-1)/n+1,y=(a[i]-1)%n+1;
		ans+=dis[x][y],is[x][y]=1;
		for(int j=0;j<4;j++)dis[x][y]=min(dis[x][y],dis[x+dx[j]][y+dy[j]]);
		//cout<<x<<' '<<y<<' '<<dis[x][y]<<endl;
		bfs(x,y);
		//for(int j=0;j<4;j++)dis[x+dx[j]][y+dy[j]]=min(dis[x+dx[j]][y+dy[j]],dis[x][y]+1);
	}
	cout<<ans;
}


Measured memory_bytes: 7608
def solve(string):
    n, m, *abc = map(int, string.split())
    a = sorted(abc[:n])
    bc = sorted(list(zip(*[iter(abc[n:])] * 2)), key=lambda x: x[1])
    i = 0
    ans = 0
    for b, c in bc[::-1]:
        start = i
        while i < n and a[i] < c and b > 0:
            i += 1
            b -= 1
            ans += c
        if start == i:
            break
    ans += sum(a[i:]) if i < n else 0
    return str(ans)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(m + 1)])))


Measured memory_bytes: 38868
#include  <cstdio>
#include <iostream>

using namespace std;
int main()
{
    int n, k;
    while(cin >> n >> k)
    {
        long long res = k;
        for(int i = 1; i <= n-1; i++)
            res *= k-1;
        cout << res << endl;

    }


}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
struct edge{int to,cost;};
vector<int> G[100005];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
std::vector<P> tree[100010];
ll i,j;

ll n,k;
long long int ans=0;
ll q,h,s,d;

int main(){
	cin>>q>>h>>s>>d>>n;
	if(q*2<h)h=2*q;
	if(h*2<s)s=2*h;
	if(s*2<d)d=2*s;
	cout<<(n/2)*d+(n%2)*s<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>

int getgcd(int n, int m){
	int r;
	if (n > m) {
		int t = m;
		m = n;
		n = t;
	}
	while ((r = m % n) != 0) {
		m = n;
		n = r;
	}
	return n;
}

int main(void){
	int n, i, max; 
	scanf("%d",&n);
	int a[n+1], gcd1[n+1], gcd2[n+1], gcd3[n+1];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	
	int add = 0;
	gcd1[0] = a[0];
	
	for(i=1;i<n;i++){
		gcd1[i] = getgcd(gcd1[i-1], a[i]);
	}
	gcd2[n-1] = a[n-1];
	for(i=n-2;i>-1;i--){
		gcd2[i] = getgcd(gcd2[i+1], a[i]);
	}
	
	gcd3[0] =  gcd2[1];
	
	gcd3[n-1] =  gcd1[n-2];
	
	for(i=0;i<n-2;i++){
		gcd3[i+1] = getgcd(gcd1[i], gcd2[i+2]);
	}
	
	max = gcd3[0];
	for(i=1;i<n;i++){
		if(gcd3[i]>max){
			max=gcd3[i];
		}
	}
	
	printf("%d",max);
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <string.h>

int main(void){
    int num,i,n,sign,o;
    char map[256][11],line[11],ans[2][7]={"Opened","Closed"};
    scanf("%d",&num);
    for(i=0;i<num;i++)
        scanf("%s",map[i]);
    scanf("%d",&n);
    for(sign=1,i=0;i<n;i++){
        scanf("%s",line);
        for(o=0;o<num;o++){
            if(strcmp(line,map[o]) == 0){
                sign=1-sign;
                printf("%s by %s\n",ans[sign],map[o]);
                break;
            }
            if(o == num-1)
                printf("Unknown %s\n",line);
        }
    }
    return 0;
}

Measured memory_bytes: 608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		int n = sc.nextInt();
		int a[] = new int[n + 2];

		int sumCost = 0;

		for (int i = 1; i < n + 1; i++) {
			a[i] = sc.nextInt();
			sumCost += Math.abs(a[i] - a[i - 1]);
		}
		sumCost += Math.abs(a[n]);
		a[n + 1] = 0;

		for (int i = 1; i < n + 1; i++) {
			if ((a[i] - a[i - 1]) * (a[i] - a[i + 1]) > 0) {

				System.out.println(sumCost - 2 * Math.min(Math.abs(a[i] - a[i - 1]), Math.abs(a[i] - a[i + 1])));
			} else {
				System.out.println(sumCost);
			}

		}

	}

}


Measured memory_bytes: 77860
#include <stdio.h>

int main(void){
    char str[11] = {'\0'};

    scanf("%s", str);
    if(str[0] == 'Y' && str[1] == 'A' && str[2] == 'K' && str[3] == 'I')
        printf("Yes");
    else
        printf("No");

    return 0;
}

Measured memory_bytes: 128
N = int(input())
ans = 0
for i in range(N+1):
    if i % 2 == 0:
        continue
    tmp = []
    for j in range(1, int((i+1)**(1/2))+1):
        if i % j == 0:
            tmp.append(i)
            tmp.append(j)
    if len(tmp) == 8:
        ans += 1
print(ans)


Measured memory_bytes: 3060