akhauriyash/Code-Regression huggingface dataset:
H, W = gets.split.map(&:to_i)
M = H.times.map{ gets.chomp.chars }
X = (0 ... W); Y = (0 ... H)
H.times do |y|
  W.times do |x|
    if M[y][x] == '.'
    	M[y][x] = [x - 1, x, x + 1].product([y - 1, y, y + 1]).select{|x_, y_| X.include?(x_) && Y.include?(y_) }.count{|x_, y_| M[y_][x_] == '#' }
    end
  end
end
puts M.map{|r| r.join }

Measured memory_bytes: 2172
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define co cout
#define ci cin
#define sf1(n) scanf("%lld",&n);
#define sf2(n,m) scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define en cout<<endl;
#define pb push_back
#define coy cout<< "YES"<<endl;
#define con cout<< "NO"<<endl;
#define For(a,b) for(ll a=0;a<b;a++)
#define br break;
#define i64 long long
i64 M=10000000;
//ll b[805],ans[805];
map< ll,pair<ll,ll> >mp;

int main()
{
    ll t,n,g,k,m,mx=0,mn=1e9,res,c1,x,y,c2;
    ci>>n>>m>>k;
    ll a[n];
    memset(a,0,sizeof(a));
    for(ll i=0;i<k;i++)
    {
        ci>>g;
        a[g-1]++;
    }
    if(k<m)
    {
        for(ll i=0;i<n;i++) co<<"Yes"<<endl;
    }
    else
    {
        mx=k-m;
        for(ll i=0;i<n;i++)
        {
            if(a[i]>mx) co<< "Yes"<<endl;
            else co<< "No"<<endl;
        }
    }
}



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

int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a > b) {
        printf("a > b\n");
    } else if (a < b) {
        printf("a < b\n");
    } else {
        printf("a == b\n");
    }
}


Measured memory_bytes: 3140
// #[warn(dead_code)]
// const TOP: u64 = 1000000007;

fn main() {
	let text = {
		use std::io::Read;
		let mut s = String::new();
		std::io::stdin().read_to_string(&mut s).unwrap();
		s
	};

	let word = text.trim();

	let first: u32 = word.chars().take(2).collect::<String>().parse().unwrap();
	let last: u32 = word
		.chars()
		.skip(2)
		.take(2)
		.collect::<String>()
		.parse()
		.unwrap();

	if 1 <= first && first <= 12 {
		if 1 <= last && last <= 12 {
			println!("AMBIGUOUS");
		} else {
			println!("MMYY");
		}
	} else {
		if 1 <= last && last <= 12 {
			println!("YYMM");
		} else {
			println!("NA");
		}
	}

	// println!("{} {}", first, last);
}


Measured memory_bytes: 4352
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int N;
const int Nmax = 2e5;
int P[Nmax];

int main(){
	cin >> N;
	for(int i=0; i<N; i++) cin >> P[i];

	vector<int> p_inv(N);
	for(int i=0; i<N; i++) p_inv[P[i]-1] = i+1;

	vector<ll> a(N), b(N);
	a[0] = 1;
	b[0] = 9e8-1+p_inv[0];

	for(int i=1; i<N; i++){
		if(p_inv[i]>p_inv[i-1]){
			b[i] = b[i-1]-1;
			a[i] = 9e8+p_inv[i]-b[i];
		} else {
			a[i] = a[i-1]+1;
			b[i] = 9e8+p_inv[i]-a[i];
		}
	}

	for(int i=0; i<N; i++) cout << a[i] << (i==N-1?'\n':' ');
	for(int i=0; i<N; i++) cout << b[i] << (i==N-1?'\n':' ');

	return 0;
}


Measured memory_bytes: 1152
package main

import (
    "bufio"
    "os"
    "strings"
    "strconv"
    "fmt"
)


var sc = bufio.NewScanner(os.Stdin)

func readLineToInt() []int {
    sc.Scan()
    line := strings.Split(sc.Text(), " ")
    var intLine []int
    length := len(line)
    for i := 0;i < length; i++ {
        n, _ := strconv.Atoi(line[i])
        intLine = append(intLine, n)
    }
    return intLine
}

func readInt() int {
    sc.Scan()
    str := sc.Text()
    n, _ := strconv.Atoi(str)
    return n
}

func main() {
    readInt()
    hList := readLineToInt()
    cnt := 0
    preValue := 0
    for _, value := range hList {
        if preValue < value {
            cnt += value - preValue
        }
        preValue = value
    }
    fmt.Println(cnt)
}


Measured memory_bytes: 640
#include <cstdio>
#define BASE 26LL
using namespace std;

