akhauriyash/Code-Regression huggingface dataset:
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.OutputStream;
public class Main {
	public static void main(String args[]) {
		Sc sc = new Sc(System.in);
		long a = sc.nL();
		long b = sc.nL();
		long c = sc.nL();
		if(a%2 == 0 || b%2 == 0 || c%2 == 0) {
			System.out.println(0);
			return;
		}
		long min = a*b;
		min = Math.min(min,a*c);
		min = Math.min(min,b*c);
		System.out.println(min);
	}
}
class Sc {
    public Sc(InputStream i) {
        r = new BufferedReader(new InputStreamReader(i));
    }

    public boolean hasM() {
        return peekToken() != null;
    }

    public int nI() {
        return Integer.parseInt(nextToken());
    }

    public double nD() { 
        return Double.parseDouble(nextToken());
    }

    public long nL() {
        return Long.parseLong(nextToken());
    }

    public String n() {
        return nextToken();
    }

    private BufferedReader r;
    private String line;
    private StringTokenizer st;
    private String token;

    private String peekToken() {
        if (token == null) 
            try {
                while (st == null || !st.hasMoreTokens()) {
                    line = r.readLine();
                    if (line == null) return null;
                    st = new StringTokenizer(line);
                }
                token = st.nextToken();
            } catch (IOException e) { }
        return token;
    }

    private String nextToken() {
        String ans = peekToken();
        token = null;
        return ans;
    }
}

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

