akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(void){
  int n;
  cin >> n;
  
  bool exist = false;
  
  for(int i=1;i<=n;i++){
    if(i * 108 / 100 == n){
        cout << i << endl;
        exist = true;
    }
  }
  
  if(!exist) cout << ":(" << endl;
  
  return 0;
}


Measured memory_bytes: 256
import sys
import itertools

ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

N = ni()
A = nl()
assert len(A) == (N + 1)


def solve():
    ar = list(itertools.accumulate(A[::-1], initial=0))
    ar.reverse()
    assert len(ar) == (N + 2)
    if N == 0:
        return 1 if A[0] == 1 else -1
    if A[0] != 0:
        return -1
    inn = ans = 1
    for i in range(1, N + 1):
        b = 2 * inn - A[i]
        if b < 0:
            return -1
        inn = min(b, ar[i + 1])
        ans += inn + A[i]
    return ans


print(solve())


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

typedef long long int ll;

int main()
{
    ll n, maxa = 0, ans = 0, tb;
    cin >> n;
    for(ll i = 0;i < n;i++){
        ll a, b;
        cin >> a >> b;
        if(maxa < a){
            maxa = a;
            tb = b;
        }
    }

    ans = maxa + tb;
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    E=[[] for _ in range(n)]
    for _ in range(n-1):
        a,b=map(int,input().split())
        a-=1; b-=1;
        E[a].append(b)
        E[b].append(a)

    dp=[1]*n
    dp[0]=k
    def dfs(v,p)->None:
        if(p!=-1):
            count=0
            for nv in E[v]:
                if(nv==p): continue
                dp[nv]=k-2-count
                count+=1
                dfs(nv,v)
        else:
            count=0
            for nv in E[v]:
                dp[nv]=k-1-count
                count+=1
                dfs(nv,v)

    dfs(0,-1)
    ans=1
    for i in range(n):
        ans*=dp[i]
        ans%=MOD
    print(ans)
resolve()

Measured memory_bytes: 102220
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>

#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;



int M,N;

int P[10000+10];
int C[500+10];
int E[500+10];
int Pt[10000+10];

int dp[500+10][10000+10];

int main() {

	cin >> M >> N;
	rep(i, M){
		cin >> P[i];
	}
	rep(i, N){
		cin >> C[i] >> E[i];
	}
	sort(P, P + M, greater<int>());

	for(int i=1; i <= M;i++){
		Pt[i] = Pt[i-1] + P[i - 1];
	}
	for(int i = 0; i<= N; i++){
		for(int j=0;j<=M;j++){
			dp[i][j]=-inf;
		}
	}
	dp[0][0] = 0;

	for(int i = 1; i<= N; i++){
		for(int j=0;j<=M;j++){
			dp[i][j] = max(dp[i - 1][j] , dp[i][j]);
			if(j - C[i - 1] > 0){
				dp[i][j] = max(dp[i - 1][j - C[i - 1]] + Pt[j] - Pt[j - C[i - 1]] - E[i - 1], dp[i][j]);
			}else{
				dp[i][j] = max(dp[i - 1][0] + Pt[j] - E[i - 1], dp[i][j]);
			}
			if(dp[i][j] < 0)
				dp[i][j] = -inf;
		}
	}

	cout << *max_element(dp[N], dp[N] + M + 1) << endl;






}

Measured memory_bytes: 20856
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define nl "\n"
typedef long long ll;
using namespace std;

int main()
{
    io;

    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    ll t,ans;
    double mod;
    cin >> t;

    if(t %1000 == 0)
        cout << "0" << nl;
    else if(t<1000)
    {
        ans = 1000-t ;
        cout << ans << nl;
    }
    else if (t >1000)
    {
        mod = t/1000.0;
        ans = round(mod)* 1000 - t;

        if(ans<0)
            cout << ans + 1000 << nl;
        else
            cout << ans << nl;

    }
    return 0;
}


Measured memory_bytes: 3688
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  ((a*b)>=(c*d)) ? cout<<a*b: cout<<c*d;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

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

int x,y,z,t1,t2,t3;

int main()
{
	FAST;

	int x;
	cin >> x;
	if (x==3||x==5||x==7) cout <<"YES\n";
	else cout << "NO\n";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int N,M;
int a[1000001];
long long runsum[1000001],c;
int b[300000];
main()
{
  int i,p,ret;
   
  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
      scanf("%d",&p);
      a[p]++;
    }
  for(i=1;i<=1000000;i++)
    runsum[i] = runsum[i-1]+i*a[i];
  
  scanf("%d",&M);
  for(i=0;i<M;i++)
    scanf("%d",&b[i]);
  for(i=ret=0;i<M;i++)
    {
      scanf("%lld",&c);
      //printf("%lld %lld|",c,runsum[b[i]]);
      if(c<=runsum[b[i]])
    printf("Yes\n");
      else
    printf("No\n");
    }
  return(0);
}

Measured memory_bytes: 13900
// Problem : A - Hitachi String
// Contest : AtCoder - Social Infrastructure Information Systems Division, Hitachi Programming Contest 2020
// URL : https://atcoder.jp/contests/hitachi2020/tasks/hitachi2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long

void solve(){
    string s;
    cin>>s;
    for(int i=0;i<sz(s);i+=2){
        string tmp = s.substr(i,2);
        if(tmp != "hi"){
            cout<<"No\n";
            return;
        }
    }
    cout<<"Yes\n";
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int t;
    //cin>>t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import Foundation
//最大公約数を求める関数
func gcd(_ num1: Int, _ num2: Int) -> Int {
   let r = num1 % num2
   if r != 0 {
       return gcd(num2, r)
   } else {
       return num2
   }
}
//３つ以上の数の最大公約数を求める
func gcdArr(_ numArr: [Int]) -> Int {
    var ans: Int = numArr[0]
    for i in numArr {
        ans = gcd(ans, i)
    }
    return ans
}

//最小公倍数を求める関数
func lcm(_ num1: Int, _ num2: Int) -> Int {
    
    var gcdNum = gcd(num1, num2)
    return num1*num2/gcdNum
}

//３つ以上の最大公約数を求める
func lcmArr(_ numArr: [Int]) -> Int {
    var ans: Int = 1
    for i in numArr {
        ans = lcm(ans, i)
    }
    return ans
}

//一次不定方程式 ax+by=gcd(a,b)を満たすa,b
func solveIdentifyEquasion(_ a: Int,_ b: Int) -> [Int]{
    var (d,d_): (Int,Int) = (a,b)
    var (x,x_) = (1,0)
    var (y,y_) = (0,1)
    var q: Int
    
    while d_ != 0 {
        q = d/d_
        (d,d_) = (d_,d%d_)
        (x,x_) = (x_,x-q*x_)
        (y,y_) = (y_,y-q*y_)
    }
    return [x,y]
}


func solveIdentifyEquasion2(_ a: Int,_ b: Int, _ c: Int) -> [Int]{
    return (solveIdentifyEquasion(a, b).map({$0 * c/gcd(a, b)}))
}

let rl = readLine()!.split(separator: " ").map({Int($0)!})
if rl[2].isMultiple(of: gcd(rl[0], rl[1])) {
    print("YES")
} else {
    print("NO")
}

Measured memory_bytes: 13484
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

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

	int N;
	cin>>N;
	N=N%10;
	if(N==3){
		cout<<"bon"<<endl;
	}else if(N==0||N==1){
		cout<<"pon"<<endl;
	}else if(N==6||N==8){
		cout<<"pon"<<endl;
	}else{
		cout<<"hon"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3692
N = int(raw_input())
A = map(int,raw_input().split())
B = map(int,raw_input().split())
C = map(int,raw_input().split())
ans = 0

for i in range(0,N):
  ans = ans + B[A[i]-1]
  if i>0 and A[i-1]+1==A[i]:
    ans = ans + C[A[i-1]-1]

print ans


Measured memory_bytes: 2568
def gcd(a, b):
    while b:
        r = a % b
        a, b = b, r
    return a

A, B = list(map(int, input().split()))
n = gcd(A, B)

ans = 1
if not n % 2: ans += 1

while not n % 2:
    n //= 2

i = 3

while i <= n**0.5:
    if not n % i: ans += 1
    while not n % i:
        n //= i
    i += 2

if 1 < n: ans += 1
print(ans)

Measured memory_bytes: 3188
#!/usr/bin/env python

def solve():
    y500, y100, y50, n = [int(input()) for _ in [0]*4]

    ans = 0
    for i in range(y500+1):
        for j in range(y100+1):
            for k in range(y50+1):
                ans += [0,1][500*i+100*j+50*k==n]
    print(ans)

if __name__=="__main__":
    solve()

Measured memory_bytes: 3060
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    String info[] = new String[3];
    info = line.split(" ", 0);
    int n = Integer.parseInt(info[0]);
    int x = Integer.parseInt(info[1]);
    int t = Integer.parseInt(info[2]);
    
    if(n % x == 0){
		System.out.println(n / x * t);
    }else{
      	System.out.println((n / x + 1)* t);
    }
  }
}

Measured memory_bytes: 35596
#include <iostream>
#include <algorithm>
#define rep(i, a, n) for(int i = a;i < n;i++)
#define repe(i, a, n) for(int i = a;i <= n;i++)
#define repr(i, a, n) for(int i = a;i > n;i--)
using namespace std;


using llint = long long int;


llint n, m;


llint solve(){
	if(n == 1 && m == 1) return 1;
	if(n == 1) return m - n*2;
	if(n == 2) return 0;
	return n*m - (n*2 + (m-2)*2);
}


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

	cout << solve() << endl;

	return 0;
}

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