int main(int argc, char** argv)
{
	char s[12];
	int cnt = 0;
	long long n;
	scanf("%lld", &n);
	while(n > 0)
	{
		n --;
		s[cnt++] = n % BASE + 'a';
		n /= BASE;
	}
	for(int i=cnt-1; i>=0; i--) putchar(s[i]);
	putchar('\n');
	return 0;
}

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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int n, m;cin>>n>>m;

	vector<int> d(n+1);

	rep(i,m){
		int l,r;cin>>l>>r;

		d[l] +=1;
		d[r+1] -=1;
	}

	rep(i,n+1){
		d[i+1] += d[i];
	}
	int cnt=0;
	rep(i,n+1){
		if(d[i] ==m)cnt++;
	}
	writeln(cnt);


}


Measured memory_bytes: 640
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

using namespace std;

int main(){
    long long A, B, C;
    cin >> A >> B >> C;
    for(int i=1;i<=10000000;i++){
        if(A % 2 || B % 2 || C % 2){
            cout << i-1 << endl;
            return 0;
        }
        long long a = 0, b = 0, c = 0;
        a += B / 2;
        a += C / 2;
        b += A / 2;
        b += C / 2;
        c += A / 2;
        c += B / 2;
        A = a, B = b, C = c;
    }
    cout << -1 << endl;
	return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;
int vis[2][maxn];
int main()
{
	int N,M,a[100010];
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
		scanf("%d",&a[i]);
	a[0]=2e5;
	for(int i=1;i<=N;i++)
			vis[i%2][a[i]]++;
//	sort(vis[0]+1,vis[0]+1+N,[&](int a,int b){return a>b;});
//	sort(vis[1]+1,vis[1]+1+N,[&](int a,int b){return a>b;});
	int p1=0,p2=0,pp1=0,pp2=0,m1=0,m2=0,mm1=0,mm2=0;
	for(int i=1;i<=1e5;i++)
		if(vis[0][i]>m1)
				m1=vis[0][i],p1=i;
	for(int i=1;i<=1e5;i++)
		if(vis[1][i]>m2)m2=vis[1][i],p2=i;
	for(int i=1;i<=1e5;i++)
		if(i!=p1&&vis[0][i]>mm1)mm1=vis[0][i],pp1=i;
	for(int i=1;i<=1e5;i++)
		if(i!=p2&&vis[1][i]>mm2)mm2=vis[1][i],pp2=i;
	if(p1!=p2)printf("%d\n",N-m1-m2);
	else printf("%d\n",N-max(m1+mm2,m2+mm1));

}

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

string K;
ll D;

constexpr ll MOD = 1e9 + 7;

vector<vector<vector<ll>>> memo;

ll solve(ll i, ll j, bool equal) {
    if (i == K.size()) {
        return j == 0;
    }

    if (memo[i][j][equal] != -1) {
        return memo[i][j][equal];
    }

    ll result = 0;
    if (equal) {
        for (ll k = 0; k <= K[i] - '0'; k++) {
            (result += solve(i + 1, (j + k) % D, k == K[i] - '0')) %= MOD;
        }
    } else {
        for (ll k = 0; k < 10; k++) {
            (result += solve(i + 1, (j + k) % D, false)) %= MOD;
        }
    }
    return memo[i][j][equal] = result;
}

int main() {
    cin >> K >> D;
    memo.resize(K.size(), vector<vector<ll>>(D, vector<ll>(2, -1)));

    cout << (solve(0, 0, true) + MOD - 1) % MOD << endl;
}

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

int main() {
  long int X;
  cin >> X;
  long int count=0,score=0;
  count = X/11 *2;
  X -= count/2 *11;
  while(score<X){
    count ++;
    if(count%2==1) score +=6;
    else score +=5;
  }
  cout << count << endl;
}


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

int main() {
  //N 回数　S 入力
  int N;
  cin >> N ;
  
  int P = 0;
  int W = 0;
  int G = 0;
  int Y = 0;
   
// for 
    for (int i = 0 ; i < N ; i++) {
		string B;
        cin >> B ;

    	if ( B == "P" ) {
         	 P = 1;
        }

        	else if ( B == "W" )	{
            	W = 1;
        }
      			else if ( B == "G" )	{
                G = 1;
        }
      				 else	{
                      Y	= 1;
                    }
    }
 // 出力
      if	( P + W + G + Y == 4)	
      	cout << "Four" << endl;
      
      else	
        cout << "Three" << endl;
     
    }
//　終了

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [float('inf') for _ in range(N)]
    dp[0] = 0
    dp[1] = abs(h[0] - h[1])
    for i in range(2, N):
        k = 1
        for k in range(1, K + 1):
            dp[i] = min(dp[i], dp[i - k] + abs(h[i] - h[i - k]))
    print(dp[-1])


main()


Measured memory_bytes: 56800
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a;
	for (int h = 0; h < 20; h++) {
		cin >> n;
		int test[11] = { 0 };
		if (n == 0) {
			cin >> n; return 0;
		}
		for (int i = 0; i < n; i++) {
			cin >> a;
			test[a]++;
		}
		for (int i = 0; i < 10; i++) {
			if (test[i] == 0) {
				cout << '-' << endl;
			}
			else {
				for (int j = 0; j < test[i]; j++) {
					cout << '*';
				}
				cout << endl;
			}
		}
	}
	cin >> n;
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,m,s[22],t[22];
vector<int>v[55];
vector<int>vs[21];
bool used[55];
int d[55];
bool color[55];
int e[55][55];
void dfs(int x){
    used[x]=true;
    for(int i:v[x]){
        if(!used[i]){
            d[i]=d[x]+1;
            dfs(i);
        }
    }
}
signed main(){
    cin>>n;
    rep(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].pb(b);
        v[b].pb(a);
        e[a][b]=e[b][a]=i;
    }
    cin>>m;
    rep(i,m){
        cin>>s[i]>>t[i];
        s[i]--,t[i]--;
        fill(used,used+n,false);
        fill(d,d+n,INF);
        d[s[i]]=0;
        dfs(s[i]);
        int now=t[i];
        while(1){
            if(s[i]==now)break;
            for(int I:v[now]){
                if(d[I]+1==d[now]){
                    vs[i].pb(e[now][I]);
                    now=I;
                    goto loop;
                }
            }
            loop:;
        }
    }
    int res=0;
    for(int i=0;i<(1<<m);i++){
        int popcount=__builtin_popcount(i);
        fill(color,color+n-1,false);
        rep(j,m){
            if((i>>j)&1){
                for(int k:vs[j])color[k]=true;
            }
        }
        int cnt=0;
        rep(j,n-1)if(color[j]==0)cnt++;
        if(popcount%2){
            res-=(1ll<<cnt);
        }
        else{
            res+=(1ll<<cnt);
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
//枝ごとにデータを格納する場合
struct edge{
	int from, to;
	ll cost;
};
vector<edge> ES(2000);
vector<ll> Dist(1000, 0);
vector<bool> negative(1000, false);
//ベルマンフォード法(sは始点, nは頂点数, mは枝数)
void BellmanFord(int s, int n, int m)
{
	for(int i=0; i<n; i++) Dist[i]=1e18;

	Dist[s]=0;
	
	for(int j=0; j<n; j++){
		bool update=false;
		for(int i=0; i<m; i++){
			edge e=ES[i];
			if(Dist[e.from]!=1e18&&Dist[e.to]>Dist[e.from]+e.cost){
				Dist[e.to]=Dist[e.from]+e.cost;
				update=true;
			}
		}
		if(!update) break;
	}
}
//グラフ内の負の閉路を検出する
void find_negative_loop(int n, int m)
{
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			edge e=ES[j];
			if(Dist[e.from]!=1e18&&Dist[e.to]>Dist[e.from]+e.cost){
				Dist[e.to]=Dist[e.from]+e.cost;
				negative[e.to]=true;
			}
			if(negative[e.from]) negative[e.to]=true;
		}
	}
}
int main(void)
{
	int n, m;

	cin>>n>>m;

	rep(i, m){
		cin>>ES[i].from>>ES[i].to>>ES[i].cost;
		ES[i].from--; ES[i].to--; ES[i].cost=-ES[i].cost;
	}
	BellmanFord(0, n, m);
	ll ans=-Dist[n-1];
	find_negative_loop(n, m);
	if(negative[n-1]){
		cout<<"inf"<<endl;
	}else{
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

string solve(immutable int n)
{
    auto t = iota(3).map!(_=>readln().chomp().to!int());
    immutable m=t[0], p=t[1], d=t[2];
    auto g = iota(d).map!(_=>readln().chomp().map!(c=>c=='1').array()).array();
    auto a = iota(1,n+1).array();
    foreach(e;g) foreach(i,v;e) if(v) swap(a[i],a[i+1]);
    immutable h=a[p-1];
    if(m==h) return "0";
    a = iota(1,n+1).array();
    foreach(j,e;g)
    {
        foreach(i,v;e) if(v) swap(a[i],a[i+1]);
        foreach(i,v;a) if(v==m || v==h)
        {
            if((a[i+1]==m || a[i+1]==h) && (i<=0 || !e[i-1]) && !e[i] && (i+1>=e.length || !e[i+1]))
                return format("%s %s",j+1,i+1);
            break;
        }
    }
    return "1";
}

void main()
{
    for(int n; 0!=(n=readln().chomp().to!int()); )
        writeln(solve(n));
}

Measured memory_bytes: 1072
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

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

    int x[8], y[8];
    for(int i=0; i<N; i++){
        cin >> x[i] >> y[i];
    }

    vector<int> v(N);
    iota(v.begin(), v.end(), 1);

    double rsum = 0;
    int d = 0;
    do{
        for(int i=0; i<N-1; i++){
            rsum += sqrt((x[v[i]-1] - x[v[i+1]-1]) * (x[v[i]-1] - x[v[i+1]-1])
                    + (y[v[i]-1] - y[v[i+1]-1]) * (y[v[i]-1] - y[v[i+1]-1]));
        }
        d++;
    }while(next_permutation(v.begin(), v.end()));

    cout << setprecision(20) << rsum / d << endl; 
	return 0;
}


Measured memory_bytes: 256
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP
*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define PB push_back
#define IN insert
#define MP make_pair
#define all(v) v.begin(),v.end()
//#define y cout<<"Yes"
#define LW(v) sort(v.begin(),v.end());
#define HI(v) sort(v.begin(),v.end(),greater<long long>());
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    double t,r=1,r1=0,r2=0,k=0,a,b,c,m,d=0,n,e,f,x,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4,s5;
    cin>>s1;
    a=count(all(s1),'A');
    b=count(all(s1),'B');
    if(a>=1&&b>=1)
    {
        cout<<"Yes";
    }
  else{cout<<"No";
//cout<<setprecision(12)<<fixed<<x<<endl;
}
}





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

#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

const int maxr = 1e5 + 5;


int32_t main()
{
	GO;
	char ch;
	cin >> ch;
	if ('A' <= ch && ch <= 'Z')
		cout << "A" << endl;
	else
		cout << "a" << endl;
	return 0;
}

//!

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main() {
	long long h;
	cin>>h;
	long long cnt=0;
	while(h) {
		h/=2;
		cnt++;
	}
	long long res=1,a=2;
	while(cnt) {
		if(cnt%2) res*=a;
		a*=a;
		cnt/=2;
	}
	cout<<res-1;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:268435456")
#pragma warning( disable : 6031)
#pragma warning( disable : 4244)
#pragma warning( disable : 26451)
#ifndef _MSC_VER
#pragma GCC target ("sse4.2")
#endif
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#  define __builtin_popcountll __popcnt64
#endif
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdint>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <random>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <chrono>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-15)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef pair<ll, ll> pll;
typedef vector< pii > vpii;
typedef vector< pll > vpll;
typedef vector<ll> vl;
typedef vector<vector<long long>> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef tuple<int, int, int> tiii;
const long long mod = int(1e9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;




int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int s, w;
	cin >> s >> w;
	cout << (w >= s ? "unsafe" : "safe");
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
    int m,f,r,p;
    
    while(1)
    {
        scanf("%d %d %d\n",&m,&f,&r);
        
        if (m==-1 && f==-1 && r==-1)
        break;
        
        p = m + f;
        
        if (p >= 80)
        printf("A\n");
        
        else if (m==-1 || f==-1)
        printf("F\n");

        
        else if (65<=p && p<80)
        printf("B\n");
        
        else if (50<=p && p<65)
        printf("C\n");
        
        else if ((30<=p && p<50) && r>=50)
        printf("C\n");
        
        else if ((30<=p && p<50) && r<50)
        printf("D\n");
        
        else if (p<30)
        printf("F\n");
        
    }
    
    return 0;
}



Measured memory_bytes: 2136
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
	int n; cin>>n;
	int ans=n*800 -(n/15)*200;
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
data = list(map(int, input().split()))

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

left_ = [0] * (n + 1)
right_ = [0] * (n + 1)
ans = []

for i in range(n):
    left_[i] = gcd( left_[i-1], data[i] )

for i in range(n-1, 0, -1):
    right_[i] = gcd( right_[i+1], data[i] )

for i in range(n):
    ans += [ gcd( left_[i-1], right_[i+1] ) ]

print( max(ans) )


Measured memory_bytes: 20584
# -*- coding: utf-8 -*-

import math

n = int(raw_input())
x = map(int, raw_input().split())
y = map(int, raw_input().split())
d1 = d2 = d3 = d4 = 0.0
for i in range(n):
    d = math.fabs(x[i]-y[i])
    d1 += d
    d2 += d*d
    d3 += d*d*d
    if d4 < d:
        d4 = d
d2 = math.pow(d2, (1.0/2.0))
d3 = math.pow(d3, (1.0/3.0))

print d1
print d2
print d3
print d4

Measured memory_bytes: 6676
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

struct UnionFind {
  vector<int> parent; // parent[root] is the negative of the size.
  UnionFind(int n) : parent(n, -1) { };
  bool unite(int u, int v) { 
    u = root(u); v = root(v);
    if (u == v) return false;
    if (parent[u] > parent[v]) swap(u, v);
    parent[u] += parent[v]; parent[v] = u;
    return true;
  }
  bool find(int u, int v) { return root(u) == root(v); }
  int root(int u) { return parent[u] < 0 ? u : parent[u] = root(parent[u]); }
  int size(int u) { return -parent[root(u)]; }
};

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, M, K;
  while (cin >> N >> M >> K) {
    vec<int, 2> ok(N), ng(N);
    UnionFind uf(N);
    for (int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      ok[a].push_back(b);
      ok[b].push_back(a);
      uf.unite(a, b);
    }
    for (int i = 0; i < K; i++) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      ng[a].push_back(b);
      ng[b].push_back(a);
    }
    for (int i = 0; i < N; i++) {
      int res = uf.size(i) - 1 - ok[i].size();
      for (int j : ng[i]) {
        if (uf.find(i, j)) --res;
      }
      cout << res << " ";
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 12152
def main():
    N = int(input())
    p = list(map(float, input().split()))
    u = [0.0]
    v = [1 - p[0], p[0]]
    for i, p in enumerate(p[1:], 1):
        u, v = v, u + [0.0, 0.0]
        t = u[0]
        v[0] = t * (1 - p)
        for j, uu in enumerate(u[1:], 1):
            v[j] = t * p + uu * (1 - p)
            t = uu
        v[-1] = t * p
    print(sum(v[(N + 1) // 2:]))

main()


Measured memory_bytes: 3316
s=input()
N=len(s)

b,w=0,0
for i in range(N):
    if i%2==0:
        if s[i]=="1": b+=1
        else: w+=1

    
    else:
        if s[i]=="1": w+=1
        else: b+=1

print(min(b,w))

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int scount=0; //记录s出现次数 
    int n=s.size();
    for(int i=0;i<s.size();i++){
        if(s[i]=='T'&& scount>0){
             //删除一对 
            n-=2; 
            scount--;
            continue;
        }
        if(s[i]=='S'){
                scount++;
        }
    }
    printf("%d\n",n);
}


Measured memory_bytes: 832
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, i;
    ll ans, pys;

    scanf("%d", &n);

    ans = 0;
    for (i = 1; i <= n; i++) {
        pys = n / i;
        pys = pys * (pys + 1) / 2;
        pys *= i;
        ans += pys;
    }

    printf("%lld\n", ans);
    
    return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    int n, k;
    cin >> n >> k;
    ll ans = 0;

    // 1
    ll t = n / k;
    ans += t * t * t;

    // 2
    if (k % 2 == 0 and n >= k / 2) {
        ll s = 1;
        n -= k / 2;
        s += n / k;
        ans += s * s * s;
    }

    out(ans);
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

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

        int n = sc.nextInt();

        int min = sc.nextInt();
        long ans = 0;

        for (int i = 1; i < n; i++) {
            int tmp = sc.nextInt();

            if (tmp > min) {
                min = tmp;
            } else {
                ans += (min - tmp);
            }
        }

        System.out.println(ans);


        sc.close();

        }

    }



Measured memory_bytes: 58516
import java.io.*;

public class Main {

  static int time;
  
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] in = br.readLine().split(" ");
    time = Integer.parseInt(in[0]);


    br.close();

    int h = time / 3600;
    int m = (time - h * 3600) / 60;
    int s = time % 60;

    System.out.println(h + ":" + m + ":" + s);

  }
}