int main(){
    int n,k;
    string s;
    cin >> n >> k >> s;
    vector<int> a(n,0);
    int t=1,u=0;
    if(s[0]=='0')u++;
    for(int i=1;i<n;i++){
        if(s[i-1]==s[i])t++;
        else {
            a[u]=t;
            t=1;
            u++;
        }
    }a[u]=t;
    int ans,tmp=0;
    if((u+1)/2<=k)ans=n;
    else {
        for(int i=0;i<=k*2;i++)tmp+=a[i];
        ans=tmp;
        for(int i=2;i+k*2<=u+1;i+=2){
            tmp-=(a[i-2]+a[i-1]);
            tmp+=(a[i+k*2]+a[i+k*2-1]);
            if(ans<tmp)ans=tmp;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd
#define bod 100000007
/****************************/
using namespace std;
int n;
pii a[100010];
int main()
{
	cin>>n;
	rep(i,n)
	{
		int x;
		cin>>x;
		a[i]=make_pair(x,i);
	}
	sort(a,a+n);
	int ans=0;
	rep(i,n)
	{
		if(a[i].nd%2!=i%2)
		{
			ans++;
		}
	}
	cout<<ans/2;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),res=0;
    double[] a=new double[n];
    double ave=0,sum=0,min=Double.MAX_VALUE;
    for(int i=0;i<n;i++) {
    	a[i]=sc.nextDouble();
    	sum+=a[i];
    }
    ave=sum/n;
    for(int i=0;i<n;i++) {
    	if(min>Math.abs(a[i]-ave)) {
    		min=Math.abs(a[i]-ave);
    		res=i;
    	}
    }
    System.out.println(res);
  }
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int n;
vector<int> adj[2010];
int arr[2010];
int dist[2010],dist1[2010],num[2010];
int op;
int dfs(int u,int pa,int d){
    num[u] = arr[u];
    dist[u] = arr[u]*d;
    dist1[u] = 0;
    int sum = 0,maxi = 0;
    for (int i = 0; i < adj[u].size(); i++){
        int v = adj[u][i];
        if (v == pa) continue;
        int val = dfs(v,u,d+1);
        num[u] += num[v];
        dist[u] += dist[v];
        sum += val;
        maxi = max(maxi,val);
    }
    if (sum >= 2*maxi){
        sum %= 2;
    }
    else{
        sum = 2*maxi-sum;
    }
    dist1[u] += sum+num[u]*d;
    return sum + num[u];
    //cout << u << " " << cur.first << " "<< cur.second<< "\n";
}
int main(){
    cin >> n;
    int tot = 0;
    for (int i = 1; i <= n; i++){
        char x;
        cin >> x;
        arr[i] = x-48;
        tot += arr[i];
    }
    for (int i = 0; i < n-1; i++){
        int a,b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int ans = 1e9;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++) dist[j] = dist1[j] = num[j] = 0;
        int pos = 1;
        dfs(i,-1,0);
        for (int j = 1; j <= n; j++){
            if (i == j) continue;
            if (dist1[j] > dist[i]-dist[j]) pos = 0;
            //cout <<  dist1[j]<< " " << dist[i]-dist[j] << "\n";
        }
        //cout << pos << "hi\n";
        if (pos && dist[i]%2 == 0) ans = min(ans,dist[i]/2);
    }
    if (ans == 1e9) cout << "-1";
    else cout << ans;
}
/*
15
110100110111100
1 3
2 3
3 15
4 5
5 6
6 7
5 15
8 15
9 10
9 11
9 12
9 13
9 14
14 15
*/


Measured memory_bytes: 512
import copy
N=int(input())
A=[int(input()) for i in range(N)]
A_f=copy.deepcopy(A)
A_f.sort()
A_max=A_f[N-1]
A_sec=A_f[N-2]

for i in A:
    if i==A_max:
        print(A_sec)
    else:
        print(A_max)

Measured memory_bytes: 14568
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const ll mxn=2e5+1;
ll n,k;
vector<ll> graph[mxn];
ll fac[mxn],inv[mxn];
ll p(ll a,ll n)
{
  ll ans=1;
  while(n)
  {
    if(n&1)
      ans=(ans*a)%mod;
    a=(a*a)%mod;
    n=n>>1;
  }
return ans;
}
ll ncr(ll n,ll r)
{
  ll ans=fac[n];
  ans*=inv[r];
  ans%=mod;
  ans*=inv[n-r];
  ans%=mod;
 // cout<<fac[n]<<" "<<inv[r]<<" "<<inv[n-r]<<" ";
 // cout<<n<<" "<<r<<" "<<ans<<"\n";
  return ans;
}
ll dfs(ll u,ll lvl,ll p)
{
  ll child=0;
  for(auto v:graph[u])
  child+=(v!=p);
  ll temp=1;
  if(lvl==0)
  {
    if(child>k-1)
      return 0;
   temp=ncr(k,child+1);
   temp*=fac[child+1];
   temp%=mod;
   //  cout<<u<<" "<<temp<<"\n";
    for(auto v:graph[u])
    {
      if(p==v)
        continue;
      temp*=dfs(v,lvl+1,u);
      temp%=mod;
    }
  }
  else
  {
    if(child>k-2)
      return 0;
    temp=ncr(k-2,child);
    temp*=fac[child];
    temp%=mod;
  //    cout<<u<<" "<<temp<<"\n";
    for(auto v:graph[u])
    {
      if(p==v)
        continue;
      temp*=dfs(v,lvl+1,u);
      temp%=mod;
    }

  }

  return temp;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

  ll t=1;
//  cin>>t;
  ll tt=1;
  while(t--){
    ll i;
    fac[0]=1;
    fr(i,1,mxn)
    fac[i]=(fac[i-1]*i)%mod;
    fr(i,0,mxn)
    {
    	inv[i]=p(fac[i],mod-2);
    	//cout<<p(fac[i],mod-2)<<" ";
    }
      cin>>n>>k;
    fr(i,0,n-1)
    {
      ll u,v;
      cin>>u>>v;
      graph[u].pb(v);
      graph[v].pb(u);
    }
    cout<<dfs(1,0,1);
   // cout<<"Case #"<<tt<<": ";
   // tt++;
    }
  return 0;
}



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

//map<long long , int> pa;

int main()
{
  int ans,A,H;
  cin>>H>>A;
  ans=0;
  
  while(H>0)
  {
    H-=A;
    ans++;
  }
  cout<<ans;  
}

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

int main()
{
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; ++i) {
      double x1, y1, x2, y2, x3, y3, x4, y4, g1, g2;
      cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;

      if ((x1-x2)*(y3-y4) == (x3-x4)*(y1-y2))
	cout << "YES" << endl;
      else
	cout << "NO" << endl;
    }
  }
  return 0;
}

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