int main() {
  int n,k;
  cin>>n>>k;
  
  vector<int> mul(20,1);
  for(int i=0;i<20;++i){
    mul[i+1] = mul[i] * 2;
  }
  
  long double ans = 0.0;
  for(int i=0;i<n;++i){
    for(int j=0;j<20;++j){
      if((i+1) * mul[j] >= k) {
        ans += pow(0.5, (j));
        break;
      }
    }
  }
  ans *= 1.0/(double)(n);
  cout<<fixed<<setprecision(10)<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
import numpy as np

H, W, K = map(int, input().split())
cells = np.zeros((H, W), dtype=np.int)

for i in range(H):
    tmp = input()
    for j in range(W):
        if tmp[j] == '#':
            cells[i][j] = 1

ans = 0

for mask_h in range(2**H):
    for mask_w in range(2**W):
        counter = 0
        for h in range(H):
            for w in range(W):
                if ((mask_h >> h) & 1) == 0 and ((mask_w >> w) & 1) == 0 and cells[h][w] == 1:
                    counter += 1

        if counter == K:
            ans += 1

print(ans)


Measured memory_bytes: 27136
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
const ll MOD = 1000000007;
using namespace std;

int main()
{
  int n, a;
  cin >> n >> a;
  string ans = (n % 500 <= a) ? "Yes" : "No";
  cout << ans << endl;
}


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

using namespace std;

int main(){

    int n;
    cin >> n;

    long long int a[n];
    for(int i=0;i<n;i++)cin >> a[i];

    long long int s[n],t[n];

    for(int i=0;i<n;i++){
        s[i]=i+a[i];
        t[i]=i-a[i];
    }

    sort(s,s+n);
    sort(t,t+n);

    long long int c=0;

    for(int i=0;i<n;i++){
        c += upper_bound(t,t+n,s[i])-lower_bound(t,t+n,s[i]);
    }

    cout << c << endl;

}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a) a.begin(),a.end()
using ll=long long;