Measured memory_bytes: 24436
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};

map<ll, ll> prime_factor(ll n){
  map<ll, ll> res;
  for(ll i=2 ; i*i<=n ; i++){
    while(n%i==0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}

int main(){
  ll n; cin>>n;
  map<ll, ll> ma = prime_factor(n);
  ll res=0;
  for(auto p : ma){
    ll e = p.se;
    ll tmp = 0, cur=1;
    while(e >= cur){
      e -= cur++;
      ++tmp;
    }
    res += tmp;
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <vector>
#include <functional>
using namespace std;

using ll = long long;
using P = pair<int, int>;

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

    string s, code = "CODEFESTIVAL2016";
    cin >> s;

    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != code[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define Y first
#define X second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int H, W, N;
char field[1024][1024];
int dy[] = {0,1,0,-1}, dx[] = {1,0,-1,0};

int main(){
  scanf("%d%d%d", &H, &W, &N);
  rep(i, H) scanf("%s", field[i]);

  int x, y;
  rep(i, H) rep(j, W) if(field[i][j] == 'S'){ y = i; x = j; break;}

  map<pi, int>m;
  m[MP(y, x)] = 1;
  queue<pipi>q;
  q.push(MP(MP(1, 0), MP(y, x)));
  while(!q.empty()){
    pipi p = q.front(); q.pop();
    if(field[p.S.Y][p.S.X] == p.F.F + '0'){
      if(p.F.F == N){
	printf("%d\n", p.F.S);
	break;
      }
      m.clear();
      while(!q.empty()) q.pop();
      m[MP(p.S.Y, p.S.X)] = 1;
      p.F.F++;
    }
    rep(d, 4){
      int ny = p.S.Y + dy[d], nx = p.S.X + dx[d];
      int hp = p.F.F, c = p.F.S;
      if(ny < 0 || ny >= H || nx < 0 || nx >= W || field[ny][nx] == 'X' || m.count(MP(ny, nx))) continue;
      m[MP(ny, nx)] = 1;
      q.push(MP(MP(hp, c+1), MP(ny, nx)));
    }
  }
  return 0;
}

Measured memory_bytes: 30232
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author emli
 */


#include <bits/stdc++.h>



#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define forx(i, n) for(int i = 1 ; (i) <= (n) ; ++i)
#define ll long long
#define all(x) (x).begin(),(x).end()
#define sqr(x) (x) * (x)
#define debug(x) cout << #x <<" = " << x << endl
#define printvpair(v) for(auto x : v) cout << x.first  <<" " << x.second << endl;
#define printv(v) if (v.size()> 0) {for(auto x : v) cout << x << " "; cout << endl;}
#define MINUS(a) memset(a,0xff,sizeof(a))

const int INF = INT_MAX / 2;
const int N = (int)1e6 + 7;

const int dx[4] = {0,  0, 1, -1};
const int dy[4] = {1, -1, 0,  0};
using namespace std;

class CGrandGarden {
public:
	void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int n;
        cin >> n;
        vector<bool> used(n + 1);
        vector<int> a(n + 1),b(n + 1);

        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            if (a[i] == 0){
                used[i] = true;
            }
        }

        int l = -1;
        int r = -1;
        int ans = 0;
        while (true) {
            bool ok = true;
            for (int i = 0; i < n; ++i) {
                if (a[i] != b[i]) {
                    ok = false;
                    l = i;
                    r = n - 1;
                    for (int j = i + 1; j < n; ++j) {
                        if (used[j]) {
                            r = j - 1;
                            break;
                        }
                    }
                    ans++;
                   // cout << "Range = " << l << " " << r << endl;
                    for (int k = l; k <= r; ++k) {
                        b[k]++;
                        if (b[k] == a[k]) {
                            used[k] = true;
                        }
                    }
                    break;
                }
            }
            if(ok){
                break;
            }
        }

        cout << ans << endl;
	}
};


int main() {
	CGrandGarden solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main() {
    int H, W;
    char c[110][110];
    char c2[210][110];

    cin >> H  >> W;
    for(int i = 1; i <= H; i++){
        for (int j = 1; j <= W; j++){
            cin >> c[i][j];
        }
    }
    for(int i = 1; i <= 2*H; i++){
        for(int j = 1; j <= W; j++){
            c2[i][j] = c[(i+1)/2][j];
            cout << c2[i][j];   
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
S = input()
if S[0] == "A":
    if S[2:-1].count("C") == 1:
        S2 = S.replace("A","")
        S3 = S2.replace("C","")
        if S3.islower() == True:
            ac = True
        else:
            ac = False
    else:
        ac = False
else:
    ac = False
if ac == True:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<numeric>
using namespace std;
#define ll  long long
#define mp make_pair
#define fi first
#define se second
#define pii pair<ll,ll>
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define what_is(x) cerr << #x << " is " << x << endl;
string str;ll ans=0;
void dfs (int a,ll now)
{
    if(a==str.size()){
        ans += now;
        return;
    }
    ll x=0;
    for(int i=a;i<str.size();i++)
    {
        x=x*10+str[i]-'0';
        dfs(i+1,now+x);
    }
}
int main()
{
    cin >> str;
    dfs(0,0);
    cout << ans << endl;
}

Measured memory_bytes: 256
n,m,X,Y = list(map(int,input().split()))
x = list(map(int,input().split()))
y = list(map(int,input().split()))

m_x = sorted(x,reverse=True)
m_y = sorted(y)

ans = "War"

for i in range(X+1,Y+1):
    if m_x[0]<i<=m_y[0]:
        ans = "No War"
 
print(ans)




Measured memory_bytes: 38384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type Node struct {
	key    int
	parent *Node
	left   *Node
	right  *Node
}

// main
func main() {
	//testFunction()
	solve(bufio.NewScanner(os.Stdin))
}

// test
func testFunction() {
	input := `
8
insert 30
insert 88
insert 12
insert 1
insert 20
insert 17
insert 25
print
`
	sc := bufio.NewScanner(strings.NewReader(strings.Trim(input, "\n")))
	solve(sc)
}

func preOrder(node *Node, accm []int) []int {
	if node == nil {
		return accm
	}
	accm = append(accm, node.key)
	accm = preOrder(node.left, accm)
	accm = preOrder(node.right, accm)
	return accm
}

func inOrder(node *Node, accm []int) []int {
	if node == nil {
		return accm
	}
	accm = inOrder(node.left, accm)
	accm = append(accm, node.key)
	accm = inOrder(node.right, accm)
	return accm
}

func postOrder(node *Node, accm []int) []int {
	if node == nil {
		return accm
	}
	accm = postOrder(node.left, accm)
	accm = postOrder(node.right, accm)
	accm = append(accm, node.key)
	return accm
}

func NewNode(key int) *Node {
	return &Node{
		key:    key,
		parent: nil,
		left:   nil,
		right:  nil,
	}
}

//func insert(node *Node, key int) *Node {
//	if node == nil {
//		return NewNode(key)
//	}
//
//	if node.key > key {
//		node.left = insert(node.left, key)
//	}
//	if node.key < key {
//		node.right = insert(node.right, key)
//	}
//	node.parent = node
//	return node
//}
func insert(node *Node, key int) *Node {

	var parent *Node
	n := node
	for n != nil {
		parent = n
		if n.key > key {
			n = n.left
		} else {
			n = n.right
		}
	}

	nn := &Node{
		key: key,
	}
	if parent == nil {
		return nn
	}
	nn.parent = parent
	if key < parent.key {
		parent.left = nn
	} else {
		parent.right = nn
	}

	return node
}

//
func printList(accm []int) {
	buf := bufio.NewWriter(os.Stdout)
	for _, v := range accm {
		buf.Write([]byte(fmt.Sprintf(" %d", v)))
	}
	buf.Flush()
}

func print(node *Node) {
	var accm []int
	accm = inOrder(node, accm)
	printList(accm)
	fmt.Println()
	accm = make([]int, 0)
	accm = preOrder(node, accm)
	printList(accm)
	fmt.Println()
}

// solve
func solve(sc *bufio.Scanner) {
	var node *Node
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	for i := 0; i < n; i++ {
		sc.Scan()
		command := sc.Text()
		if command == "insert" {
			sc.Scan()
			value, _ := strconv.Atoi(sc.Text())
			node = insert(node, value)
		} else if command == "print" {
			print(node)
		}
	}
}



Measured memory_bytes: 52284
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
/*
#include <map>
#include <functional>
#include <set>
#include <iterator>
*/

using namespace std;
typedef long long ll;
int X;
char S[20];

int main() {
   cin >> S;
   int i=0;
   int max_abs = 10000;
   for (i=0;S[i+2] != '\0';i++) {
      int cnt = (S[i] - '0') * 100 + (S[i+1] - '0') * 10 + (S[i+2] - '0');
      //cout << S[i] - '0' << " " << S[i+1] - '0' << " " << S[i+2] - '0' << endl;
      max_abs = min(max_abs, abs(cnt - 753));
   }
   cout << max_abs << endl;
}

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

int main( ) {
  int a, b;
  cin >> a >> b;
  
  int count = 0;
  if(a <= b){
    count = a;
  }else{
    count = a - 1;
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
#include<numeric>
using namespace std;
typedef long long ll;
//ll mod = 1e9+7;
ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> a_accum(n+1);
    a_accum[0] = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        a_accum[i+1] = a_accum[i] + a;
    }
//    rep(i, n+1) {
//        cout << a_accum[i] << endl;
//    }
    vector<vector<ll>> keta_one_list(40);
    rep(i, n) {
        for ( int j = i; j < n; ++j ) {
            ll tmp_num = a_accum[j+1] - a_accum[i];
            int check_idx = 0;
            while(1) {
//                cout << tmp_num << " " << (1LL<<check_idx) << endl;
                if ( (1LL<<check_idx) > tmp_num ) {
                    break;
                }
                if ( tmp_num & (1LL<<check_idx) ) {
                    keta_one_list[check_idx].push_back(tmp_num);
//                    cout << keta_one_list[check_idx].back() << endl;
                }
                ++check_idx;
            }
        }
    }
//    rep(i, 10) {
//        cout << i << ": ";
//        for ( auto tmp_num : keta_one_list[i] ) {
//            cout << tmp_num << " ";
//        }
//        cout << endl;
//    }
    ll ans = 0;
    for ( int i = 39; i >= 0; --i ) {
        if ( keta_one_list[i].size() < k || keta_one_list[i].empty() ) {
            continue;
        }
//        cout << i << endl;
        ans += 1LL<<i;
        int cnt = 0;
        for ( auto tmp_num : keta_one_list[i] ) {
            if ( ( ans & tmp_num ) == ans ) {
                ++cnt;
            }
        }
        if ( cnt < k ) {
            ans -= 1LL<<i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 76304
#include<stdio.h>
int main(void){
	int a, b;
	scanf("%d %d",&a,&b);
	if (a < b){
		printf("a < b\n");
	}
	else if (a > b){
		printf("a > b\n");
	}
	else if (a == b){
		printf("a == b\n");
	}
return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double d,t,s;
    cin>>d>>t>>s;
    if(d/s<=t)
    cout<<"Yes"<<'\n';
    else
    cout<<"No"<<'\n';
    
 
    
    
    return 0;
}

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


#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
ll a[110000];

main(){
  ll n,m,ans=0,sum=1,cnt=0;
  cin>>n>>m;
  rep(i,0,n)cin>>a[i];
  bool fuck=true;
  rep(i,0,n)if(a[i]%2==1)fuck=false;
  sum=a[0]/2;
  rep(i,1,n)sum=sum/GCD(sum,a[i]/2)*a[i]/2;
  ll k=1;
  if(sum>m)fuck=false;
  while(sum*(2*k-1)<=m){ans++,k++;}

  rep(i,0,n){
    if((sum/(a[i]/2))%2==0)fuck=false;
  }
  if(fuck)cout<<ans;
  else cout<<0;
}

Measured memory_bytes: 1024
n = int(input())

graphs = []

for _ in range(n):
    graphs.append(list(map(int, input().split()))[2:])


def bfs(graphs, seen_points, score, scores, queue):
    while len(queue) > 0:
        start_point = queue.pop(0)
        if seen_points[start_point - 1] == 2:
            continue
        else:
            next_points = [
                point for point in graphs[start_point - 1] if seen_points[point - 1] == 0]
            if len(next_points) >= 1:
                score += 1
                for point in next_points:
                    queue.append(point)
                    if seen_points[point - 1] == 0:
                        seen_points[point - 1] = 1
                        scores[point - 1] = scores[start_point - 1] + 1
                seen_points[start_point - 1] = 2


seen_points = [0 for _ in range(n)]
scores = [-1 for _ in range(n)]
scores[0] = 0
queue = [1]
bfs(graphs, seen_points, 0, scores, queue)

for index, score in enumerate(scores):
    print(index + 1, score)



Measured memory_bytes: 5632
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < m; i++) {
			int s = sc.nextInt() - 1;
			int t = sc.nextInt() - 1;
			a[s]++;
			a[t]++;
		}
		for (int i = 0; i < n; i++) {
			System.out.println(a[i]);
		}
	}

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


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

#define endl '\n'
#define ll long long
#define rint register int
#define minpq priority_queue <int, vector<int>, greater<int> >
#define maxpq  priority_queue <int>

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t, i, x, j, y, 	z, k, n;
	cin >> n;

	z = 0;

	rep(i, 1, n + 1, 1) {
		ll s = i, l = (n / i) * i;
		ll t = (l - s) / i + 1;

		z += (t * (l + s)) / 2;
	}

	ce(z)
}


Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main(){
    while(true){
    int n,m;
    cin>>n>>m;
    if(n==0&&m==0){
        return 0;
    }
    int a[1000];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int sum=-1;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int p = a[i]+a[j];
            if(p<=m&&p>sum){
                sum=p;
            }
        }
    }
    if(sum!=-1){
        cout<<sum<<endl;
    }else{
        cout<<"NONE"<<endl;
    }
    }
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    ll x;
    cin>>x;
    cout<<!x<<"\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, k; cin >> n >> k;
  int a[n]; rep(i, n) cin >> a[i];
  sort(a, a+n);
  ll ans = 0;
  rep(i, n-k) ans += a[i];
  cout << ans;
}


Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
using namespace std;

int INF = 1e9 + 7;

int main() {
    int N, K, ans=INF;
    cin >> N >> K;
    vector<int>h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());

    for (int i = 0; i <= N - K; i++) {
        int l = h[i + K - 1] - h[i];
        if (l < ans)ans = l;
    }

    cout << ans << endl;

}

Measured memory_bytes: 640