pair<map<ll, ll>, set<ll>> prime_factor(ll n){
    map<ll, ll> res;
    set<ll> primes;
    for(ll i = 2; i*i <= n; ++i) {
        if(n%i==0) primes.insert(i);

        while(n%i == 0){
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) {
        res[n] = 1;
        primes.insert(n);
    }
    return make_pair(res, primes);
}

const ll MOD = 1000000007;

ll mod_add(ll a, ll b){
    return ((a % MOD) + (b % MOD)) % MOD;
}
 
ll mod_mul(ll a, ll b){
    return ((a % MOD) * (b % MOD)) % MOD;
}

ll mod_pow(ll x, ll r){
    if (r == 0) return 1;

    else if (r == 1) return x % MOD;

    else if (r % 2 == 0){
        ll t = mod_pow(x, r/2) % MOD;
        return mod_mul(t, t);
    }

    else{
        ll t = mod_pow(x, r/2) % MOD;
        ll k = mod_mul(t, t);
        return (k % MOD) * (x % MOD);
    }
}

ll mod_div(ll a, ll b){
    return mod_mul(a, mod_pow(b, MOD - 2));
}

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

    int n;
    cin >> n;

    vector<ll> a(n);
    set<ll> primes;
    map<ll, ll> pf_lcm;

    rep(i, n){
        cin >> a[i];
        pair<map<ll, ll>, set<ll>> pf_pr = prime_factor(a[i]);
        map<ll, ll> pf = pf_pr.first;
        set<ll> pr = pf_pr.second;

        for(ll prime: pr){
            pf_lcm[prime] = max(pf_lcm[prime], pf[prime]);
            primes.insert(prime);
        }
    }

    ll LCM = 1;
    for(ll prime: primes){
        LCM = mod_mul(LCM, mod_pow(prime, pf_lcm[prime]));
    }
    ll res = 0;
    rep(i, n){
        res = mod_add(res, mod_div(LCM, a[i]));
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 1408
from math import ceil
def solve():
    N, A, B = map(int, input().split())
    H = [int(input()) for _ in range(N)]
    top = max(H)
    total = sum(H)
    bottom = 0
    mid = (top+bottom)//2
    while bottom+1<top:
        cnt = 0
        for i in range(N):
            cnt += max(ceil((H[i]-B*mid)/(A-B)),0)
        if cnt>mid:
            bottom = mid
        else:
            top = mid
        mid = (top+bottom)//2
    ans = top
    return ans
print(solve())

Measured memory_bytes: 81012
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){	
	string s;
	cin>>s;
	if(s[0]!='A'){
		cout<<"WA"<<endl;
		return 0;
	}
	int cnt=0;
    bool ok = 0;
    //int cnt = 0;
    for(int i=2;i<=s.size()-2;i++){
        if(s[i]=='C'){
            ok = 1;
            cnt++;
        }
    }
    if(cnt>1){
        cout<<"WA"<<endl;
        return 0;
    }
    int cnt2=0;
    for(int i=0;i<s.size();i++){
        if(s[i]>='a' && s[i]<='z') cnt2++;
    }
    if(cnt2==s.size()-2 && ok) cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=0
b=0
c=0
d=0
for i in range(n):
  S=input()
  for i in range(len(S)-1):
    if S[i]=="A" and S[i+1]=="B":
      c=c+1
  if S[0]=="B":
    b=b+1
  if S[-1]=="A":
    a=a+1
  if S[0]=="B" and S[-1]=="A":
    d=d+1
if a==b and b==d and a!=0:
  print(c+min(a,b)-1)
else:
  print(c+min(a,b))

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

const int mex = 1e5 + 5;

bool vis[mex];
vector <int> adj[mex];
map <pair <int , int>, int > dis;
int col[mex];

void dfs(int root){
    vis[root] = true;
    
    for(auto i : adj[root]){
        if(!vis[i]){
            if(dis[{root,i}]%2){
                col[i] = col[root]^1;
            }
            else{
                col[i] = col[root];
            }
            dfs(i);
        }
    }
}

int main(){
    int n, x, y, z;
    cin >> n;
    
    for(int i = 1; i < n; i++){
        cin >> x >> y >> z;
        adj[x].push_back(y);
        adj[y].push_back(x);
        dis[{x,y}] = z;
        dis[{y,x}] = z;
    }
    
    dfs(1);
    
    for(int i = 1; i <= n; i++){
        cout << col[i] << '\n';
    }
}

Measured memory_bytes: 23168
var output;
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//1:数値へ変換 2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字に分割 7:1文字に分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
  var one = myconv(next(),4);
  var H = one[0];
  var N = one[1];
  var list = new Array(N);
  var hplist = new Array(H+1);
  for(var i = 0; i < N ; i++){
    var tmp = myconv(next(),4);
    var tmp2 = {};
    tmp2["a"] = tmp[0];
    tmp2["b"] = tmp[1];
    list[i] = tmp2;
  }
  hplist[0] = 0;
  for(var i = 0; i <= H+1; i++){
    if(hplist[i] != null){
       for(var j = 0; j < N; j++){
         if(hplist[i+list[j]["a"]] == null){
            hplist[i+list[j]["a"]] = hplist[i] + list[j]["b"];
         }else{
            hplist[i+list[j]["a"]] = Math.min(hplist[i+list[j]["a"]], hplist[i] + list[j]["b"]);
         }
       }
    }
  }
  var min = hplist[hplist.length - 1];//どこかで右端より小さいのがあるはず？
  for(var i = hplist.length - 1; i >= 0; i--){
    if(hplist[i] != null){
       if(hplist[i] >= min){
          hplist[i] = min; 
       }else{
          min = hplist[i];
       }
    }else{
       hplist[i] = min;
    }
  }
  myout(hplist[H]);
}

Measured memory_bytes: 7856
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;

// int MOD = 998244353;
int MOD = 1000000007;


signed main(){
	
	ll n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> b(n);
	vector<ll> c(n);

	rep(i,n)cin >> a[i];
	rep(i,n)cin >> b[i];

	int cnt[30] = {0};
	ll mask = 0;
	rep(bit,29){
		mask = (mask<<1)+1;
		rep(i,n)c[i] = b[i]&mask;
		SORT(c);
		rep(ai,n){
			ll fa = a[ai]&mask;
			ll x = 1LL<<bit;
			auto r1 = lower_bound(c.begin(),c.end(),x-fa);
			auto r2 = lower_bound(c.begin(),c.end(),2*x-fa);
			auto r3 = lower_bound(c.begin(),c.end(),x+2*x-fa);
			auto r4 = lower_bound(c.begin(),c.end(),4*x-fa);
			cnt[bit] += (ll)(r2-r1) + (ll)(r4-r3); 
		}
	}

	ll ans = 0;
	rep(i,29){
		ans += (1LL<<i)*(cnt[i]%2);
	}

	cout << ans << endl;


	return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf16-exhibition-final-open.contest.atcoder.jp/tasks/cf16_exhibition_final_a
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://arc092.contest.atcoder.jp/tasks/arc092_b

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

const int mod = 1e9+7;
const int inf = (1<<28);
const ll infl = (1LL<<60);

struct segtree {
  int N;
  vector<int> dat;
  
  segtree(int n) {
    N = 1;
    while(N < n) N *= 2;
    dat.assign(2*N-1, 0);
  }
  // update k-th element
  void update(int k, int a) {
    k += N-1; // leaf
    dat[k] = a;
    while(k > 0) {
      k = (k - 1) / 2;
      dat[k] = max(dat[k*2+1], dat[k*2+2]);
    }
  }
  // max [a, b)
  int query(int a, int b) { return query(a, b, 0, 0, N); }
  int query(int a, int b, int k, int l, int r) {
    if(r <= a or b <= l) return 0;
    if(a <= l and r <= b) return dat[k];
    int m = (l + r) / 2;
    return max(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
  }
};

struct STs {
  vector<segtree> st;

  STs(int n, string s): st(26, segtree(n)) {
    rep(i,n) {
      st[s[i]-'a'].update(i, 1);
    }
  }

  void change(int k, char old, char cur) {
    st[old-'a'].update(k, 0);
    st[cur-'a'].update(k, 1);
  }

  int query(int l, int r) {
    int res = 0;
    rep(i,26) res += st[i].query(l, r+1);
    return res;
  }
};

int main() {
  int n, q;
  string s;
  cin >> n >> s >> q;

  STs segforest(n,s);
  rep(i,q) {
    int type; cin >> type;
    if (type == 1) {
      int k;
      char c;
      cin >> k >> c; k--;
      segforest.change(k,s[k],c);
      s[k] = c;
    }
    if (type == 2) {
      int l, r;
      cin >> l >> r; l--; r--;
      cout << segforest.query(l,r) << endl;
    }
  }
  return 0;
}


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

int main() {
	int A, B;
	cin >> A >> B;
	if ( A > B ) {
		cout << 2*A - 1 << endl;
	}
		else if ( A < B ) {
			cout << 2*B - 1 << endl;
		}
		
		else if ( A = B ) {
			cout << 2*A << endl;
		}
		
	return 0;
}

Measured memory_bytes: 888
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
const int N=1505;
int S[N],n,u[N][N],l[N][N],r[N][N];
char A[N][N];
int main(){
	scanf("%d",&n);
	for (register int i=1;i<=n;i++)scanf("%s",A[i]+1);
	for (register int i=0;i<=n;i++)
		for (register int j=0;j<=n;j++)u[i][j]=A[i][j]>='0'&&A[i][j]<='9'?min(i,min(u[i-1][j],u[i][j-1])):1<<30;
	long long ans=0;
	for (register int x=1;x<=n;x++){
		for (register int i=x;i;i--){
			for (register int j=1;j<=n;j++)S[j]=S[j-1]+(u[x][j]<=i?A[x][j]-'0':0);
			for (register int j=n+1;j;j--){
				if (A[i][j]>='0'&&A[i][j]<='9'){
					if (i<x){
						l[i][j]=min(l[i][j+1],l[i+1][j]);
						r[i][j]=max(r[i][j+1],r[i+1][j]);
					}
					else l[i][j]=min(j,l[i][j+1]),r[i][j]=max(j,r[i][j+1]);
				}
				else l[i][j]=1e9,r[i][j]=-1;
				if (l[i][j]<=r[i][j])ans+=(A[i][j]-'0')*(S[r[i][j]]-S[l[i][j]-1]-(i==x?A[i][j]-'0':0));
			}
		}
	}
	printf("%lld\n",ans);
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 105;
int n, ans;
ii a[N], b[N];
bool visited[N];

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i].first >> b[i].second;
    }
    sort(a, a + n);
    sort(b, b + n);

    for (int i = 0; i < n; ++i) {
        auto [x2, y2] = b[i];
        int mx_h = -1;
        int idx = -1;
        for (int j = 0; j < n; ++j) {
            if (visited[j]) continue;
            auto [x1, y1] = a[j];
            if (x1 >= x2)
                break;
            if (y2 > y1 && y1 > mx_h) {
                mx_h = y1;
                idx = j;
            }
        }
        if (idx != -1) {
            visited[idx] = true;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
import math

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

def get_distance(x1, y1, x2, y2):
    dist = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
    return dist

dist_sum = 0

for i in range(n):
  for j in range(i+1,n):
    dist_sum += get_distance(d[i][0],d[i][1],d[j][0],d[j][1])

print(dist_sum * 2 / n)

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N){
    bool ret = false;
    for(int i=1; i<10; ++i){
        if(N%i==0 && N/i<10) { ret = true; }
    }
    if(ret)
    cout << "Yes" << endl;
    else
    cout << "No" << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main() {
	double N, K;
	cin >> N >> K;
  	vector<double> p(N);
  	for (int i = 0; i < N; i++) cin >> p.at(i);

  	vector<double> pi(N+1, 0);
  	for (int i = 0; i < N; i++){
      pi.at(i+1) = pi.at(i) + (p.at(i)+1)/2;
    }
  
  	double res = -1;
    for (int i = 0; i <= N-K; ++i) {
      double val = pi.at(K+i) - pi.at(i);
      if (res < val) res = val;
    }
  cout << fixed << setprecision(6);
  cout << res << endl;
}

Measured memory_bytes: 3328
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    if(n <= 999){
        cout << "ABC" << endl;
        return 0;
    }
    cout << "ABD" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
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;}
//	std::cout<<std::fixed<<std::setprecision(10);


void dfs(int h, int w, const vector<vector<char>> &field, vector<vector<int>> &mp) {
	int H = field.size();
	int W = field[0].size();
	// 四方向を探索
	for(int i; i<4; i++) {

		int dh = 0;
		int dw = 0;

		if(i==0) dw = -1;
		else if(i==1) dw = 1;
		else if(i==2) dh = -1;
		else if(i==3) dh = 1;

		int nh = h + dh;
		int nw = w + dw;

		// 場外アウトしたり、0 だったりはスルー
		if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;

		if(field[nh][nw]=='.') {
			if(mp[nh][nw] > mp[h][w]+1 || mp[nh][nw]==-1) {
				mp[nh][nw] = mp[h][w] + 1;
				//cout << "hoge" << endl;
				dfs(nh, nw, field, mp);
			}
		}
	}
	
}

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> field(H, vector<char>(W));

	rep(i, H) {
		rep(j, W) {
			cin >> field[i][j];
		}
	}

	int ans = 0;

	rep(p, H) {
		rep(q, W) {
			vector<vector<int>> f_mp(H, vector<int>(W, -1));

      if(field[p][q]=='#') continue;
			f_mp[p][q] = 0; // start;
			dfs(p, q, field, f_mp);

			//int max_h = 0, max_w = 0;
			int max_mp = 0;

			rep(i, H) {
				rep(j, W) {
					if(max_mp<f_mp[i][j]) {
						max_mp = f_mp[i][j];
						// max_h = i;
						// max_w = j;
					}
				}
			}

			if(max_mp > ans) ans = max_mp;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
    int n, *v, *c, ans;

    cin >> n;
    v = new int[n];
    c = new int[n];

    for(int i = 0;i < n;i++)    cin >> v[i];
    for(int i = 0;i < n;i++)    cin >> c[i];

    ans = 0;
    for(int i = 0;i < n;i++){
        if(v[i] > c[i])     ans += v[i] - c[i];
    }

    cout << ans << endl;

    delete[] v;
    delete[] c;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int in()
{
	int x=0,f=1;char c=getchar();
	while(c=='-'){f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
int a[200010];
vector<int> b;
int main()
{
	int N=in(),K=in(),t,cnt=0,ans=0;
	while(N--)a[in()]++;
	for(int i=0;i<=200000;i++)if(a[i])b.push_back(a[i]),cnt++;
	sort(b.begin(),b.end());
	cnt-=K;
	for(int i=0;i<cnt;i++)ans+=b[i];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define sd(a) scanf("%lld",&a)
#define int long long
using namespace std;
main(){
    int n;
    cin>>n;
    int ans=1;
    for(int i=2;i<=n;++i){
        int now=i*i;
        while(now<=n){
            ans=max(ans,now);
            now*=i;

        }

    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const int MAX = 510000;
const int MOD = 1000000007;
ll mod                = 1e9+7;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {// テーブルを作る前処理
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

long long COM(int n, int k){ // 二項係数:nCk計算
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
const double PI=acos(-1);
int main(){
	int n;
	ll ans=0LL;
	cin >>n;
	COMinit();
	Vi a(n+1);
	cin >> a;
	map<int, int> dis;
	int left=0, right=0;
	rep(i, n+1) { 
		dis[a[i]] += 0; 
		if(dis[a[i]]!=0){
			left = dis[a[i]]-1;
			right = i ;
		}else{
			dis[a[i]] = i+1;
		}
	}
	clog << left <<" "<< right << endl;
	cout << n << endl;

	for (int i = 1; i < n ; i++) {
		ans = COM(n+1, i + 1) - COM(left + n - right, i);
		ans %= mod;
		ans += mod;

		ans %= mod;

		cout << ans << endl;
	}
	cout<<1<<endl;
}
/*
1 2 1 3

4- 1
6 - 1
4 - 0
1 - 0

1 4 2 3 4 5
6- 1
15 - 1-1
20 
15 - 

33 -1
33*32/2 -1 -2 =525
33*32*31/6 - 3=5453
*/

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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;

template<class T,class U>
using umap = unordered_map<T,U>;

template<class T>
using uset = unordered_set<T>;

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

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


int main(){
  int n;cin >> n;
  string s;cin >> s;
  if(n < 3200) cout << "red\n";
  else cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include <string>
#include<math.h>
typedef long long int ll;
using namespace std;

int f[110][10];
int p[110][11];
int main(){
	int n; cin >>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			cin >> f[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<11;j++){
			cin >> p[i][j];
		}
	}
	ll ans=-1e9;
	for(int i=1;i<(1<<10);i++){
		ll sum=0;
		for(int j=0;j<n;j++){
			int cnt=0;
			for(int k=0;k<10;k++){
				if((i>>k)&1 &&f[j][k]==1){
					cnt++;
				}
			}
			sum+=p[j][cnt];
		}
		ans=max(ans,sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
 {
 	int k,a,b,i,f=0;
 	cin>>k>>a>>b;
 	for(i=a;i<=b;i++)
 		{
 			if(i%k==0)
 			{
			 cout<<"OK"<<endl;
			 break;
 			}
 			else 
 				f++;
		 }
	if(f==(b-a+1))
		cout<<"NG"<<endl;
 	return 0;
}
 	
 					

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (const string& e_) { return "\"" + e_ + "\""; }
string to_string (char e_) { return "\'" + string(1, e_) + "\'"; }
string to_string (bool e_) { return e_ ? "true" : "false"; }
template <typename T> string to_string (T e_) {
	string s_ = "[ ";
	for (const auto& x_ : e_) s_ += to_string(x_) + " ";
	return s_ + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e_) {
	return "(" + to_string(e_.first) + ", " + to_string(e_.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
bool prime[1000000];

void sieve(){
	memset(prime, 1, sizeof prime);
	for(int i = 2; i <= 1000000; i++){
		if(prime[i]){
			for(int j = 2 * i; j <= 1000000; j += i)
				prime[j] = false;
		}
	}
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int x;
	cin >> x;

	sieve();

	while(!prime[x]) x++;

	cout << x;
}

Measured memory_bytes: 1280
#include<iostream>
#include<cmath>
#include<iomanip>

#define PI 3.141592

using namespace std;

struct coordinate{
	double x;
	double y;
};

void kock(int n,struct coordinate left,struct coordinate right){
	if (n == 0) return;
	struct coordinate s,t,u;
	s.x = (left.x * 2 + right.x * 1)/3;
	s.y = (left.y * 2 + right.y * 1)/3;
	t.x = (left.x * 1 + right.x * 2)/3;
	t.y = (left.y * 1 + right.y * 2)/3;
	u.x = (t.x - s.x) * cos(PI/3) - (t.y - s.y) * sin(PI/3) + s.x;
	u.y = (t.x - s.x) * sin(PI/3) + (t.y - s.y) * cos(PI/3) + s.y;

	kock(n-1,left,s);
	cout << setprecision(10) << s.x << " " << setprecision(10) << s.y <<  endl;
	kock(n-1,s,u);
	cout << setprecision(10) << u.x << " " << setprecision(10) << u.y <<  endl;
	kock(n-1,u,t);
	cout << setprecision(10) << t.x << " " << setprecision(10) << t.y <<  endl;
	kock(n-1,t,right);
}

int main(){
	int n; cin >> n;
	struct coordinate p1,p2;
	p1.x = 0;
	p1.y = 0;
	p2.x = 100;
	p2.y = 0;
	cout << p1.x << " " << p1.y << endl;
	kock(n,p1,p2);
	cout << p2.x << " " << p2.y << endl;
return 0;
}

Measured memory_bytes: 3208
#include <vector>
#include <iostream>
using namespace std;
int main(void)
{
    long N;
    cin >> N;
    vector<long> data (N, 0);
    vector<long> c (N+1, 0);

    for (int i = 0; i < N; i++)
      cin >> data [i];

    long count = 0;
    
    for (long j = 0; j < N; j++)
      	c[data[j]-1]++;

    for (long i = 0; i < N; i++)
       count += c[i] * (c[i] - 1) / 2;

    for (long k = 0; k < N; k++)
		cout << (count - c[data[k]-1] +1) << endl;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int n;
	cin >> n;
	string s1 = to_string(n);
	string s2 = to_string(n);
	reverse(s2.begin(), s2.begin());
	for (int i = 0; i < 3; i++) {
		if (s1[i] != s2[2 - i]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 256
def solve():
    s = input()
    t = input()
    ls = len(s)
    lt = len(t)
    for i in range(ls - lt + 1)[::-1]:
        if all([si == ti or si == "?" for si, ti in zip(s[i:i + lt], t)]):
            return (s[:i] + t + s[i + lt:]).replace("?", "a")
    return "UNRESTORABLE"


def resolve():
    print(solve())


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3060
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.15f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;

	writeln(N^^3);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
n = gets.split.map(&:to_i)
cnt = 0
n.sort!
until n[1] == n[2]
  n[0] += 1
  n[1] += 1
  cnt += 1
end
while n[0] < n[1]
  n[0] += 2
  cnt += 1
end
cnt += 1 if n[0] > n[1]
p cnt


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

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	int s, n, m;
	cin >> s >> n >> m;
	vector<int> x(s);
	for (int i = 0; i < s; i++) {
		cin >> x[i];
	}
	vector<ll> t(n);
	for (int i = 0, ti, pi; i < n; i++) {
		cin >> ti >> pi;
		t[i] = ti - x[pi - 1];
	}
	sort(t.begin(), t.end());
	vector<ll> sum(n), ssum(n);
	for (int i = 0; i < n; i++) {
		sum[i] = t[n - 1] - t[i];
	}
	for (int i = n - 2; i >= 0; i--) {
		ssum[i] = ssum[i + 1] + sum[i];
	}
	vector<vector<ll>> dp(m, vector<ll>(n)), mo(m, vector<ll>(n));
	for (int i = 0; i < n; i++) {
		dp[0][i] = ssum[0] - ssum[i] - sum[i] * i;
	}
	for (int i = 1; i < m; i++) {
		for (int j = 0; j < n; j++) {
			dp[i][j] = dp[i - 1][j];
			for (int k = 0; k < j; k++) {
				dp[i][j] = min(dp[i][j], dp[i - 1][k] + (ssum[k + 1] - ssum[j] - sum[j] * (j - k - 1)));
			}
		}
	}
	cout << dp[m - 1][n - 1] << endl;
	return 0;
}

Measured memory_bytes: 32528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17

int main(){
    int x;cin>>x;
    if(x>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define intl long long int

vector<vector<intl> > dp(1e5+2,vector<intl>(3,-1));

intl fun(intl d,intl a,intl n,vector<vector<intl> >&ar){
    if(dp[d][a]!=-1){
        return dp[d][a];
    }
    intl x1=a+1;
    x1%=3;
    intl x2=a+2;
    x2%=3;
    if(d==n-1){
        dp[d][a]=ar[d][a];
        return dp[d][a];
    }
    dp[d+1][x1]=fun(d+1,x1,n,ar);
    dp[d+1][x2]=fun(d+1,x2,n,ar);
    dp[d][a]=max(dp[d+1][x1],dp[d+1][x2]);
    dp[d][a]+=ar[d][a];
    return dp[d][a];
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    intl i,j,n,k;
    cin>>n;
    vector<vector<intl> > ar(n,vector<intl>(3));
    for(i=0;i<n;i++){
        cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
    }
    intl x=fun(0,0,n,ar);
    intl y=fun(0,1,n,ar);
    intl z=fun(0,2,n,ar);
    cout<<max(x,max(y,z))<<"\n";
}

Measured memory_bytes: 21936
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int N; cin >> N;
  vector<int> a(N);
  vector<bool> vist(N);

  for (int i = 0; i < N; ++i) cin >> a[i], --a[i];

  int cnt = 0;
  int u = 0;
  while(u != 1) {
    if (vist[u]) {
      cout << -1 << endl;
      return 0;
    }

    vist[u] = true;
    u = a[u];
    ++cnt;
  }

  cout << cnt << endl;

  return 0;
}



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

int main()
{
  int n, k;
  string s;
  
  cin >> n >> s >> k;
  
  for (int i=0; i<n; i++) {
    if (s[i] != s[k-1])
    {
      s[i] = '*';
    }
    cout << s[i];
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int n; cin >>n;
  string s; cin >>s;
  for (int i=0; i<n; i++){
    if (i == s.size()) break;
    cout <<s[i];
  }
  if ((int)s.size() > n) cout <<"...";
  cout <<endl;
}


Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=350;
//ここまでテンプレ
int main(){
	int N,K;
	cin>>N>>K;
	if(N%K==0)
		cout<<0<<endl;
	else
		cout<<1<<endl;
	return 0;
}

Measured memory_bytes: 256
def cardFight(taro, hanako):
    if taro < hanako:
        return 0, 3
    elif taro == hanako:
        return 1, 1
    else:
        return 3, 0

if __name__ == '__main__':
    taroP, hanakoP = 0, 0
    m = int(input())
    for i in range(m):
        t, h = input().split()
        tP, hP = cardFight(t, h)
        taroP += tP
        hanakoP += hP
    print(taroP, hanakoP)



Measured memory_bytes: 5600
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

X,Y,Z = inpl()
X -= Z
print(X//(Y+Z))


Measured memory_bytes: 4332
#include <stdio.h>

int n;
int wall[100];
int cnt[101];

int delete(int now) {
	int len;

	wall[now] = 0;

	len = 1;
	if (wall[(now + 1) % n])
		len += delete((now + 1) % n);
	if (wall[(now - 1 + n) % n])
		len += delete((now - 1 + n) % n);

	return len;
}

int main(void) {
	int i;
	int m;

	scanf("%d %d", &n, &m);

	while (m--) {
		int a, l;

		scanf("%d %d", &a, &l);

		for (i = 0; i < l; i++)
			wall[(a + i) % n] = 1;
	}

	for (i = 0; i < n; i++)
		if (wall[i]) {
			cnt[delete(i)]++;
		}

	for (i = 100; i >= 1; i--)
		if (cnt[i])
			printf("%d %d\n", i, cnt[i]);

	return 0;
}


Measured memory_bytes: 600
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	long long n,p[1000001];
	scanf("%d",&n);
	for(int i=0;i<2*n;i++)
		scanf("%d",&p[i]);
	sort(p,p+n*2);
	double ans=0;
	for(int i=0;i<2*n;i++)
		ans+=(p[i]*i)/(double)(n*2-1);
	printf("%.10lf\n",ans);
	return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,int>;
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; }

signed main(){
  int n,m;
  cin >> n >> m;
  vint H(n);
  rep(i,0,n) cin >> H[i];
  vvint to(n);
  rep(i,0,m){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  int ans = 0;
  rep(i,0,n){
    bool judge = true;
    for(auto p:to[i]){
      if(H[i] <= H[p]) judge = false;
    }
    if(judge) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 9860
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long

int main()
{

    long long a;
    while(~scanf("%lld",&a))
    {
         long long min1 = 1000000000009;

        for(int i=1;i<=sqrt(a);i++)
        {

            if(a%i==0)
            {

                if((a/i-1)+(i-1)<min1)
                    {min1 = (a/i-1)+(i-1);

                    }
            }
        }
        printf("%lld\n",min1);

    }
}


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

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
	string s;
	cin >> s;

	cout << s.substr(0, 4) << ' ' << s.substr(4) << endl;

    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
Asort = sorted(A)[:: -1]
L = [0] * N  # 左からi番目までのgcdをメモった配列
R = [0] * N  # 右からi番目までのgcdをメモった配列
L[0] = A[0]
R[0] = A[N - 1]
for i in range(1, N):
	L[i] = gcd(L[i - 1], A[i])
	R[i] = gcd(R[i - 1], A[N - 1 - i])
ans = max(L[N - 2], R[N - 2])
for j in range(1, N - 1):
    ans = max(ans, gcd(L[j - 1], R[N - j - 2]))
    
print(ans)


Measured memory_bytes: 16124
// 1_2_B

#include <iostream>
using namespace std;

int main(){
  int a, b, c;
  cin >> a; cin >> b; cin >> c;

  if(a < b && b < c){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3056
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int N, D, X; cin >> N >> D >> X;
    vector<int> A(N);
    for(int &a:A) cin >> a;
    
    int ans = 0;
    for(int i=0; i<N; i++)
        ans += (D-1)/A[i] + 1;
    
    cout << ans + X << endl;

    return 0;
}


Measured memory_bytes: 256