int main(){
    int h,w;
    cin>>h>>w;
    int n;
    cin>>n;
    vector<int> a(n);
    vector<vector<int>> field(h,vector<int>(w,-1));
    for(int i=0;i<n;i++) cin>>a[i];
    int index=0;
    for(int i=0;i<h;i++){
        if(i%2==0){
            for(int j=0;j<w;j++){
                if(a[index]==0) index++;
                field[i][j]=index+1;
                a[index]--;
            }
        }
        else{
            for(int j=w-1;j>=0;j--){
                if(a[index]==0) index++;
                field[i][j]=index+1;
                a[index]--;
            }
        }
    }
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<field[i][j];
            if(j!=w-1) cout<<" ";
            else cout<<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 384
/*
  行列の積n×mの行列Aとm×lの行列Bを入力し、
  それらの積であるn×lの行列Cを出力するプログラムを作成してください。)
  2018/02/12
*/

#include<stdio.h>
int main(void){
  int l,m,n;
  long int a[100][100];/*行列A*/
  long int b[100][100];/*行列B*/
  long long c[100][100];/*行列c*/
  int i,j,k;/*i行目、j列目、c(i,j)=∑[k=1 ->m]{a(i,k)*b(k,j)}*/

  scanf("%d %d %d",&n,&m,&l);
  
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%ld",&a[i][j]);
    }
  }

  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
      scanf("%ld",&b[i][j]);
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      c[i][j] = 0;
      for(k=0;k<m;k++){
	c[i][j] += a[i][k]*b[k][j];
      }
      if(j<l-1)
	printf("%lld ",c[i][j]);
      else
	printf("%lld\n",c[i][j]);
    }
  }
  return 0;
}


Measured memory_bytes: 2040
import java.util.*;
import java.math.*;

class Main{       
   public static void main(String[] args){

      Scanner sc = new Scanner(System.in);  
      
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      int D = sc.nextInt();
      
      if(D <= A || B<=C){
          System.out.println(0);
          return;
      }else if(C <= A && D <= B){
          System.out.println(D-A);
          return;
      }else if(C<=A &&  B<=D){
          System.out.println(B-A);
          return;
      }else if(A<=C && D<=B){
          System.out.println(D-C);
          return;
      }else if(A<=C && B<=D){
          System.out.println(B-C);
          return;
      }      
      
      
   }
}

Measured memory_bytes: 23636
use std::collections::*;
use std::io::*;
use std::*;
// template {{{
macro_rules! get {
    ($($t:tt),*; $n:expr) => {
        {
            let stdin = std::io::stdin();
            let ret = std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
                let line = line.unwrap();
                let mut it = line.split_whitespace();
                _get!(it; $($t),*)
            }).collect::<Vec<_>>();
            ret
        }
    };
    ($($t:tt),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut it = line.split_whitespace();
            _get!(it; $($t),*)
        }
    };
}
macro_rules! _get {
    ($it:ident; [char]) => {
        _get!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; [u8]) => {
        _get!($it; String).bytes().collect::<Vec<_>>()
    };
    ($it:ident; usize1) => {
        $it.next().unwrap().parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap().parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:tt),+) => {
        ($(_get!($it; $t)),*)
    };
}
// }}}

fn main() {
    let (mut a, mut b, mut c) = get!(i32, i32, i32);
    let k = get!(i32);
    let mut count = 0;
    while !(b > a) {
        b *= 2;
        count += 1;
    }
    while !(c > b) {
        c *= 2;
        count += 1;
    }
    println!("{}", if k >= count { "Yes" } else { "No" });
}


