akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    string x; cin >> x;
    ll n = x.size();
    stack<char> st;
    rep(i,n){
        if(st.empty()) st.push(x[i]);
        else{
            if(st.top() == 'S'){
                if(x[i] == 'T') st.pop();
                else st.push(x[i]);
            }else{
                st.push(x[i]);
            }
        }
    }
    cout << st.size() << endl;
}

Measured memory_bytes: 644
#include<iostream>

using namespace std;

int main() {
	int N;
	int A[1000];
	cin >> N;

	auto print = [&A, N]() {
		for (int i = 0; i < N; ++i) {
			cout << A[i];
			if (i < N - 1) {
				cout << ' ';
			}
			else {
				cout << endl;
			}
		}
	};

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

	print();

	for (int i = 1; i < N; ++i) {
		int v = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		print();
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  int sum=0;
  vector<int> C(N);
  for(int i=0; i<N; i++)cin >> A[i];
  for(int i=0; i<N; i++){int x; cin >> x; sum+=x;}
  for(int i=0; i<N-1; i++)cin >> C[i];
  for(int i=0; i<N-1; i++){
    if(A[i]+1==A[i+1])sum+=C[A[i]-1];
  }
  cout << sum << endl;
  return 0;
}

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

INF = float('inf')

"""
S = input()
N = int(input())
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
D = [input() for _ in range(N)]
"""

def main():
    N = int(input())
    D = [int(input()) for _ in range(N)]
    D = sorted(list(set(D)), reverse=True)

    print(len(D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
n = int(input())
g = []
for i in range(n):
    g.append([int(i) for i in input().split()])
q = int(input())
EPS = 0.001
def dot(a, b):
    return sum([i * j for i,j in zip(a, b)])
def sub(a, b):
    return [a[0] - b[0],a[1] - b[1]]
def cross(a, b):
    return  a[0] * b[1] - a[1] * b[0]
def contains(g, p):
    x = False
    for i in range(n):
        a = sub(g[i], p)
        b = sub(g[(i+1)%n], p)
        if abs(cross(a, b)) < EPS and dot(a, b) < EPS: 
            return 1
        if a[1] > b[1]:
            a,b=b,a
        if a[1] < EPS and EPS < b[1] and cross(a,b) > EPS:
            x = not x
    return 2 if x else 0
for i in range(q):
    x,y = map(int, input().split())
    print(contains(g, [x,y]))



Measured memory_bytes: 5644
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){

	string findStr;
	int n;

	cin >> findStr;
	cin >> n;

	int cnt = 0;
	for(int i = 0; i < n; i++){
		string str;
		cin >> str;
		// ツ開ツ始ツ地ツ点ツづーツづつアツづ可つキツづゥツつゥ
		for(int j = 0; j < str.size(); j++){
			// ツ各ツ閉カツ篠堋づ可づつつ「ツづづ敖づつ「ツつュ
			bool f = false;
			for(int k = 0; k < findStr.size(); k++){
				if(findStr[k] != str[(k+j)%str.size()]){
					f = true;
					break;
				}
			}
			if(!f){
				cnt++;
break;
			}
		}
	}
	cout << cnt << endl;

	int x;
	cin >> x;

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void)
{
  char s[2][3]={};
  int i,j,flag=1;
  for(i=0;i<2;i++)
  {
    scanf("%s",s[i]);
  }
  i=0;
  for(j=0;j<3;j++)
  {
    if(s[i][j]!=s[1][2-j])
    {
      flag=0;
      break;
    }
  }
  if(flag)
  {
    printf("YES\n");
  }
  else
  {
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
const int N = 10000;
int main()
{
	int a[N] = {0}, n, max = -1000001, min = 1000001;
	
	long long sum = 0;
	
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		if(a[i] > max)
		{
			max = a[i];
		}
		if(a[i] < min)
		{
			min = a[i];
		}
		sum += a[i];
	}
	printf("%d %d %lld\n", min, max, sum);
	
	
	
	
	
	return 0;
} 


Measured memory_bytes: 2796
#include<iostream>
#include<string>
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;



int main()
{
	int f=0;
	string N;
	cin >> N;
	for (unsigned int i = 0; i < N.size(); i++)
	{
		f += N[i] - '0';
	}
	string str = (stoi(N) % f == 0) ? "Yes" : "No";
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	int sum = 0;
	for (auto c : s) { sum += (int)(c - '0'); }
	cout << (sum % 9 == 0 ? "Yes" : "No") << "\n";

	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>

#define llong long long
#define rep(i,l,n) for(llong (i)=(l);(i)<(n);(i++))
#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
#define _abs(a) ((a)>0?(a):(-(a)))

using namespace std;

int main(){
	string s,t;
	cin >> s >> t;
	int N = s.size(),n = t.size();
	int ans = 1000;
	rep(i,0,N-n+1){
		int cnt = 0;
		rep(j,0,n){
			if( s[i+j] != t[j] ) cnt++;
		}
		ans = _min(ans,cnt);
	}
	
	cout << ans;
	
	return 0;
}


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

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

  deque<int> deq;

  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    if(i % 2 == N % 2){
      deq.push_back(a);
    }
    else{
      deq.push_front(a);
    }
  }

  for(int i = 0; i < N; i++){
    if(i == 0){
      cout << deq[i];
    }
    else{
      cout << " " << deq[i];
    }
  }

  return 0;
}


Measured memory_bytes: 2944
import math
import itertools
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
cnt = 0
for i in range(N):
    for j in range(i+1, N):
        cnt += bisect.bisect_left(L[j+1:N], L[i]+L[j])
        
print(cnt)

Measured memory_bytes: 52000
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { lhs = rhs; return true; }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { lhs = rhs; return true; }
  return false;
}

struct range {
  struct itr {
    int64_t i;
    constexpr itr(int64_t i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int64_t operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int64_t l_, int64_t r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

struct revrange {
  struct itr {
    int64_t i;
    constexpr itr(int64_t i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int64_t operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int64_t l_, int64_t r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

int main() {
  u64 N;
  std::cin >> N;
  u32 ans = 0;
  for (u64 x = 2; x * x <= N; ++x) {
    if (N % x == 0) {
      u32 cnt = 0;
      while (N % x == 0) {
        N /= x;
        ++cnt;
      }
      u32 cur = 1;
      while (true) {
        if (cnt < cur) {
          break;
        }
        cnt -= cur;
        ++ans;
        ++cur;
      }
    }
  }
  if (N > 1) {
    ++ans;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
 
struct Team{
    int id,ac,pn;
    vi wa=vi(11);
};
 
int main(void){
    int m,t,p,r;
    while(cin>>m>>t>>p>>r,t){
        deque<Team> team(t+1);
        rep(i,t)team[i+1].id=i+1;
        rep(i,r){
            int tm,id,num,res;
            cin>>tm>>id>>num>>res;
            if(res==0){
                team[id].ac++;
                team[id].pn+=team[id].wa[num]*20+tm;
            }else{
                team[id].wa[num]++;
            }
        }
        team.pop_front();
        sort(all(team), [](Team a,Team b){return a.ac>b.ac || (a.ac==b.ac&&(a.pn<b.pn || (a.pn==b.pn&&a.id>b.id))); });
        rep(i,t){
            cout<<team[i].id<<(i+1==t ? "" : (team[i].ac==team[i+1].ac&&team[i].pn==team[i+1].pn?"=":","));
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3120
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if V <= W:
    # 追いつけない
    print("NO")
else:
    dx = abs(A - B)
    dv = V - W
    t = dx / dv
    if t <= T:
        print("YES")
    else:
        print("NO")



Measured memory_bytes: 9176
/*
PROG: abc079c
LANG: C++
    _____
  .'     '.
 /  0   0  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
 */
#include <bits/stdc++.h>

using namespace std;

long long readi()
{
	long long input = 0;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	bool negative = false;
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = 10 * input + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	return input;
}
void printi(long long output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
string reads()
{
	string input = "";
	char c = ' ';
	while (c <= ' ')
	{
		c = getchar();
	}
	while (c > ' ')
	{
		input += c;
		c = getchar();
	}
	return input;
}
void prints(string output)
{
	for (int i = 0; i < output.length(); i++)
	{		
		putchar(output[i]);
	}
	return;
}
int sgn(long long x)
{
	if (x < 0) 
	{
		return -1;
	}
	if (x > 0) 
	{
		return 1;
	}
	return 0;
}
long long randomize(long long x)
{
	return (((1ll << 31) * rand()) + rand()) % x;
}

#define MP make_pair
#define PB push_back
#define PF push_front
#define MT make_tuple
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second

#define SINF 10007
#define MOD 1000000007
#define INF 1000000861
#define LLINF 1000000000000000861ll
#define CO 1000861
#define EPS 0.000000000000001
#define PI 3.141592653589793

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

string s;
int A[4];

int32_t main()
{
	ios_base::sync_with_stdio(false);
	srand(time(NULL));
	//	cout << fixed << setprecision(10);	
	//	cerr << fixed << setprecision(10);
	//	if (fopen("abc079c.in", "r"))
	//	{	
	//		freopen ("abc079c.in", "r", stdin);
	//		freopen ("abc079c.out", "w", stdout);
	//	}
	cin >> s;
	A[0] = s[0] - '0';
	A[1] = s[1] - '0';
	A[2] = s[2] - '0';
	A[3] = s[3] - '0';
	for (int mask = 0; mask < 8; mask++)
	{
		int val = A[0];
		//		cerr << val << endl;
		for (int j = 1; j < 4; j++)
		{
			if (mask & (1 << (j - 1)))
			{
				val += A[j];
			}
			else
			{
				val -= A[j];
			}
		}
//		if (mask == 7)
//		{
//			cerr << val << endl;
//		}
		//		cerr << val << endl;
		if (val == 7)
		{
			cout << A[0];
			for (int j = 1; j < 4; j++)
			{
				if (mask & (1 << (j - 1)))
				{
					cout << '+' << A[j];
				}
				else
				{
					cout << '-' << A[j];
				}
			}
			cout << "=7\n";
			return 0;
		}
	}
	assert(false);
	return 0;
}


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

if N != 0:
  plist = list(map(int,input().split()))
  plistnew = []
  plistno = []
  anslist = []
  abslist1 = []
  abslist2 = []
  
  for i in range(-5,105):
    plistnew.append(i)
  
  for j in plistnew:
    if j in plist:
      pass
    else:
      plistno.append(j)

  for k in plistno:
    abslist1.append(X-k)
    abslist2.append(abs(X-k))
  
  minabs = min(abslist2)

  for l in range(len(abslist2)):
    if abslist2[l] == minabs:
      anslist.append(plistno[l])
  print(min(anslist))
  
if N == 0:
  print(X)

Measured memory_bytes: 9224
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#define LINF 1e18
#define INF 1e9 + 7

using namespace std;

int main() {
  int N;
  cin >> N;
  int a[200100];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int count = 1;
  for (int i = 0; i < N; i++) {
    if (a[i] == count) {
      count++;
    }
  }
  if (N - (count - 1) == N) {
    cout << -1 << endl;
  } else {
    cout << N - (count - 1) << endl;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:
const int limit = 100010;
vector<int> tree[limit];
int dist[limit],prv[limit];

void dfs(int v,int p,int d){
	dist[v] = d;
	prv[v] = p;
	for(auto &v2:tree[v]){
		if(v2 == p) continue;
		dfs(v2,v,d+1);
	}
}

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

	rep(i,n-1){
		int a,b;
		cin >> a >> b;
		tree[a-1].push_back(b-1);
		tree[b-1].push_back(a-1);
	}

	dfs(0,-1,0);
	int root = 0;
	rep(i,n) if(dist[root] < dist[i]) root = i;

	dfs(root,-1,0);
	int farthest = 0;
	rep(i,n) if(dist[farthest] < dist[i]) farthest = i;

	vector<int> order;
	int cur = farthest;
	
	order.push_back(0);
	cur = prv[cur];

	while(cur != root){
		order.push_back(tree[cur].size() - 2);
		cur = prv[cur];
	}

	order.push_back(0);

	int cnt = 0;
	for(auto &elem:order) cnt += elem + 1;

	if(cnt != n){
		cout << -1 << endl;
		return 0;
	}

	bool rev = false;
	const int m = order.size();
	rep(i,m){
		if(order[i] != order[m-1-i]){
			if(order[i] > order[m-1-i]) rev = true;
			break;
		}
	}

	if(rev) reverse(begin(order),end(order));

	vector<int> ans;
	int start = 1;
	for(auto &elem:order){
		const int num = elem + 1;
		rep(loop,num-1) ans.push_back(start + 1 + loop);
		ans.push_back(start);
		start += num;
	}

	rep(i,n) cout << (i?" ":"") << ans[i];
	cout << endl;


	return 0;
}

Measured memory_bytes: 12664
import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  var n = 0
  while( {n=readLine.trim.toInt;n} != 0 ) {
    val b = new ArrayBuffer[String]
    var convert = for(i<-1 to n) yield readLine.trim.split(" ").toList
    val m = readLine.trim.toInt
    for(i<-1 to m) {
      val s = readLine.trim
      b += convert.find{ _(0) == s }.map{ _(1) }.getOrElse(s)
    }
    println(b.mkString)
  }
}

Measured memory_bytes: 77120
#include <iostream>

using namespace std;

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


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

#define COUT(x) cout << #x << " = " << (x) << ", "
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
typedef long long ll;
const int MOD = 1000000007;

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  if((10 * g + b) % 4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n, m, a, b, i, c[50];

    scanf("%d %d", &n, &m);
    for (i = 0; i < n; i++) {
        c[i] = 0;
    }
    for (i = 0; i < m; i++) {
        scanf("%d %d", &a, &b);
        c[a - 1]++;
        c[b - 1]++;
    }
    for (i = 0; i < n; i++) {
        printf("%d\n", c[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	string str;
	cin >> str;
	if(str.back() == 's') str += "es";
	else str += "s";
	cout << str << '\n';
}



Measured memory_bytes: 3648
from math import gcd

n = int(input())
a = list(map(int,input().split()))


gcd_num = a[0]
for ai in a[1:]:
    gcd_num = gcd(gcd_num,ai)

if(gcd_num > 1):
    print('not coprime')
    exit()

def sieve(n):
    if( n <= 1):
        return []
    elif(n==2):
        return [2]

    primes = [2]
    len_list = (n+1)//2
    len_sqrt = int(len_list**0.5) + 1
    flags = [True] * len_list
    flags[0] = False
    for i in range(len_sqrt):
        if(flags[i]):
            start = ((i*2+1)**2)//2
            for j in range( start, len_list, i*2+1):
                flags[j] = False
    return [2] + [i*2+1 for i in range(len_list) if flags[i]]

p_6 = set(sieve(10**6))
p_3 = sieve(10**3)

use = [0] * (10**6+1)

for ai in a:
    if(ai==1):
        continue
    divs = []
    for p in p_3:
        if(ai%p==0):
            divs.append(p)
            while(ai%p==0):
                ai//=p
    if(ai != 1):
        divs.append(ai)

    for di in divs:
        if(use[di] != 0):
            print('setwise coprime')
            exit()
        use[di] = 1

print('pairwise coprime')

Measured memory_bytes: 190632
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;     
int main(){
	fastIO;                                  
	long long a,b,x;
	cin>>a>>b>>x;
	--a;
	long long cnt=(b/x)-(a/x);
	if(a == -1 && x>1){
		cnt++;
	}
	cout<<cnt<<'\n';
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    vector<bool> used(128, false);
    for(char c : s){
        if(used[c]){
            cout << "no" << endl;
            return 0;
        }
        used[c] = true;
    }

    cout << "yes" << endl;
    return 0;
}


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

int K;
vector<int> n(100000,100000);
deque<int> deq;

int BFS(){
	while(!deq.empty()){
		int f=deq.front();
		deq.pop_front();
		if(f==0)return n[0];
		if(n[f]<n[(f*10)%K]){
			n[(f*10)%K]=n[f];
			deq.push_front((f*10)%K);
		}
		if(n[f]+1<n[(f+1)%K]){
			n[(f+1)%K]=n[f]+1;
			deq.push_back((f+1)%K);
		}
	}
}

int main(){
	cin >> K;
	deq.push_back(1);
	n[1]=1;
	cout << BFS() << endl;
	return 0;
}

Measured memory_bytes: 896
<?php
$engArray = array(
    'A' => 1,
    'B' => 2,
    'C' => 3,
    'D' => 4,
    'E' => 5,
    'F' => 6,
    'G' => 7,
    'H' => 8,
    'I' => 9,
    'J' => 10,
    'K' => 11,
    'L' => 12,
    'M' => 13,
    'N' => 14,
    'O' => 15,
    'P' => 16,
    'Q' => 17,
    'R' => 18,
    'S' => 19,
    'T' => 20,
    'U' => 21,
    'V' => 22,
    'W' => 23,
    'X' => 24,
    'Y' => 25,
    'Z' => 26
);

// キーと値を入れ替えた配列も用意
$numArray = array_flip($engArray);

// 標準入力を一行ずつ配列に代入
while ($line = fgets(STDIN)) {
    $stdin[] = trim($line);
}

// 加算する分の数字
$addCount = $stdin[0];
foreach (str_split($stdin[1]) as $value) {
    // 加算前の英字の数字と加算数値を加算
    $AnsCount = $engArray[$value] + $addCount;
	
    while ($AnsCount) {
        // AnsCountが26以下になるまで26を引き続ける
        if ($AnsCount <= 26) {
            break;
        }
        $AnsCount = $AnsCount - 26;
    }
    echo $numArray[$AnsCount];
}
echo "\n";


Measured memory_bytes: 5364
N , M = map(int, input().split())
A = sorted([int(input()) for _ in range(M)])

Flag = [True for _ in range(N+1)]
for a in A:
    Flag[a] = False

Dp = [0 for _ in range(N+1)]

Dp[0] = 1
if 1 not in A:
    Dp[1] = 1
for i in range(N-1):
    if Flag[i+2]:
        Dp[i+2] = (Dp[i] + Dp[i+1])%(10**9+7)
print(Dp[-1])

Measured memory_bytes: 92192
n , m = map(int, input().split())
a = list(map(int,input().split()))
a.sort()
bc=[]
for i in range(m):
    b , c = map(int, input().split())
    bc.append((b,c))
bc.sort(key = lambda x : x[1],reverse=True)

t=0
for i in range(m):
    b,c=bc[i]
    if t>=n:
        break
    if a[t]>=c:
        break
    for j in range(b):
        if a[t]<c:
            a[t]=c
            if t<n-1:
                t+=1
        else:
            break
print(sum(a))


Measured memory_bytes: 22508
using System;
using System.Linq;

class B
{
	static void Main() { foreach (var x in Enumerable.Range(1, int.Parse(Console.ReadLine())).Select(i => ($"{i} " + Console.ReadLine()).Split()).OrderBy(x => x[1]).ThenByDescending(x => int.Parse(x[2]))) Console.WriteLine(x[0]); }
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, ans = 0, tans = 0;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  deque<ll> dq;
  rep(i, n) dq.push_back(a[i]);

  for (int i = 0; i < 2; ++i) {
    ll r = dq.front();
    ll l = r;
    dq.pop_front();
    ans = 0;
    while (dq.size()) {
      ll b = dq.back();
      ll f = dq.front();
      ll mx = max({abs(r - b), abs(r - f), abs(l - b), abs(l - f)});
      ans += mx;
      if (mx == abs(r - b))
        r = b, dq.pop_back();
      else if (mx == abs(l - b))
        l = b, dq.pop_back();
      else if (mx == abs(r - f))
        r = f, dq.pop_front();
      else if (mx == abs(l - f))
        l = f, dq.pop_front();
    }
    rep(i, n) dq.push_front(a[i]);
    tans = max(tans, ans);
  }

  cout << tans << endl;
  return 0;
}


Measured memory_bytes: 1848
#include <iostream>
using namespace std;
int main(){
    int h, w;
    cin >> h >> w;
    while (h!=0){
        for (int i = 0;i < h;i++){
            for (int j = 0;j < w;j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
    return 0;
    
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
 
const int MOD = 1000000007;
const int N = 100005;
const int M = 1000005;
 
#define ll                      long long int
#define loop(i,a,b)             for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)            for(int i=(int)a;i<=(int)b;++i)
#define loopl(i,a,b)            for(ll i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)            for(int i=(int)a;i>=(int)b;--i)
#define pb                      push_back
#define F                       first
#define S                       second
#define mp                      make_pair
#define RALL(x)                 x.rbegin(),x.rend()
#define ALL(x)                     x.begin(),x.end()
#define MAX                     1e9
#define MIN                     -1e9
#define max(x,y)                (x>y)?x:y
#define min(x,y)                (x<y)?x:y
#define mid(l,r)                (l+(r-l)>>1)
#define mina(a)                    *min_element(a.begin(), a.end())
#define maxa(a)                    *max_element(a.begin(), a.end())
#define PI                      acos(-1.0)

typedef  map<string,int>         msi;
typedef  map<int,int>             mii;
typedef  map<ll, ll>             mll;
typedef  map<char,int>           mci;
typedef  map<int,string>         mis;
typedef  pair<int,int>              pii;
typedef  pair<string, int>       psi;
typedef  pair<string, string>    pss;
typedef  vector<int>              vi;
typedef  vector<string>          vs;
typedef  vector<char>             vc;
typedef  vector<bool>            vb;
typedef  vector< pii >           vii;

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n; cin>>n;
    if(n==1) return 0;
    int dp[n+1];
    memset(dp, 0, sizeof(dp));

    int h[n+5];
    loop(i,0,n)
        cin>>h[i];

    dp[1] = abs(h[1]-h[0]);
    loop(i,2,n)
    {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    ll a,b,c;
    cin >> a >> b >> c;
    // 2*sqrt(ab)  < c - a - b
    // 4*ab < (c-a-b)^2
    if(c-a-b >=0 && 4*a*b < (c-a-b)*(c-a-b))cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int a,b,c;cin>>a>>b>>c;
  cout<<min(min(a+b,b+c),c+a);

 

  return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
int main(){
	double ans=0,sum;
	int n,k,i,tmp;
	cin>>n>>k;
	for(i=1;i<=n;i++){
		tmp=i;
		sum=1;
		while(tmp<=k-1){
			tmp*=2;
			sum/=2;
		}
		ans+=sum;
	}
	printf("%.9f\n",ans/n);
}


Measured memory_bytes: 256
k, a, b = map(int, input().split())

ans = 1
if b - a <= 1:
    ans += k
else:
    ans += a - 1
    k -= a - 1
    if k % 2 == 0:
        ans += k // 2 * (b - a)
    else:
        ans += k // 2 * (b - a) + 1

print(ans)

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

using namespace std;

#define F first
#define S second

const int N = 1e5 + 10;

int n;
int a[N], b[N], mx[N];
char s[N];
pair<int, int> who(-1, -1);

bool check(int x) {
  for (int i = 0; i < n; ++i) {
    a[i + 1] = (s[i] == 'a' + x) ? 1 : -1;
  }
  for (int i = 1; i <= n; ++i) {
    b[i] = a[i] + b[i - 1];
  }
  mx[n] = b[n];
  for (int i = n - 1; i >= 0; --i) {
    mx[i] = max(mx[i + 1], b[i]);
  }
  for (int i = 0; i + 2 <= n; ++i) {
    if (mx[i + 2] - b[i] > 0) {
      who.F = i + 1;
      for (int j = i + 2; j <= n; ++j) {
        if (b[j] == mx[i + 2]) {
          who.S = j;
          break;
        }
      }
      return 1;
    }
  }
  return 0;
}

int main() {
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < 26; ++i) {
    if (check(i)) {
      break;
    }
  }
  printf("%d %d\n", who.F, who.S);
  return 0;
}


Measured memory_bytes: 1536
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int comp( const void *c1, const void *c2 )
{
  int tmp1 = *(int *)c1;
  int tmp2 = *(int *)c2;

  if( tmp1 < tmp2 ){
    return  1;
  }
  if( tmp1 == tmp2 ){
    return  0;
  }
  else{
    return  -1;
  }
}

int main(){
  int k,t;
  int a[100];
  int i,j;
  int max = -1;
  
  cin >> k >> t;
  for(i = 0;i < t;i++){
    cin >> a[i];
  }

  while(1){
    qsort(a,t,sizeof(int),comp);
    if(a[1] == -1){
      break;
    }
    max = a[0];
    a[0] -= a[1];
    a[1] = -1;
    for(i = 2;i < t;i++){
      if(a[i] == max){
	a[i] = -1;
      }
      else{
	break;
      }
    }
  }

  if(a[0] == 0){
    cout << 0 << endl;
  }
  else{
    cout << a[0] - 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;

int GCD(int a, int b) {
	int r = a % b;
	while (r) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main() {
	int n; cin >> n;
	vector<int> a(n);

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

	vector<int> ruiseki_mae(n); ruiseki_mae[0] = a[0];
	for (int i = 1; i < n; i++) {
		ruiseki_mae[i] = GCD(ruiseki_mae[i - 1], a[i]);
	}

	vector<int> ruiseki_oku(n); ruiseki_oku[n - 1] = a[n - 1];
	for (int i = n-2; i >= 0; i--) {
		ruiseki_oku[i] = GCD(ruiseki_oku[i + 1], a[i]);
	}

	int ans = max(ruiseki_oku[1], ruiseki_mae[n - 2]);

	for (int i = 1; i < n - 1; i++) {
		ans = max(ans, GCD(ruiseki_mae[i - 1], ruiseki_oku[i + 1]));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

const int dx[] = {1, -1, 0,  0};
const int dy[] = {0  ,0, 1, -1};
int dis(int startX,int startY,int endX,int endY,vector<vector<char>> &a,int n,int m){
	queue<pair<int,int>> q;
	q.push({startX,startY});
	vector<vector<int>> d(n,vector<int>(m,1e9));
	vector<vector<int>> used(n,vector<int>(m));
	d[startX][startY] = 0;
	used[startX][startY] = true;
	while(!q.empty()){
		pair<int,int> cur = q.front();
		q.pop();
		
		int x = cur.first;
		int y = cur.second;
		for(int i = 0; i < 4; i++){
			int x1 = x + dx[i];
			int y1 = y + dy[i];
			if (0 <= x1 && x1 < n && 0 <= y1 && y1 < m && !used[x1][y1] && a[x1][y1] == '.'){
				d[x1][y1] = min(d[x][y] + 1,d[x1][y1]);
				used[x1][y1] = true;
				q.push({x1,y1});
			}
		}
	}
	if (d[endX][endY] == 1000000000){
		return -1;
	}
	return d[endX][endY];
}
int main() {
	int n,m;
	cin >> n >> m;
	
	vector<vector<char>> a(n,vector<char>(m));
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			cin >> a[i][j];

	int best = -1e9;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			for(int x = 0; x < n; x++)
				for(int y = 0; y < m; y++){
					if (a[i][j] != '#' && a[x][y] != '#'){
						int disComp = dis(i,j,x,y,a,n,m); 
						if (disComp > best){
							best = disComp;
						}
					}
				}
		
	cout << best << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int an = a * n;
		System.out.println(Math.min(an, b));
		}
	}

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

int M = 100000, N = 10;

int GetRandom(int min,int max){
	return min + (int)(rand()*(max-min+1.0)/(1.0+RAND_MAX));
}

int main(){
    // 入力
    int D;
    cin >> D;   // D = 365
    ll c[26];
    for(int i=0;i<26;i++)
        cin >> c[i];
    ll s[D][26];
    for(int i=0;i<D;i++)
        for(int j=0;j<26;j++)
            cin >> s[i][j];
    // 初期解t[D]
    int t[D];
    /*
    for(int i=0;i<D;i++)
        cin >> t[i];
    */
    for(int i=0;i<D;i++){
        //t[i] = GetRandom(1,26);   // 1<=, <=26
        t[i] = i%26 + 1;
    }
    // クエリ
    // cin >> M;
    int d[M][N], q[M][N];
    /*
    for(int i=0;i<M;i++)
        cin >> d[i] >> q[i];
    */
    for(int i=0;i<M;i++){
        for(int j=0;j<N;j++){
            d[i][j] = GetRandom(1,D);   // 1<=, <=365
            q[i][j] = GetRandom(1,26);   // 1<=, <=26
        }
    }

    // 処理部
    ll v_best = 0;
    for(int query=0;query<M;query++){
        int last[26] = {}, q_[N];
        // コンテスト種別の変更（N個）
        for(int i=0;i<N;i++){
            q_[i] = t[d[query][i]-1];
            t[d[query][i]-1] = q[query][i];
        }
        // D日分
        ll v = 0;
        for(int i=1;i<=D;i++){
            // 満足度の増加分
            v += s[i-1][t[i-1]-1];
            last[t[i-1]-1] = i;
            // 満足度の低下分（コンテスト26種分）
            for(int j=0;j<26;j++)
                v -= c[j]*(i - last[j]);
        }
        // cout << v << endl;
        if(v < v_best){
            for(int i=0;i<N;i++){
                t[d[query][i]-1] = q_[i];
            }
        }
    }

    // 答え出力
    for(int i=0;i<D;i++)
        cout << t[i] << endl;

}

Measured memory_bytes: 11528
N,K = list(map(int,input().split()))

acc = [0]
for i in range(1,N+1):
    acc.append(acc[i-1]+i)

ans = 0
for i in range(K,N+1):
    min = acc[i-1]
    max = acc[N] - acc[N-i]
    ans += max - min + 1
    
MOD = 10**9+7
print(ans%MOD+1)

Measured memory_bytes: 82372
#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 endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<60;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

vector<ll> ans,ans2;
ll a[1100],b[1100],c[1100];
main(){
  ll x,y,z,k;
  cin>>x>>y>>z>>k;
  rep(i,0,x)cin>>a[i];
  rep(i,0,y)cin>>b[i];
  rep(i,0,z)cin>>c[i];
  rep(i,0,x){
    rep(j,0,y)ans.pb(a[i]+b[j]);
  }
  sort(ans.rbegin(),ans.rend());
  rep(i,0,min(x*y,k)){
    rep(j,0,z){
      ans2.pb(ans[i]+c[j]);
    }
  }
  sort(ans2.rbegin(),ans2.rend());
  rep(i,0,k)cout<<ans2[i]<<endl;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<char, int> memo;
    string s;
    cin >> s;
    for (char c : s) memo[c]++;
    bool ans = (memo.size() == 2);
    for (auto& p : memo) {
        if (p.second != 2) {
            ans = false;
            break;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	
	int a[31] = {0};

	int i,j;
	int cnt = 0;
	for(i = 0;i<n;i++){
		int t;
		int k;
		scanf("%d",&t);
		if(i == 0){
			for(j = 0;j<t;j++){
				scanf("%d",&k);
				a[k] = 1;
			}
		}else{
			int at[31] = {0};

			for(j = 0;j<t;j++){
				scanf("%d",&k);
				at[k] = 1;
			}
			for(j = 1;j<=m;j++){
				if(a[j] == 1 && at[j] == 0)
					a[j] = 0;
			}
		}
	}
	for(i = 1;i<=m;i++){
		if(a[i] == 1)
			cnt++;;
	}
	printf("%d\n",cnt);
	
}


Measured memory_bytes: 128
import math


def solve():
    A, B, H, M = map(int, input().split())
    H = (H*60+M)*0.5
    M *= 6
    radio = 0
    if abs(H-M) <= 360-abs(H-M):
        radio = abs(H-M)
    else:
        radio = 360-abs(H-M)
    ans = A**2+B**2-2*A*B*math.cos(math.radians(radio))
    print(ans**0.5)


solve()


Measured memory_bytes: 62584
#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() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h+1);
  rep(i, h) cin >> s[i];
  rep(i, h) s[i] += '#';
  s[h] = "";
  rep(j, w+1) s[h] += '#';

  vector<vector<int>> num_lighted(h, vector<int>(w, -1));
  rep(i, h) {
    int sj = -1;
    rep(j, w+1) {
      if (sj == -1) {
        if (s[i][j] == '.') sj = j;
      } else {
        if (s[i][j] == '#') {
          for (int k = sj; k < j; ++k) num_lighted[i][k] += j - sj;
          sj = -1;
        }
      }
    }
  }
  rep(j, w) {
    int si = -1;
    rep(i, h+1) {
      if (si == -1) {
        if (s[i][j] == '.') si = i;
      } else {
        if (s[i][j] == '#') {
          for (int k = si; k < i; ++k) num_lighted[k][j] += i - si;
          si = -1;
        }
      }
    }
  }
  int ans = 0;
  rep(i, h) rep(j, w) ans = max(ans, num_lighted[i][j]);
  cout << ans << endl;
  // rep(i, h) {
  //   rep(j, w) printf("%2d ", num_lighted[i][j]);
  //   printf("\n");
  // }
  return 0;
}

Measured memory_bytes: 26472
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int abc[3];fill(abc,abc+3,0);
  for(int i = 0; i < s.length(); ++i) ++abc[s[i]-'a'];
  int M = max({abc[0],abc[1],abc[2]}), m = min({abc[0],abc[1],abc[2]});
  if(M < m+2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b){
		cout<<"YES"<<endl;
		}
	else{
		cout<<"NO"<<endl;
		}
		return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
 
typedef long long ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;
 
using namespace std;
 
int main() {

	int q;
	cin >> q;

	vector<ll> v;

	int a;
	ll b;
	rep(i, q) {
		cin >> a;

		switch(a) {
			case 0:
				cin >> b;
				v.push_back(b);
				break;

			case 1:
				cin >> b;
				cout << v[b] << endl;
				break;

			case 2:
				v.pop_back();
				break;
		}
	}
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define MOD 1000000007
#define ll long long int
#define pi pair <ll,ll>
#define vi vector <ll>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define SQ(a) (a)*(a)
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>       //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/

ll binExp(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a;
    }
    ll p=binExp(a,b/2);
    if(b%2==0){
        return (p*p)%1000000007;
    }
    else{
        return (p*p*a)%1000000007;
    }
    
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll i,j,k,n,m,t,l=0,x,prev=0,max1=0,flag=0,cnt=0,y,min1,q;
    cin>>n;
    ll a[n],freq[n+1]={0};
    vector <ll> v;
    for(i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>n) continue;
        if(i-a[i]+1>0){
            v.push_back(i+1-a[i]);
        }
        freq[i+1+a[i]]++;
        
    }
    for(auto x : v){
        cnt+=freq[x];
    }
    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 8328
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main(){
    Hello
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> v;
    for(int i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        v.push_back({a, -b});
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    for(int i = 0; i < v.size(); i++){
        ans += v[i].first * (min(m, -1 * v[i].second));
        m -= min(m, -1 * v[i].second);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 5320
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(' ').map { it.toLong() }

    fun so(m: Long): MutableList<Pair<Long,Long>> {
        var n = m
        val s = Math.floor(Math.sqrt(n.toDouble())).toLong()
        var r = 0L
        val res = mutableListOf<Pair<Long,Long>>()
        for (i in 2..s) {
            if (n%i == 0L) {
                r = 0L
                while(n%i == 0L) {
                    r++
                    n = n/i
                }
                res.add(i to r)
            }
        }
        if (n > s) res.add(n to 1)
        return res
    }

    fun gcd(a: Long, b: Long): Long {
        return if (a==1L || b== 1L) 1L
        else if (b == 0L) a
        else if (a < b) gcd(a, b % a)
        else gcd(b, a % b)
    }
    val g = gcd(a,b)
    val insuu = so(g)

    println(insuu.size + 1)
}


Measured memory_bytes: 38312
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;
vector<map<ll,ll>>dp;
ll n,m;
vector<vector<ll>> edge;
ll dfs0(ll par,ll node)
{
  if(dp[node].count(par))return dp[node][par];
  ll res=1;
  for(auto nn:edge[node])
  {
    if(nn==par)continue;
    res=(ll)res*(dfs0(node,nn)+1)%m;
  }
  dp[node][par]=res;
  return res;
}
ll dfs(ll par,ll node)
{
  //cout<<par<<" "<<node<<endl;
  if(dp[node].count(par))return dp[node][par];
  if(edge[node].size()==1&&par!=-1)return 1;
  ll mul=1;
  vector<ll>lmul(edge[node].size()),rmul(edge[node].size());
  map<ll,int>ma;
  int cnt=0;
  for(auto itr=edge[node].begin();itr!=edge[node].end();itr++)
  {
    ma[*itr]=cnt++;
    lmul[ma[*itr]]=mul;
    mul=mul*(dfs(node,*itr)+1)%m;
  }
  mul=1;
  for(auto itr=edge[node].rbegin();itr!=edge[node].rend();itr++)
  {
    rmul[ma[*itr]]=mul;
    mul=mul*(dfs(node,*itr)+1)%m;
  }
  for(ll nn:edge[node])
  {
    dp[node][nn]=lmul[ma[nn]]*rmul[ma[nn]]%m;
  }
  dp[node][-1]=mul;
  return dp[node][par];
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>n>>m;
  edge.resize(n);
  dp.resize(n);
  rep(i,n-1)
  {
    ll a,b;
    cin>>a>>b;
    a--;b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  dfs0(-1,0);
  rep(i,n)
  {
    cout<<dfs(-1,i)<<"\n";
  }
  cout<<flush;
  return 0;

}


Measured memory_bytes: 42112
/*
      author : nishi5451
      created: 11.08.2020 21:27:48
*/

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


int main(){
    int H,W,h,w;
    cin >> H >> W >> h >> w;
    int ans = H*W - h*W - w*H + h*w;
    cout << ans << endl;
    return 0;
}

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

public class Main {
  public static void main(String args[] ) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    double sum = 100000;

    for (int i = 0;i < n; i++) {
      sum = (1000 * Math.ceil((sum * 1.05) * 0.001));
    }

    System.out.println((int)sum);
  }
}

Measured memory_bytes: 24408
import sys
input = sys.stdin.readline
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in range(n)]
ab = [(x,y) for x,y in zip(a,b)]
from operator import itemgetter
ab = tuple(sorted(ab,key=itemgetter(0),reverse=True))
dp = [[-10**14]*(n+1) for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
  for j in range(i+2):
    if j >= 1:
      dp[i+1][j] = max(dp[i][j]+ab[i][0]*abs(ab[i][1]-(n-1-(i-j))),dp[i][j-1]+ab[i][0]*abs(ab[i][1]+1-j))
    if j == 0:
      dp[i+1][0] = dp[i][0] + ab[i][0]*abs(ab[i][1]-(n-1-i))
print(max(dp[n]))

Measured memory_bytes: 106132
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
	long long n;
	cin >> n;
	long long nyaw = 0;
	long long cp = n;
	while (cp != 0) {
		nyaw += cp % 10;
		cp /= 10;
	}
	if (n % nyaw == 0) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

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

int main (){
  int N;
  vector<int> arrey = {0};
  cin >> N;
  for (int i = 0;i < N ;i++){
    int now;
    cin >> now;
    for (int l = 0; l < arrey.size();l++){
      if(arrey.at(l) == now) break;
      if(l == arrey.size() - 1) {
        arrey.push_back(now);
        break;
      }
    }
  }
  cout << arrey.size() -1<< endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int gcd(int x, int y);

int main(void)
{
    long int a,b;
    while (scanf("%ld %ld", &a, &b) != EOF){
        printf("%ld %ld\n", gcd(a, b), a / gcd(a, b) * b);
    }  
    return (0);
}
/*ユークリッドを用いた最大公約数の計算*/
int gcd(int x, int y)
{
    if (y == 0){
        return (x);
    }else{
        return (gcd(y, x % y));
    }
}



Measured memory_bytes: 2040