akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

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

  int ret = 0;
  for(int i=0; i<n; ++i) {
    if(s[i] != '.') continue;
    s[i] = 'W';
    // cout << i << " " << s << endl;
    int turn = 0, cnt = 0;
    bool flag = true;
    for(int j=0; j<n; ++j) {
      if(turn == 0 && s[j] == 'B') turn = 1;
      else if(turn == 1) {
        if(s[j] == 'W') {
          cnt++;
        }
        else if(s[j] == 'B') {
          if(cnt >= 1) flag = false;
        }
        else {
          turn = 0;
          cnt = 0;
        }
      }
    }
    if(!flag) {
      s[i] = '.';
      continue;
    }

    // cout << s << endl;
    
    turn = 0; 
    cnt = 0;
    for(int j=0; j<n; ++j) {
      if(turn == 0 && s[j] == 'W') turn = 1;
      else if(turn == 1) {
        if(s[j] == 'B') {
          cnt++;
        }
        else if(s[j] == 'W') {
          ret = max(ret, cnt);
        }
        else {
          turn = 0;
          cnt = 0;
        }
      }
    }
    s[i] = '.';
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 3200
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*float n乗*/ll floatpow(float x,ll n){ll i;float ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
double ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 char s[1000010];sc(s);
 ll len=strlen(s);
 ll cnt=0; 
 bool flag=false;
 rep(i,0,len){
 // pr(cnt);pr(flag);pr(s[i]);
  if((cnt==0||cnt>=3)&&!flag&&s[i]=='A')flag=true;
  else if(cnt==0&&s[i]=='K'){cnt++;flag=false;}
  else if(cnt==1&&s[i]=='I'){cnt++;flag=false;}
  else if(cnt==2&&s[i]=='H'){cnt++;flag=false;}
  else if(cnt==3&&s[i]=='B'){cnt++;flag=false;}
  else if(cnt==4&&s[i]=='R'){cnt++;flag=false;}
  else{ pN;return 0;}
 }
 if(cnt==5)pY;
 else pN;
  
return 0;}

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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

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

    
    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        lefts[i]--;
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21736
package main

import (
	"fmt"
//	"strconv"
//	"sort"
//	"math"
//	"regexp"
)


var a,b,x uint64

func main(){
	fmt.Scan(&a,&b,&x)

	if a == 0{
		var n uint64 = b /x
		fmt.Println(n+1)
	}else{
		var m uint64 = (a-1) /x
		var n uint64 = b /x
		fmt.Println(n-m)
	}

}

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

int main() {
  string S, T;
  cin >> S >> T;
  int n = S.size();
  int result = 0;
  for (int i=0; i < n; ++i) {
    if (S[i] != T[i]) {
      ++result;
    }
  }
  cout << result << "\n";
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  int a, b, c;
  cin >> a >> b >> c;
  cout << min(c, b/a) << endl;
}


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

int main(){
    int x,a,b;
    cin >> x;
    if(x==1){
        cout << "Hello World" << '\n';
        
    }else{
        cin >> a >> b;
        cout << a+b << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
import collections

A,B=map(int,input().split())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

AA=collections.Counter(prime_factorize(A))
BB=collections.Counter(prime_factorize(B))

AAA=list(AA)
BBB=list(BB)

CCC=set(AAA) & set(BBB)

print(len(CCC)+1)



Measured memory_bytes: 3316
#include <algorithm>
#include <climits>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define loop(i, times) for(int i = 0; i < times; i++)
#define seloop(i, start_index, end_index) for(int i = start_index; i < end_index; i++)
#define eqseloop(i, start_index, end_index) for(int i = start_index; i <= end_index; i++)



void CreateCharTable(string input, vector<int>& collection)
{
	int index = input.size() - 1;
	collection.resize((int)('z') + 1);
	while (index != -1)
	{
		collection[(int)(input[index])] = index;
		index--;
	}
}

bool Compare(vector<int>& collection1, vector<int>& collection2)
{
	if (collection1.size() != collection2.size())
		return false;

	int n = collection1.size();
	loop(i, n)
	{
		if (collection1[i] != collection2[i])
			return false;
	}

	return true;
}

int main()
{
	string s; cin >> s;
	string t; cin >> t;

	vector<int> s_char_table, t_char_table;
	CreateCharTable(s, s_char_table);
	CreateCharTable(t, t_char_table);

	vector<vector<int>> s_char_index_collection;
	s_char_index_collection.resize(s.size());
	vector<vector<int>> t_char_index_collection;
	t_char_index_collection.resize(t.size());
	int s_size = s.size();
	loop(i, s_size)
		s_char_index_collection[s_char_table[(int)(s[i])]].push_back(i);
	int t_size = t.size();
	loop(i, t_size)
		t_char_index_collection[t_char_table[(int)(t[i])]].push_back(i);

	loop(i, s_size)
	{
		if (!Compare(s_char_index_collection[i], t_char_index_collection[i]))
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 12228
// Problem : A - Not
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)
#define vt vector
#define bug(x) cout<<#x<<"="<<x<<endl;

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

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

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char cl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n;
	cin>>n;
	if(n==1)
	cout<<0;
	if(n==0)
	cout<<1;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
 
using namespace std;
 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
 
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
 
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
 
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
 
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



int main(){
  int N,M;
  cin >> N >> M;
  int perm[10];
  rep(i,10) perm[i] = i+1;
  vector<int> G[100];
  
  rep(i,M){
    int a,b;
    cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int ans = 0;
  do{
    bool f = true;
    int to = 0;
    rep(i,N-1){
      auto res = find(all(G[to]),perm[i]);
      if(res == G[to].end()){
	f = false;
	break;
      }
      else{
	to = perm[i];
      }
    }
    // cout << to << " ";
    // rep(i,N-1) cout << perm[i];
    // cout << endl;
    if(f) ans++;
  }while(next_permutation(perm,perm+N-1));
  cout << ans << endl;
}

  
                           

                                                          






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){

    ll h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    ll s1 = h1*60+m1;
    ll s2 = h2*60+m2;

    cout << s2-s1-k << endl;
    return 0;

}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <functional>
using namespace std;

long long N, M, A[1 << 18]; vector<long long>L;

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) cin >> A[i];
	sort(A, A + M);
	for (int i = 0; i < M - 1; i++) L.push_back(A[i + 1] - A[i]);
	sort(L.begin(), L.end());
	reverse(L.begin(), L.end());

	long long R = A[M - 1] - A[0];
	for (int i = 0; i < L.size(); i++) {
		if (i >= N - 1) break;
		R -= L[i];
	}
	cout << R << endl;
	return 0;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class AConsecutiveIntegers {
public:
        int n,k;
void solve(std::istream& cin, std::ostream& cout) {
    cin >> n >> k;
    cout << n - k + 1 << endl;
}
};


#undef int
int main() {
	AConsecutiveIntegers 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>
using namespace std;

int main(){

  string s, t;
  getline(cin, s);
  getline(cin, t);
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());

  for(int i=0; i<min(s.size(), t.size()); i++){
    if(s[i] > t[i]){
      cout << "No" << endl;
      return 0;
    }
    if(s[i] < t[i]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(s.size() < t.size()){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


// 190327


Measured memory_bytes: 256
using System;

class Program
{
	static void Main(string[] args)
	{
		string[] strInput = Console.ReadLine().Split(' ');
		int a = int.Parse(strInput[0]);
		int b = int.Parse(strInput[1]);
		int c = int.Parse(strInput[2]);
		int k = int.Parse(strInput[3]);

		int result = 0;
		if (a > k)
		{
			result = k;
			Console.WriteLine(result);
			return;
		}
		else
		{
			result = a;
			k -= a;
		}

		if (b > k)
		{
			Console.WriteLine(result);
			return;
		}

		k -= b;
		result -= k;
	
		Console.WriteLine(result);
		return;
	}
}

Measured memory_bytes: 27548
S = input()
if(S[0]=="A"):
    S = S[1::]
    SS = S[1:-1]
    if(SS.count("C") ==1):
        SS = SS.replace("C","c")
        S = S[0]+SS+S[-1::]
        if(S.islower()):
            print("AC")
        else:
            print("WA")
    else:
        print("WA")
else:
    print("WA")


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

int main() {
    long long int L,R; cin>>L>>R;
    long long int x = 2020, y = 2019;
    
    if(R - L > 672) x=0;
    else{
    for(long long int i=L;i<=R;++i){
        for(long long int j=i+1;j<=R;++j){
            x = min(x,(i*j)%y);
            if(x==0) break;
        }
    }
    }
    
    cout<<x<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int m;
double a, b;
double num[100100];
P ans[100100];

vector<int> prime;
bool is_prime[MAX_N + 1];

int sieve(int n) {//n??\???????´???°?????°?????????
	int p = 0;
	for (int i = 0; i <= n; i++)is_prime[i] = 1;
	is_prime[0] = is_prime[1] = 0;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			prime.push_back(i);
			for (int j = 2 * i; j <= n; j += i)is_prime[j] = 0;
		}
	}
	return p;
}

int main() {
	sieve(100000);
	fill(num, num + 100100, 0);
	rep(i, 100100)ans[i] = { -1,-1 };
	rep(i, prime.size()) {
		rep(j, i + 1) {
			double q = prime[i], p = prime[j];
			if (p*q <= 100000) {
				if (num[(int)(p*q)] < p / q) {
					num[(int)(p*q)] = p / q;
					ans[(int)(p*q)] = { p, q };
				}
			}
		}
	}
	while (cin >> m >> a >> b&&m + a + b) {
		for (int i = m; i >= 0; i--) {
			if (a / b < num[i] + EPS) {
				cout << ans[i].first << " " << ans[i].second << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 5660
use std::error::Error;
use std::io::{BufReader, Read};

const P: u32 = 1000000007;

fn main() {
    let mut s = String::new();
    let mut stdin = std::io::stdin();
    stdin.read_line(&mut s);
    let n: u32 = s.trim().parse().unwrap();
    println!("{}", n * (n + 1) >> 1);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
     
using namespace std;
typedef long long ll;
const int dinf=1000;
const int nmax=30; 
const int kmax=410; 


int DP[kmax][kmax];
char S[nmax][nmax];
 
int H,W,K;

char v(int i,int j){
    if (i < 1 || H < i || j < 1 || W < j){
        cout << "Error Line:" << __LINE__ << endl;
        exit(-1);
    }
    return S[i-1][j-1];
}

void print_v(){
    cout << H << endl;
    for(int i=1;i<=H; i++){
        for(int j=1; j<=W; j++){
            cout << v(i,j);
        }
        cout << endl;
    }
}

int index(int i,int j){
    if (i < 1 || H < i || j < 1 || W < j){
        cout << "Error Line:" << __LINE__ << endl;
        cout << i << "," << j << endl;
        exit(-1);
    }
    return (i-1)* W + j - 1;    
}

void print_DP(void){
    for(int i=0;i<K; i++){
        for(int j=0; j<K; j++){
            if(j!=0){ cout << ",";}
            if(DP[i][j] != dinf){
                cout << DP[i][j];
            } else {
                cout << ".";
            }
        }   
        cout << endl;
        if(i % W == W-1){
            cout << endl;
        }
    }
}

void init_DP(void){
    for(int k1=0; k1<K; k1++){
        for(int k2=0; k2<K; k2++){
            DP[k1][k2]=dinf;
        }
    }
    for(int i=1; i<=H; i++){
        for(int j=1; j<=W; j++){
            int k,l;
            int cost;
            k = index(i,j);
            DP[k][k] = 0; 
            if (i!= 1){ 
                l = index(i-1,j);
                if (v(i,j) != '#' && v(i-1,j)!= '#'){
                    cost = 1;
                    DP[k][l] = cost;
                }
                
            }

            if (i!= H){
                l = index(i+1,j);
                if (v(i,j) != '#' && v(i+1,j)!= '#'){
                    cost = 1;
                    DP[k][l] = cost;
                }
            }

            if (j!= 1){
                l = index(i,j-1);
                if (v(i,j) != '#' && v(i,j-1)!= '#'){
                    cost = 1;
                    DP[k][l] = cost;
                }
            }

            if (j!= W){
                l = index(i,j+1);
                if (v(i,j) != '#' && v(i,j+1)!= '#'){
                    cost = 1;
                    DP[k][l] = cost;
                } 
            }
            
        }
    }
}

void print_maxd(){
    int max=0;
    for(int i=0;i<K; i++){
        for(int j=0; j<K; j++){
            if (DP[i][j] != dinf && max < DP[i][j]){
                max = DP[i][j];
            }
        }
    }
    cout << max << endl;
}

void do_DP(){
    for(int k=0;k<K;k++){
        for(int i=0;i<K; i++){
            for(int j=0; j<K; j++){
                DP[i][j] = min(DP[i][j],DP[i][k]+DP[k][j]);
            }
        }
    }
}

int main() {
    int i,j; 
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> H >> W;
    K = H * W;
    // cout << H << "," << W << "," << K << endl; 
    i=0; 
    for(i=0; i< H; i++){
        int p,q;
        char s[30];
        cin >> s;
        strcpy(S[i],s);
        // cout << S[i] << endl; 
    }

    //print_v();
    init_DP();
    //print_DP();
    do_DP();
    // print_DP();
    print_maxd();
}




Measured memory_bytes: 896
N = int(input())
f = 0
b = 0
fb = 0
for i in range(N//3):
    f += (i+1)*3
for i in range(N//5):
    b += (i+1)*5
for i in range(N//15):
    fb += (i+1)*15
s = N*(N+1)/2
ans = s-(f+b-fb)
print(int(ans))

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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PN() putchar('\n')
#define PRINTARR(a,b) for(int i=0;(a+i)!=(b);i++){cout << *(a+i) << " ";}PN();
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define MT make_tuple

typedef pair<int, int> PII;
typedef tuple<int, int, int> T3I;
typedef long long LL;
typedef unsigned long long ULL;

void RI() {}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d", &head);
    RI(tail...);
}
void RLL() {}
template<typename... T>
void RLL( LL& head, T&... tail ) {
    scanf("%lld", &head);
    RLL(tail...);
}
void print() {putchar('\n');}
template<typename T, typename... U>
void print(T head, U... tail) {
    cout << head << " ";
    print(tail...);
}

const int MOD = 1000000007;
#define MAX_N 100005


int main()
{
    LL N;
    RLL(N);
    REP(h, 1, 3501) {
        REP(w, 1, 3501) {
            LL A = 4LL * h * w - N * (h + w);
            LL B = N * h * w;

            if(A > 0 and B > 0 and B % A == 0) {
                LL n = B / A;
                printf("%lld %d %d\n", n, h, w);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
list = tuple(map(int,input().split()))

a , b = 0 , abs(list[0]-list[1])

for i in range(2,N):
  d1 = a + abs(list[i]-list[i-2])
  d2 = b + abs(list[i]-list[i-1])
  a , b = b , d1 if d1 <= d2 else d2

print(b)

Measured memory_bytes: 14184
from collections import Counter

n = int(input())

def prime_factorize(n):
    i = 2
    temp = n
    result = []
    while(i * i <= n):
        count = 0
        while temp % i == 0:
            count += 1
            temp //= i
        if count > 0:
            result.append([i, count])
        i += 1
    if temp != 1:
        result.append([temp, 1])
    return result

c = Counter()
for i in range(1, n + 1):
    pf = prime_factorize(i)
    for p in pf:
        c[p[0]] += p[1]

count2 = 0
count4 = 0
count15 = 0
count25 = 0
count75 = 0
for i, v in c.items():
    if v >= 74:
        count75 += 1
    if v >= 24:
        count25 += 1
    if v >= 14:
        count15 += 1
    if v >= 4:
        count4 += 1
    if v >= 2:
        count2 += 1


b = count4 * (count4 - 1) * (count2 - 2) // 2
c = count15 * (count4 - 1)
d = count25 * (count2 - 1)
e = count75


print(b + c + d + e)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int N=305;
ll nw[N][N],a[N][N],fa[N],rnk[N];
int n;
ll sum;
struct Edge {
	int u,v,w;
};
vector <Edge> E;
bool cmp(Edge a,Edge b) {
	return a.w<b.w;
}
int find(int x) {
	if(x==fa[x]) return x;
	else return fa[x]=find(fa[x]);
}
int uni(int a,int b) {
	int f_a=find(a),f_b=find(b);
	if(f_a==f_b) return 0;
	if(rnk[f_a]<=rnk[f_b]) {
		fa[f_a]=f_b;
		if(rnk[f_a]==rnk[f_b])
			rnk[f_b]++;
	}
	else fa[f_b]=f_a;
}
int main() {
//	freopen("1.in","r",stdin);
	memset(nw,127/2,sizeof(nw));
	cin>>n;
	F(i,0,n) nw[i][i]=0,fa[i]=i;
	F(i,1,n) F(j,1,n) cin>>a[i][j];
	F(i,1,n) F(j,1,n) {
		if(a[i][j]!=a[j][i]) {cout<<-1;return 0;}
		if(i==j&&a[i][j]) {cout<<-1;return 0;}
	}
	F(i,1,n) F(j,i+1,n) E.push_back((Edge) {i,j,a[i][j]});
	sort(E.begin(),E.end(),cmp);
	int lim=E.size(),t=-1;
	F(i,1,n*(n-1)/2) {
		if(++t>=lim) break;
		int u=E[t].u,v=E[t].v,w=E[t].w;
		if(nw[u][v]<=w) continue;
		sum+=w;
		nw[u][v]=nw[v][u]=w;
		F(i,1,n) F(j,1,n) nw[i][j]=min(nw[i][j],min(nw[i][u]+w+nw[v][j],nw[i][v]+w+nw[u][j]));
		int pd=0;
		F(i,1,n) F(j,1,n) if(nw[i][j]!=a[i][j]) pd=1;
//		F(i,1,n){ F(j,1,n) printf("%lld ",nw[i][j]);cout<<"\n";}
//		cout<<endl;
		if(pd==1) continue;
		else break;
		if(t+1==lim) {cout<<"-1";return 0;}
		break;
//		else nw[E[t].u][E[t].v]=nw[E[t].v][E[t].u]=E[t].w,sum+=E[t].w;
	}
//	F(k,1,n) 
//		F(i,1,n)
//			F(j,1,n)
//				nw[i][j]=min(nw[i][j],nw[i][k]+nw[k][j]);
//	F(i,1,n) F(j,1,n) if(nw[i][j]!=a[i][j]) {cout<<-1;return 0;}
	int pd=0;
		F(i,1,n) F(j,1,n) if(nw[i][j]!=a[i][j]) pd=1;
	if(pd==1) cout<<-1;
	else cout<<sum;
	return 0;
}

Measured memory_bytes: 2556
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define int ll
//struct edge {int to,cost;};

signed main(){
    int n,h;
    cin >> n >> h;
    P v[114514];
    int Marx=-INF,Engels;
    REP(i,n){
        int tm,p;
        scanf("%lld%lld",&tm,&p);
        if(Marx<tm){
            Marx = tm;
            Engels = p;
        }
        v[i] = MP(p,tm);
    }
    int sum = 0,num = 0;
    sort(v,v+n);
    RREP(i,n){
        if(v[i].FI<Marx) break;
        /*if(v[i].fi==Engels){
            Engelse = -1;
            continue;
        } else {*/
            h -= v[i].FI;
            num++;
            if(h<=0){
                printf("%lld\n",num);
                return 0;
            }
        //}
    }
    printf("%lld\n",num+(h+Marx-1)/Marx);

    return 0;
}


Measured memory_bytes: 1152
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
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;
}
//

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

  int k, x;
  cin >> k >> x;

  int b = max(-1000000, x - k + 1);
  int e = min(1000000, x + k - 1);
  for (int i = b; i <= e; i++) {
    cout << i << (i != e ? " " : "");
  }

  cout << "\n";

  return 0;
}

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

using namespace std;

int main() {
	string s;
	cin >> s;
	int t = 0;
	if (s[0] == 'o') t += 100;
	if (s[1] == 'o') t += 100;
	if (s[2] == 'o') t += 100;
	cout << 700 + t << endl;
	return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define LL unsigned long long
#define sigma_size 30
#define max_size (int)(1e6+10)
#define MAX (int)(1e5+7)

int main ()
{
	LL s;
	scanf ( "%lld",&s );
	int a , b , c , d;
	a = d = (int)sqrt(s);
	b = c = 0;
	while ( s > 1ll * a * d ){
		if ( a < d ) a++;
		else d++;
	}
	LL k = 1ll * a * d - s;
	for ( int i = 1 ; i <= sqrt(k) ; i++ )
	{
		if ( k % i == 0 )
		{
			if ( i <= 1e9 && k / i <= 1e9 ){
				b = i;
				c = k / i;
				break;
			}
		}
	}
	printf ( "0 0 %d %d %d %d\n",a,b,c,d );
	return 0;
}

Measured memory_bytes: 3704
N = int(input())
l = map(int, input().split())

dic = {}
for num in l:
    dic.setdefault(num, 0)
    dic[num]+=1

result = 0
for k, v in dic.items():
    if k > v:
        result = result + v
    elif k < v:
        result += (v - k)

print(result)


Measured memory_bytes: 23284
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;
int main() {
	string s;
	cin >> s;

	int a = 0, b = 0;
	for (int i = 0; i < s.size(); i += 2) {
		if (s.at(i) == '0') b++;
		else a++;
	}
	for (int i = 1; i < s.size(); i += 2) {
		if (s.at(i) == '1') b++;
		else a++;
	}
	cout << min(a, b) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long MOD = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

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

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

int main()
{
  int n;
  cin >> n;
  int x[n];

  rep(i, n) {
    cin >> x[i];
  }

  ll ans = INF;

  repi(i, 1, 101) {
    ll power = 0;

    rep(j, n) {
      power += pow(x[j] - i, 2);
    }
    ans = min(ans, power);
  }

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

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

int main() {
     
    ll n; cin >> n;    
    ll tmp = n;
    ll sum = 0;
    while (0 < tmp) {      
        sum += tmp % 10;
        tmp /= 10;
    }

    if (n % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
//	freopen("input.txt","r",stdin);
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	while(c<=10000){
		if(c%a==0){
			printf("YES\n");
			return 0;
		}
		c+=b;
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
int main() {
	ll n,i;
	cin>>n;ll a[n],s=0;
	fr(i,0,n)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	s+=a[n-1];ll c=0,d=n-2;n--;
	while(c!=d)
	{
	if(c%2==0 && c!=0)
	{
		n--;
	}
	s+=a[n-1];
	
	c++;	
	}
	cout<<s;
	return 0;
}


Measured memory_bytes: 5132
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

struct job {
	ll A, B;
	bool operator < (const job& b)const {
		return B < b.B;
	}
};
job J[200010];
int main() 
{
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> J[i].A >> J[i].B;
	}
	sort(J, J + N);
	ll time = 0;
	for (int i = 0; i < N; i++) {
		time += J[i].A;
		if (time > J[i].B) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	vector<int> arr;
	for(int i=0; i<n; i++) {
		int t;
		cin >> t;
		if(t-1 > arr.size())
			return !(cout << -1);
		arr.insert(arr.begin()+t-1, t);
	}
	for(int i: arr)
		cout << i << '\n';
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int num, h, m, s;
    cin >> num;
    h = num / 3600;
    m = (num % 3600) / 60;
    s = num % 3600 % 60;
    cout << h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 3088
#include <iostream>
#include <vector>

using namespace std;
using pint = pair<int,int>;

int N;
vector<vector<pint>>v;

bool judge(int bit)
{
    for(int i = 0; i < N;i++)
    {
        if(!(bit & (1<<i)))
        {
            continue;
        }
        for(pint xy : v[i])
        {
            int x = xy.first;
            int y = xy.second;
            if((y == 1) && !(bit&(1<<x)))
            {
                return false;
            }
            if((y == 0) && (bit&(1<<x)))
            {
                return false;
            }
        }
    }
    return true;
}

int main()
{
    cin >> N;
    v.resize(N);
    for(int i = 0; i < N;i++)
    {
        int A; cin >> A;
        v[i].resize(A);
        for(int j = 0; j < A;j++)
        {
            cin >> v[i][j].first >> v[i][j].second;
            --v[i][j].first;
        }
    }
    int res = 0;
    for(int bit = 0; bit < (1<<N);bit++)
    {
        if(judge(bit))
        {
            int count = 0;
            for(int i = 0; i < N;i++)
            {
                if(bit&(1<<i))
                {
                    count++;
                }
            }
            res = max(res,count);
        }
    }
    cout << res << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> p(100009);
  for(int i=1;i<=N;i++)cin >> p[i];
  int count=0;
  for(int i=1;i<=N;i++){
    if(p[i]==i){
      count++;
      if(i<=N-1 && p[i+1]==i+1){i++;}
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3620
h, w, m = map(int, input().split())
target_points = {tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)}

row_points = [0] * h
col_points = [0] * w
for row, col in target_points:
    row_points[row] += 1
    col_points[col] += 1

row_max = max(row_points)
col_max = max(col_points)

row_max_indexes = [i for i in range(h) if row_points[i] == row_max]
col_max_indexes = [i for i in range(w) if col_points[i] == col_max]

empty_crossing_exist = False
for row in row_max_indexes:
    for col in col_max_indexes:
        if (row, col) not in target_points:
            empty_crossing_exist = True
            break
    if empty_crossing_exist:
        break

print(row_max + col_max - (not empty_crossing_exist))


Measured memory_bytes: 83496
#include <iostream>
#include <cmath>
#include <limits>

using namespace std;

int getNumberOfDigits(unsigned long long n) {
    size_t number_of_digits = 0;
    while (n > 0) {
        ++number_of_digits;
        n /= 10;
    } 
    return number_of_digits;
}

int main() {
    unsigned long long n;
    cin >> n;
    int result = numeric_limits<int>::max();
    for (unsigned long long a = 1; a <= sqrt(n); ++a) {
        if (n % a != 0) continue;
        int f = max(getNumberOfDigits(a), getNumberOfDigits(n / a));
        if (f < result) result = f;
    }
    cout << result << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int m=0 ,f=0 ,r=0 ;

    while(1){
        scanf("%d%d%d",&m ,&f ,&r);

        if ((m==-1 && f==-1) && r==-1) break;

        if (m==-1 || f==-1){
            printf("F\n");
        } else if ((m+f)>=80){
            printf("A\n");
        } else if ((m+f)>=65){
            printf("B\n");
        } else if ((m+f)>=50){
            printf("C\n");
        } else if ((m+f)>=30 && r>=50){
            printf("C\n");
        } else if ((m+f)>=30 && r<50){
            printf("D\n");
        } else if ((m+f)<=30){
            printf("F\n");
        }


    }

    return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int a[m];
    int sum = 0;
    for (int i=0; i<m; i++){
        cin >> a[i];
        sum += a[i];
    }
    if (n < sum){
        cout << -1 << endl;
    }
    else{
        cout << n-sum << endl;
    }
}

Measured memory_bytes: 3672
def main():
    import sys
    input = sys.stdin.readline
    #n = int(input())
    #l = list(map(int, input().split()))
    '''
    a=[]
    b=[]
    for i in range():
        A, B = map(int, input().split())
        a.append(A)
        b.append(B)'''

    n,m=map(int, input().split())
    l=[[]for _ in range(n)]
    cnt=0

    for i in range(m):
        A,B = map(int, input().split())
        l[A-1].append(B-1)
        l[B-1].append(A-1)

    v=[]
    for i in range(n):
        le=len(l[i])
        if le%2!=0:#euler
            print("No")
            return
        if le>=4:
            v.append(i)
    #e>6>4
    for item in v:
        if len(l[item])>=6:
            print("Yes")
            return
    ll=len(v)
    if ll<2:#4*1~0
        print("No")
        return
    elif ll>2:
        print("Yes")
        return

    s,e=v #4*2
    for item in l[s]:
        p=s
        n=item

        while n!=e:
            for jtem in l[n]:
                if jtem!=p:
                    p,n=n,jtem
                    break
            
            if n==s:
                print("Yes")
                sys.exit()

    print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 21080
using System;
class Program
{
    private bool IsAllEven(int[] num)
    {
        int f = 0;
        for (int i = 0; i < num.Length; i++)
        {
            if (num[i] % 2 != 0)
            {
                f = 1;
                break;
            }
        }
        return (f == 0) ? true : false;
    }
    public static void Main()
    {
        Program prog = new Program();
        int n = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = int.Parse(str[i]);
        int c = 0;
        while (prog.IsAllEven(a))
        {
            for (int i = 0; i < a.Length; i++)
                a[i] = a[i] / 2;
            c++;
        }
        Console.WriteLine(c);
    }
}

Measured memory_bytes: 11092
import java.util.Arrays;
import java.util.Scanner; // 文字列を標準入力からscanする

public class Main { 

  static long return_smaller(long a, long b){
    if(a > b){
      return b;
    }
      return a;
  }

  static long return_bigger(long a, long b){
    if(a > b){
      return a;
    }
      return b;
  }
    
  public static void main(final String[] args) {
    int N = 0;
    int i = 0;
    int j = 0;
    int k = 0;

    Scanner scan = new Scanner(System.in);
		String str = "";
    str = scan.nextLine();

    N = Integer.parseInt(str);
    
    int[][] a = new int[N+1][3];

    for(i=1; i<=N; i++){
      str = scan.nextLine();
      String[] strs2 = str.split(" ");
      a[i][0] = Integer.parseInt(strs2[0]);
      a[i][1] = Integer.parseInt(strs2[1]);
      a[i][2] = Integer.parseInt(strs2[2]);
    }
    scan.close();

    int init = 0;
    long[][] dp = new long[N+1][3];
    for(i=0; i<N; i++){
      Arrays.fill(dp[i], init);
    }

    for(i=1; i<=N; i++){
      for(j=0; j<3; j++){
        for(k=0; k<3; k++){
          if(j != k){
            dp[i][j] = return_bigger(dp[i][j], dp[i-1][k] + a[i][j]);
          }
        }
      }
    }

    long dpN_max = 0;
    for(i=0; i<3; i++){
      dpN_max = return_bigger(dpN_max, dp[N][i]);
    }

    System.out.println(dpN_max);

  }
}

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

int main(){
  int n,a,b;
  cin >> n >> a;
  b = n % 500;
  if(b<=a) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int A, B;
    cin >> A >> B;
    
    // calculation
    if (A == B) {
        cout << "Draw" << "\n";
    } else if (A == 1 || B == 1) {
        if (A == 1) {
            cout << "Alice" << "\n";
        } else if (B == 1) {
            cout << "Bob" << "\n";
        } else {
            string res = (A > B) ? "Alice": "Bob";
            cout << res << "\n";
        }
    } else {
        string res = (A > B) ? "Alice": "Bob";
        cout << res << "\n";
    }
    
    return 0;
}


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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define LL              long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

const LL MOD=1e9+7;
LL fact[100005];
LL BigMod(LL B,LL P,LL M)
{
    LL R=1;
    while(P>0)
    {
        if(P & 1)
            R=(R*B)%M;
        P=P>>1;
        B=(B*B)%M;
    }
    return R%M;
}

LL nCr(LL n,LL r){
    LL up=fact[n];
    LL dn=(fact[r]*fact[n-r])%MOD;
    dn=BigMod(dn,MOD-2,MOD);
    return (up*dn)%MOD;
}

int main()
{
    fact[0]=1;
    FOR(i,1,100004) fact[i]=(fact[i-1]*i)%MOD;
    int n,k;
    cin >> n >> k;
    LL arr[n+10];
    FOR(i,1,n) cin >> arr[i];
    sort(arr+1,arr+n+1);
    LL ans=0,cnt=1;
    FOR(i,k,n)
    {
        ans+=(arr[i]*nCr(cnt+k-2,k-1))%MOD;
        cnt++;
        ans%=MOD;
    }
    cnt=1;
    ROF(i,n-k+1,1)
    {
        ans-=(arr[i]*nCr(cnt+k-2,k-1))%MOD;
        cnt++;
        ans=(ans%MOD+MOD)%MOD;
    }
    cout << ans;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	double d;
	int c=0,l[4]={},r[4]={},e;
	while(cin>>d){
		//if(d==0) break;
		c++;
		if(d>=1.1) e=0;
		else if(d>=0.6) e=1;
		else if(d>=0.2) e=2;
		else e=3;
		if(c%2) l[e]++;
		else r[e]++;
	}
	rep(i,0,4){
		o(l[i]<<" "<<r[i]);
	}
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define mod 1000000007
int32_t main()
{
    int n;
  cin>>n;
  string a,b;
  cin>>a>>b;
  int i;
  for(i=0;i<n;i++)
  {
    cout<<a[i]<<b[i];
  }
  cout<<endl;
    return 0;
    
}

Measured memory_bytes: 256
from collections import deque
n,c,k=map(int,input().split())
l=sorted([int(input()) for _ in range(n)],reverse=True)
ans=0
d=deque(l)
while len(d)!=0:
    ans+=1
    t=d.popleft()
    cnt=1
    while len(d)!=0 and d[0]>=t-k and cnt<c:
        d.popleft()
        cnt+=1
print(ans)

Measured memory_bytes: 8612