Measured memory_bytes: 2092
#include <iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	bool ans = false;
	for(int i=1; i<=9; i++){
		for(int j=1; j<=9; j++){
			if(i*j==n){
				ans = true;
				break;
			}
		}
		if(ans==true){
			break;
		}
	}

	if(ans){
		cout << "Yes" << "\n";
	}else{
		cout << "No" << "\n";
	}




}


Measured memory_bytes: 256
//
//AtCoder Beginner Contest 117
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<int> x(m);
    REP(i, m) {
        cin >> x[i];
    }
    sort(ALL(x));

    vector<int> dist(m-1);
    REP(i, m-1){
        dist[i] = x[i+1]-x[i];
    }
    sort(ALL(dist), greater<int>());

    int ans=0;
    FOR(i, n-1, m-2) ans+=dist[i];

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


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

int main()
{
    int a  = 0, b = 0;
    cin >> a >> b;
    vector<int> values;
    values.push_back(a + b);
    values.push_back(a - b);
    values.push_back(a * b);
    sort(values.begin(), values.end());
    cout << values[2] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define MOD 1000000007
#define itn int
#define enld endl
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
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;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s; cin >> s;
    string T = "CODEFESTIVAL2016";
    int ans = 0;
    rep(i,0,SZ(s)){
        if(s[i] != T[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#define MAX 2000

int slove(int,int,int*);

int main(){
    int m[MAX];
    int A[MAX];
    int q;
    int n;

    scanf("%d",&n);
    for(int i = 0;i < n;i++)scanf("%d",&A[i]);
    scanf("%d",&q);
    for(int i = 0;i < q;i++)scanf("%d",&m[i]);

    for(int i = 0;i < q;i ++){
        if(slove(n,m[i],A) == 1)printf("yes\n");
        else printf("no\n");
    }          

    return 0;
}

int slove(int n,int m,int *A){
    if(n == 0)return 0;
    if(m == A[0])return 1;
    if(m < A[0])return slove(n-1,m,A + 1);
    return slove(n - 1,m - A[0],A + 1) || slove(n-1, m, A + 1);
}


Measured memory_bytes: 2104
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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


    int N, X; cin >> N >> X;
    vi A(N); REP(i, N) cin >> A[i];
    
    ll ans = 0;
    FOR(i,1,N) {
        if (A[i-1]+A[i] > X) {
            int dif = A[i - 1] + A[i] - X;

            if (A[i] > dif) {
                A[i] -= dif;
            }
            else {
                A[i - 1] -= dif - A[i];
                A[i] = 0;
                
            }
            ans += dif;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B;
    cin >> A >> B;
  	if(A < 6){
    	cout << 0 << endl;
    } else if (A < 13) {
    	cout << B/2 << endl;
    } else {
    	cout << B << endl;
    }   
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
	final Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int[] heap=new int[n+1];
	for(int i=1;i<=n;i++) heap[i]=sc.nextInt();
	
	for(int i=1;i<=n;i++) {
		System.out.print("node "+i+": key = "+heap[i]+", ");
		if(parent(i)>=1) System.out.print("parent key = " +heap[parent(i)]+", ");
		if(left(i)<=n) System.out.print("left key = "+heap[left(i)]+", ");
		if(right(i)<=n) System.out.print("right key = "+ heap[right(i)]+", ");
		System.out.println("");
	}
	
	}
	
	private static int parent(int x){
		return x/2;
	}
	
	private static int left(int x){
		return 2*x;
	}
	
	private static int right(int x){
		return 2*x+1;
	}
	
}

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

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

int lcm(int a, int b) { return a * b / gcd(a, b); }

signed main() {
		int a,b;
		cin >> a >> b;
		if(b % a == 0)cout << a + b;
		else cout << b - a;
}



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

using namespace std;

int main()
{
	string s,t;
	cin >> s >> t;
	vector<vector<int> > dp(s.size()+1,vector<int>(t.size()+1,0));
		
	for(int i=0;i<s.size();i++)
		for(int j=0;j<t.size();j++)
		{
			if(s[i]==t[j])dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
			dp[i+1][j+1]=max(dp[i+1][j+1],max(dp[i+1][j],dp[i][j+1]));
		}

	string ans="";
	int i=s.size(),j=t.size();
	while(i>0 and j>0)
	{
		if(dp[i][j]==dp[i-1][j])
			i--;
		else if(dp[i][j]==dp[i][j-1])
			j--;
		else
		{
			ans=s[i-1]+ans;
			i--;j--;
		}
	}
	cout << ans << endl;

//	cout << dp[s.size()][t.size()] << endl;
}



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

int main(){
    int N, M;
    cin >> N >> M;
    ll INF = 1e18;
    vector<vector<pair<int, ll>>> edge(N+1);
    for (int i = 0; i < M; i++) {
        int u, v;
        ll s;
        cin >> u >> v >> s;
        edge[u].push_back({v, s});
        edge[v].push_back({u, s});
    }
    vector<ll> apt(N+1, INF), amt(N+1, INF);
    apt[1] = 0;
    queue<pair<int, int>> q;
    q.push({1, 1});
    while (!q.empty()) {
        int now = q.front().first;
        int sgn = q.front().second;
        q.pop();
        for (auto p : edge[now]) {
            int nxt = p.first;
            int d = p.second;
            if (sgn == 1) {
                if ((amt[nxt] < INF && amt[nxt] != d - apt[now]) || d-apt[now] <= 0) {
                    cout << 0 << endl;
                    return 0;
                }else{
                    if (amt[nxt] < INF) continue;
                    amt[nxt] = d-apt[now];
                    q.push({nxt, -1});
                }
            }
            if (sgn == -1) {
                if ((apt[nxt] < INF && apt[nxt] != d - amt[now])) {
                    cout << 0 << endl;
                    return 0;
                }else{
                    if (apt[nxt] < INF) continue;
                    apt[nxt] = d-amt[now];
                    q.push({nxt, 1});
                }
            }
        }
    }
    ll ansl = 1;
    ll ansu = INF;
    ll uniq=0;
    
    for (int i = 1; i <= N; i++) {
        if (apt[i] < INF) ansl = max(-apt[i]+1, ansl);
        if (amt[i] < INF) ansu = min(amt[i]-1, ansu);
        if (apt[i] < INF && amt[i] < INF) {
            ll g = amt[i]-apt[i];
            if (g <= 0 || g%2 || (uniq > 0 && g != uniq*2)) {
                cout << 0 << endl;
                return 0;
            }
            uniq = g/2;
        }
        //cout << ansl << ansu << uniq << endl;
    }
    if (uniq > 0 && ansl <= uniq && uniq <= ansu) cout << 1 << endl;
    else cout << max(ansu-ansl+1, 0LL) << endl;
    return 0;
}


Measured memory_bytes: 11264
s = input()

ans = [0]
cnt = 0
for i in s:
    if (i == "A" or i == "C" or i == "G" or i == "T"):
        cnt+=1
    else:
        if (cnt > 0):
            ans.append(cnt)
            cnt = 0
ans.append(cnt)
print(max(ans))


Measured memory_bytes: 2940
#include <iostream>
#include <queue>
#include <cstring>
#define P pair<int,int>
using namespace std;
int m[123][123];
int main()
{
  int n,t,x,y,c,i;
  P next[] = { P(1,0), P(-1,0), P(0,1), P(0,-1), P(1,1), P(-1,-1), };

  while(cin >> t >> n, (t || n)){
    memset(m,0,sizeof(m));
    for(x=0;x<123;x++) m[0][x] = -1;
    for(x=0;x<123;x++) m[122][x] = -1;
    for(y=0;y<123;y++) m[y][0] = -1;
    for(y=0;y<123;y++) m[y][122] = -1;
    while(n--){
      cin >> x >> y;
      m[y+61][x+61] = -1;
    }
    queue< P > q;
    cin >> x >> y;
    m[y+61][x+61] = 1;
    q.push( P(x+61,y+61) );
    c = 1;
    while(!q.empty()){
      P p = q.front(); q.pop();
      if(m[p.second][p.first] > t) continue;
      for(i=0;i<6;i++){
	if(m[p.second + next[i].second][p.first + next[i].first] == 0){
	  c++;
	  m[p.second + next[i].second][p.first + next[i].first]
	    = m[p.second][p.first] + 1;
	  q.push( P(p.first + next[i].first, p.second + next[i].second) );
	}
      }
    }
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 980
program main
  implicit none
  integer(8) :: n, m, i, j, cor, pna
  integer(8), allocatable :: p(:), w(:)
  character(2), allocatable :: s(:)

  read(*,*) n, m
  allocate(p(m))
  allocate(w(n))
  allocate(s(m))
  do i = 1, m
     read(*,*) p(i), s(i)
  end do

  cor = 0
  pna = 0
  w(:) = 0
  do j = 1, m
     if(s(j) == 'WA') then
        if(w(p(j)) /= -1) then
           w(p(j)) = w(p(j)) + 1
        end if
        
     else
        if(w(p(j)) /= -1) then
           cor = cor + 1
           pna = pna + w(p(j))
           w(p(j)) = -1
        end if
     
     end if

  end do
  
     
     
  write(*,*) cor, pna
end program main

        


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

int main()
{
    int n,m;
    cin >> n >> m;
    priority_queue<int> pq;
    int a;
    for(int i=0;i<n;++i){
        cin >> a;
        pq.push(a);
    }
    for(int i=0;i<m;++i){
        int t=pq.top();
        pq.pop();
        t/=2;
        pq.push(t);
    }
    long int sum=0;
    while(!pq.empty()){
        sum += pq.top();
        pq.pop();
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int n;

int main()
{
    string s;
    ll k;
    cin>>s>>k;
    int l=0;
    for(int i=0;i<s.size();i++)
    {
        ll t=s[i]-'0';
        ll tmp=k;
        ll cnt=0;
        if(t==1)
        {
            k--;
            if(k<=0)
            {
                cout<<1<<endl;
                return 0;
            }
            continue;
        }
        if(t!=1)
        {
            l=i;
            break;
        }
    }
    cout<<s[l]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;
using LL = long long;

LL n, a, b;
vector<LL>h;

LL ceil_m(LL P, LL Q)
{
	return (P - 1) / Q + 1;
}

//x回の爆発ですべてを倒せるか？
bool cond(LL x)
{
	LL count = 0;
	for (LL hh : h)
	{
		if (hh <= b * x)
		{
			continue;
		}
		count += ceil_m((hh - (b * x)), (a - b));
	}
	return count <= x;
}

int main(void)
{
	cin >> n >> a >> b;
	for (int i = 0; i < n; ++i)
	{
		LL hh;
		cin >> hh;
		h.push_back(hh);
	}
	sort(h.begin(), h.end());
	LL lo = 0, hi = 1e9;
	while (lo + 1 < hi)
	{
		LL mid = (lo + hi) / 2;
		if (cond(mid))
		{
			hi = mid;
		}
		else
		{
			lo = mid;
		}
	}
	cout << hi << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
using namespace std;
#define N 1000

int main(){
    char x[6];
    for (int i=0; i<6; i++){
        cin>>x[i];
    }
    if (x[2]==x[3] && x[4]==x[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int n;

int main(){
	cin >> n;
	for(int i = 111; i <= 999; i+=111){
		if(n <= i){
			cout << i << endl;
			break;
		}
	}
	
	return 0;
}

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

int read(){
    int x=0;bool f=0;char c=getchar();
    while(c<'0'||c>'9') f|=c=='-',c=getchar();
    while(c>='0'&&c<='9') x=x*10+(c^48),c=getchar();
    return f?-x:x;
}

#define MAXN 100000
int N,K;
char str[MAXN+5];

int main(){
    N=read(),K=read();
    scanf("%s",str+1);
    int cnt=0;
    for(int i=2;i<=N;i++)
        if(str[i]!=str[i-1])
            cnt++;
    int tot=N-cnt-1;
    printf("%d",tot+min(cnt,K*2));
}


Measured memory_bytes: 256
//
// !!!WARNING!!!
// AUTO SUBMITTION TEST ALERT
// !!!WARNING!!!
//

#include <stdio.h>

#define arr_print_d0dn(a, n) for(int i=0;i<(n);++i)printf(i==(n)-1?"%d\n":"%d ",(a)[i])

void insertionSort(int *A, const int N) {
    arr_print_d0dn(A, N);
    for(int i = 1; i < N; ++i) {
        int tmp = A[i];
        int j = i - 1;
        // rotate right to left
        while(j >= 0 && A[j] > tmp) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = tmp;
        arr_print_d0dn(A, N);
    }
}

int main() {
    int N;
    scanf("%d", &N);
    int A[N];
    for(int i = 0; i < N; ++i) {
        scanf("%d", A + i);
    }
    // solve
    insertionSort(A, N);

    return 0;
}



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

int main(){
int n,i;
cin>>n;
int w[n],k[n],ans=1000000;
cin>>w[0];
k[0]=w[0];
for(i=1;i<n;i++){cin>>w[i];k[i]=k[i-1]+w[i];}
for(i=1;i<n;i++){ans=min(ans,abs(k[n-1]-k[i-1]-(k[i-1])));}
cout<<ans;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B, C):
    ans = 0
    for i in range(N):
        ans += len(set([A[i], B[i], C[i]])) - 1
    return ans


def main():
    N = read_int()
    A = read_str()
    B = read_str()
    C = read_str()
    print(slv(N, A, B, C))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7740
var lines = require("fs").readFileSync("/dev/stdin","utf-8").split("\n");
var N = parseInt(lines[0]);
var A = lines[1].split(" ").map((item)=>parseInt(item));
var answer = 0;
for(var i=0;i<A.length;i++){
	for(var j=0;j<A.length;j++){
		var abs = Math.abs(A[i]-A[j]);
      	if(answer<abs) answer = abs;
    }
}
console.log(answer);

Measured memory_bytes: 7628
#include<bits/stdc++.h>
#define int long long int
#define fastscan ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define error(x) cout << #x <<": " << x <<"\n"
#define exit exit(0);

using namespace std;

const int N = 1e6;

int a[N];
int n,v;

int32_t main(){

    fastscan;

    int n,ans;

    cin >> n >> ans;
    
    while(--n){
        int x;
        cin >> x;
        ans = __gcd(ans, x);
    }

    cout << ans << "\n";

    return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  Graph G(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;  // 0-indexed
    G[a].push_back(b);
    G[b].push_back(a);
  }

  set<int> det;
  rep(i,G[0].size()) det.insert(G[0][i]);
  rep(i,G[n-1].size()) det.insert(G[n-1][i]);

  if (det.size() == G[0].size() + G[n-1].size()) cout << "IMPOSSIBLE\n";
  else cout << "POSSIBLE\n";
  return 0;
}


Measured memory_bytes: 21360
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,ans = 1,prev = -1;
	string s[2];
	cin >> n >> s[0] >> s[1];
	for(int i = 0;i < n;i++){
		if(s[0][i] == s[1][i]){
			if(prev == -1) ans = 3;
			else if(!prev) ans = ans * 2 % MOD;
			prev = 0;
		}else{
			if(prev == -1) ans = 6;
			else if(!prev) ans = ans * 2 % MOD;
			else ans = ans * 3 % MOD;
			prev = 1;
			i++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n,m,i,j,k,l;
    int a[30] = {};
    int b[30] = {};
    scanf("%d %d",&n ,&m);
    for(i=0;i<m;i++)a[i]=1;
    for(i=0;i<n;i++){
        scanf("%d", &k);
        for(j=0;j<m;j++)b[j]=0;
        for(j=0;j<k;j++){
            scanf("%d", &l);
            b[l-1] = 1;
        }
        for(j=0;j<m;j++)a[j]=(a[j]&&b[j]);
    }
    j=0;
    for(i=0;i<m;i++)if(a[i]==1)j++;
    printf("%d\n", j);
    return 0;
}

Measured memory_bytes: 128
def Warshall_Floyd(edges,N):
  for k in range(N):
    for i in range(N):
      for j in range(N):
        edges[i][j]=min(edges[i][j],edges[i][k]+edges[k][j])
  return edges



def main():
    h,w = map(int,input().split())
    ls = [[int(x) for x in input().split()] for _ in range(10)]
    a = [[int(x) for x in input().split()] for _ in range(h)]
    ls = Warshall_Floyd(ls,10)
    cost = []

    for i in range(10):
        cost.append(ls[i][1])
    ans = 0
    for i in range(h):
        for j in range(w):
            if a[i][j] == -1:
                pass
            else:
                ans += cost[a[i][j]]
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 40176
N,K = map(int,input().split())
num = N
deno = 0

def point(check):
    count = 0

    while check < K:
        count += 1
        check = check * 2

    return 2**count


for i in range(N):
    temp = point(i+1)
    deno += 1/(N*temp)

print(deno)

Measured memory_bytes: 3064
#include <iostream>
#define MAXNUM 200
#define MAXSUM 600
using namespace std;

int dp2[MAXNUM][MAXSUM];
int dp3[MAXNUM][MAXSUM];


int main() {
	int n,m,i,j;
	while(1){
		cin >> n >> m;
		if(n == 0) break;
		for(i=2;i <= n;i++){
			for(j=3;j <= m;j++){
  				dp2[i][j] = dp2[i-1][j];
  				if(j-i > 0 && i-1 >= j-i )dp2[i][j]++;
  				dp3[i][j] = dp3[i-1][j];
				if(j-i > 0) dp3[i][j] += dp2[i-1][j-i];
 			}
		}
		
		cout << dp3[n][m] << endl;
	}
return 0;
}

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a, b) memset(a, b, sizeof(a))
#define DBG(x) cout << "[" << #x << "]: " << x << endl
using ll = long long;
using pii = pair<int, int>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif

template<class Ty> Ty randint(Ty a, Ty b) { return uniform_int_distribution<Ty>(a, b)(rng); }
template<class num> inline void rd(num& x) {
	char c, neg = 0; while(isspace(c = getchar_unlocked()));
	if(!isdigit(c)) neg = (c == '-'), x = 0;
	else x = c - '0';
	while(isdigit(c = getchar_unlocked())) x = (x << 3) + (x << 1) + c - '0';
	x = neg ? -x : x; }
template <class... Args> inline void rd(Args&... args) { (rd(args), ...); }

const int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;

int main() {
	char c; cin >> c;
	if (c >= 'a' && c <= 'z') cout << 'a';
	else cout << 'A';
}

Measured memory_bytes: 3572
n = int(input())
activity = {'a': [0], 'b': [0], 'c': [0]}
for _ in range(n):
    a, b, c = (map(int, input().split()))
    activity['a'].append(a)
    activity['b'].append(b)
    activity['c'].append(c)

lev_of_hap = {'a': [0]*(n+1), 'b': [0]*(n+1), 'c': [0]*(n+1)}

for i in range(1, n+1):
    lev_of_hap['a'][i] = max(lev_of_hap['b'][i-1], lev_of_hap['c'][i-1]) + activity['a'][i]
    lev_of_hap['b'][i] = max(lev_of_hap['a'][i - 1], lev_of_hap['c'][i - 1]) + activity['b'][i]
    lev_of_hap['c'][i] = max(lev_of_hap['a'][i - 1], lev_of_hap['b'][i - 1]) + activity['c'][i]

ans = max(lev_of_hap['a'][n], lev_of_hap['b'][n], lev_of_hap['c'][n])
print(ans)


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

int main() {
  string s;
  cin >> s;
  
  int count = 0;
  if (s[0] == '1') {
    count++;
  }
  if (s[1] == '1') {
    count++;
  }
  if (s[2] == '1') {
    count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    N, T = get_next_ints()
    values = get_next_ints()

    r_values = reversed(values)

    count = 0
    max_val = 0
    max_diff = 0
    for value in r_values:
        if value >= max_val:
            max_val = value
            continue
        diff = max_val - value
        if diff > max_diff:
            max_diff = max_val - value
            count = 1
        elif diff == max_diff:
            count += 1
    print(count)

solve()

Measured memory_bytes: 14940
N = int(input())
divisions = []
for i in range(1, int(N**(1/2)+1)):
    if N % i == 0:
        divisions.append(i)
        divisions.append(N//i)
ans = 0
for d in divisions:
    if d == 1:
        continue
    if N // (d-1) == N % (d-1):
        ans += d-1
print(ans)


Measured memory_bytes: 3268
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main():
	a, b, m =[int(i) for i in input().split(" ")]
	res = 0
	for i in range(a, b + 1):
		if m % i == 0:
			res += 1
			
	print(res)
if __name__ == '__main__':
  main()

Measured memory_bytes: 7712
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
    # S, T = get_inputs()
    # print(T + S)
    A, B, K = get_inputs(int)
    if A >= K:
        print(A-K, B)
    elif A + B >= K:
        print(0, B - (K-A))
    else:
        print(0, 0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;


long double dist(ll x1, ll y1, ll x2, ll y2){
    return sqrt((double)pow(x2-x1, 2) + (double)pow(y2-y1, 2));
}


int main(){
    ll N; cin >> N;
    vector<ll> X(N), Y(N); for(int i = 0; i < N; i++) cin >> X[i] >> Y[i];
    long double ans = 0.0;
    for(int i = 0; i < N-1; i++){
        for(int j = i+1; j < N; j++){
            ans += dist(X[i], Y[i], X[j], Y[j]) * 2.0;
        }
    }
    cout << setprecision(20) << ans / (long double) N << endl;;
} 


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

using namespace std;
typedef long long ll;
ll mod = 1e9+7;

int main(void)
{
  ll N;cin>>N;
  vector<ll> P(N);
  ll min=2e5+1,res=0;
  for(ll i=0;i<N;i++){
    ll p;cin>>p;
    if(min>=p){res++;min=p;}
  }
  cout<<res<<endl;
    return 0;
}

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

int main(){
  int a,b;
  while(cin >> a >> b, a){
    int res = 1e9;
    for(int i=1;i*i<=a;i++){
      if(a%i)continue;
      for(int j=1;j*j<=b;j++){
	if(b%j)continue;

	int v[4];
	v[0] = i; v[1] = a/i; v[2] = j; v[3] = b/j;
	sort(v,v+4);
	int sum = 0;
	for(int k=0;k<3;k++)sum += (v[k+1]-v[k])*(v[k+1]-v[k]);
	res = min(res, sum);
      }
    }
    cout << res << endl;
  }
}
    

Measured memory_bytes: 1172
//解説あり

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;
int n;

void dfs(string s, char mx) {
    if (s.size()==n) {
        cout << s << endl;
        return;
    }
    for (char c = 'a'; c <= mx; c++) {
        dfs(s+c, c==mx ? mx+1 : mx);
    }

}

int main(void) {
    cin >> n;

    dfs("", 'a');

	return 0;
}


Measured memory_bytes: 1536
#include <algorithm>
#include <string>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdio.h>
#include <iostream>
using namespace std;

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

	d = 0.5 * a * b * sin(M_PI * c / 180);
	e = sqrt(a * a + b * b - 2 * a * b * cos(M_PI * c / 180));
	printf("%.8lf\n", d);
	printf("%.8lf\n", a + b + e);
	printf("%.8lf\n", 2 * d / a);
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int sc(int x){
    int S=0;
    while(x>0){
        S+=x%10;
        x/=10;
    }
    return S;
}
int main(){
    int n;
    scanf("%d",&n);
    int Min=INT_MAX;
    for(int i=1;i<=n-1;++i){
        int j=n-i;
        Min=min(Min,sc(i)+sc(j));
    }
    printf("%d\n",Min);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using lnt = long long;
using Real = long double;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)
 
#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)
 
constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;
 
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}
 
using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int N; cin >> N;
	vector<vector<Real>> dist(N, vector<Real>(N));
	vector<Real> X(N), Y(N);
	REP(i, N){
		cin >> X[i] >> Y[i];
	}
	REP(i, N){
		REP(j, N){
			dist[i][j] = sqrtl(powl(X[i]-X[j], 2.0) + powl(Y[i]-Y[j], 2.0));
		}
	}
	vector<int> vec(N);
	REP(i, N) vec[i] = i;
	Real sum = 0.0, cnt = 0.0;
	do{
		REP(i, N-1){
			sum += dist[vec[i]][vec[i+1]];
		}
		cnt += 1.0;
	} while(next_permutation(ALL(vec)));
	dcout << (sum / cnt) << ln;
}

Measured memory_bytes: 3812