akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include<map>
using namespace std;
const long long mod = 1e9 + 7;
int solveitabdo(long long x)
{
	map<long long, long long>max1;
	for (long long i = 1; i <= x; i++)
	{
		long long num = i;
		for (long long j = 2; j*j <= num ; j++)
		{
			while (num % j == 0)
			{
				num /= j;
				max1[j]++;

			}
		}
		if (num != 1)
		{
			max1[num]++;
		}
	}
	long long ans = 1;
	map<long long, long long> ::iterator it = max1.begin();
	for (; it != max1.end(); it++)
	{
		ans *= (it)->second + 1;
		ans %= mod;
	}
	return ans;
}
int main()
{
	long long x;
	cin >> x ;
	cout<<solveitabdo(x);
}

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

const int mod=1e9+7;

int main(){

  int n;
  cin>>n;
  vector<vector<int>> inp(n, vector<int>(n));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)
      cin>>inp[i][j];
  }
  int dp[(1<<n)+5]={};

  dp[0]=1;

     for(int mask=0;mask<(1<<n)-1;mask++){
      int j=__builtin_popcount(mask);
       for(int k=0;k<n;k++){
         if(inp[j][k] && !(mask &(1<<k))){
            int val= mask^(1<<k);
            dp[val]+=dp[mask];
            dp[val]=dp[val]%mod;
         }
      }
    }
   cout<<dp[(1<<n)-1]<<endl; 

   return 0;

}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string j="No";
  int N;
  cin>>N;
  for(int a=0; a<10; a++)
  for(int b=0; b<10; b++)
  if(a*b==N)
  {
    j="Yes";
  }
  {
    cout<<j<<endl;
  } 
}


      

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


using namespace std;

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









int main() {
	ll n, m;
	cin >> n >> m;
	if ((m >> 1) <= n) {
		return cout << (m >> 1), 0;
	}
	m -= (n << 1);
	cout << n + (m >> 2);
	return 0;
}

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

int main() {
	int n;
	double m;
	cin >> n >> m;
	vector<int>a(n);
	double total = 0;
	for (size_t i = 0; i < n; i++) {
		cin >> a.at(i);
		total += a.at(i);
	}
	sort(a.begin(), a.end());//sni
	reverse(a.begin(), a.end());//sni
	if (a.at(m - 1) >= total / (4 * m))cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3760
N=int(input())
S=input()
A=S.count('R')*S.count('G')*S.count('B')
for i in range(N-2):
    for j in range(i+1,N-1):
        if 2*j-i < N:
            if S[i] != S[j] and S[i] != S[2*j-i] and S[j] != S[2*j-i]:
                A-=1
print(A)

Measured memory_bytes: 9100
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#define ll long long
#define max(x,y) (x)>(y)?(x):(y)
#define cls(name,x) memset(name,x,sizeof(name))
using namespace std;
const int inf=1<<28;
const int maxn=100010;
const int maxm=1e2+10;
const int mod=1e9+7;

int main()
{
    //freopen("in.txt","r",stdin);
    ll n,m;
    while(~scanf("%lld %lld",&n,&m))
    {
        ll ans=0;
        if(n*2>=m)
            ans=m/2;
        else
            ans=n+(m-n*2)/4;
        printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう,
signed main(){
    int n;cin>>n;
    int a[114514];rep(i,0,n)cin>>a[i];
    reverse(a,a+n);
    int mini=2;int maxi=2;
    rep(i,0,n){
        if((((mini+a[i]-1)/a[i]))*a[i]>maxi){
            cout<<-1<<endl;return 0;
        }
        mini=(((mini+a[i]-1)/a[i]))*a[i];
        maxi=((maxi/a[i])+1)*a[i]-1;
    }
    cout<<mini<<" "<<maxi<<endl;
    return 0;
}

Measured memory_bytes: 1024
// Problem : A - Xor Battle
// Contest : AtCoder - AtCoder Grand Contest 045
// URL : https://atcoder.jp/contests/agc045/tasks/agc045_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

typedef long long ll;
const int MN = 60;

int n;
ll a[205];
char s[205];

namespace base{
ll a[61], tmp[61];
bool flag;

void ins(ll x){
    for(int i=MN;~i;i--)
        if(x&(1ll<<i)) {
            if(!a[i]){a[i]=x;return;}
            else x^=a[i];
            }
    flag=true;
}
bool check(ll x){
    for(int i=MN;~i;i--)
        if(x&(1ll<<i)) {
            if(!a[i])return false;
            else x^=a[i];
            }
    return true;
}
}

using base::ins;
using base::check;

int main() {
  int T; scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
    scanf("%s", s + 1);
    if (s[n] == '1') { puts("1"); continue; }
    memset(base::a, 0, sizeof(base::a));
    memset(base::tmp, 0, sizeof(base::tmp));
    base::flag = 0;
    bool is_1 = 0;
    for (int i = n; i; --i) {
      if (s[i] == '1') {
        if (!check(a[i])) {
          puts("1");
          is_1 = 1;
          break;
        }
      } else ins(a[i]);
    }
    if (!is_1) puts("0");
    //long long t[2]; t[0] = t[1] = 0;
    //for (int i = 1; i <= n; ++i) t[s[i] - '0'] |= a[i];
    //if (t[0] != t[1]) puts("1"); else puts("0");
  }
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int main(void) {
	while(1) {
		int h; cin >> h;
		int b[12][6];
		if(h == 0) break;

		for (int i = h - 1; i >= 0; --i) {
			rep(j, 5) cin >> b[i][j];
		}

		ll ans = 0;
		rep(usagi, 100){

			rep(i, h){
				int c = b[i][2];
				int l = 2, r = 2; 
				REP(j, 2){
					if(b[i][j] == c) l = j;
					else break;
				}
				reps(j, 3, 5){
					if(b[i][j] == c) r = j;
					else break;
				}
				if(r - l + 1 < 3) continue;
				ans += c * (r - l + 1);
				reps(j, l, r + 1) b[i][j] = 0;
			}

			rep(j, 5){
				queue<int> q;
				rep(i, h){
					if(b[i][j] != 0) q.push(b[i][j]);
					b[i][j] = 0;
				}
				int cnt = 0;
				while(!q.empty()) {
					b[cnt][j] = q.front(); q.pop();
					cnt++;
				}
			}
			/*
			REP(y, h){
				rep(x, 5) printf("%d ", b[y][x]);
				printf("\n");
			}
			printf("\n");
			*/
		}
		cout << ans << endl;
	}
	return 0;
}

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

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 if(a<b)
		cout<<"a < b"<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<cmath>
using namespace std;

int main(){
    int N;
    cin >> N;
    int A[N];
    int a = 0;
    int b = 0;
    for(int i = 0;i < N;i++){
        cin >> A[i];
        if(A[i] > a){
            a = A[i];
        }
        else{
            if(A[i] > b){
                b = A[i];
            }
        }
    }
    
    for(int i = 0;i < N;i++){
        if(A[i] != a){
            cout << a << endl;
        }
        else{
            cout << b << endl;
        }
    }
}


Measured memory_bytes: 2432
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]
c = [int(i) for i in readline().split()]

ans = sum(b)
for i in range(n-1):
    if a[i]+1 == a[i+1]: ans += c[a[i]-1]

print(ans)








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

bool judgeEvenStr(string S){
  string tmp = S.substr(0, S.size()/2);
  if(S == (tmp+tmp)){
    return true;
  }
  return false;
}

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

  int tmpLength = S.size() - 1;
  
  while(true){
    if(judgeEvenStr(S.substr(0, tmpLength))){
      cout << tmpLength<< endl;
      return 0;
    }
    tmpLength--;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	auto r = 0;
	auto bitSum = 0;
	auto result = 0ll;

	for (auto l = 0; l < N; ++l)
	{
		for (; r < N && ((bitSum & A[r]) == 0); ++r)
		{
			bitSum |= A[r];
		}
		result += r - l;

		bitSum &= ~A[l];
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int n;
  cin >> n;
  vector<pair<int, string>> S(n); // 文字列の長さと文字列
  for (int i=0; i<n; i++) {
    cin >> S[i].second;
    S[i].first = S[i].second.size();
  }
  sort(S.begin(), S.end()); // 文字列の長さについて昇順ソート
  map<char, int> dict; // S[0]に含まれるアルファベットと登場回数
  for (int i=0; i<S[0].second.size(); i++) {
    if (dict.count(S[0].second[i])) dict[S[0].second[i]]++;
    else dict[S[0].second[i]] = 1;
  }
  for (int i=1; i<n; i++) {
    map<char, int> dict1; // S[i]に含まれるアルファベットと登場回数
    for (int j=0; j<S[i].second.size(); j++) {
      if (dict1.count(S[i].second[j])) dict1[S[i].second[j]]++;
      else dict1[S[i].second[j]] = 1;
    }
    // 登場回数が小さい方に合わせる
    for (auto p: dict) {
      auto key = p.first;
      dict[key] = min(dict[key], dict1[key]);
    }
  }
  for (auto p: dict) {
    auto key = p.first;
    auto value = p.second;
    for (int i=0; i<value; i++) cout << key;
  }
  cout << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
n , m = map(int,input().split())

g = [[] for i in range(n)]

dp = [-1] * n
for _ in range(m):
  v1, v2 = map(int,input().split())
  v1-=1 ; v2-=1
  g[v1].append(v2)

def dfs(i):
  if dp[i]!=-1:
    return dp[i]
  temp = 0
  for neighbour in g[i]:
    temp = max(temp, dfs(neighbour) + 1)
  dp[i]=temp
  return temp
  
res = 0
for i in range(n):
  res = max(res, dfs(i))

print(res)

Measured memory_bytes: 154060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    vector<int> V(5);
    for(int &v:V)
        cin >> v;
    
    int mn = INF;
    int idx = 0;
    for(int i=0; i<5; i++){
        if(V[i]%10 < mn && V[i]%10 !=0){
            mn = V[i]%10;
            idx = i;
        }
    }
    
    int ans = 0;
    for(int i=0; i<5; i++){
        if(i==idx) continue;
        
        ans += (V[i] + 9) / 10 * 10;
        
    }
    cout << ans + V[idx] << endl;
    return 0;
}


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

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

	vector<double> dp(N+1);
	dp[0] = 1;

	for (int n = 1; n <= N; ++n) {
		double pi;
		cin >> pi;
		for (int k = n; k >= 0; --k) {
			// the prob of k heads after n tosses is that either the nth toss is a
			// heads or tails. dp[k-1] is prob of k-1 heads after n-1 tosses and
			// dp[k] is prob of k heads after n-1 tosses
			dp[k] = (k <= 0 ? 0 : dp[k-1]) * pi + dp[k] * (1-pi);
		}
	}

	double p = 0;
	for (int n = N; n > N/2; --n)
		p += dp[n];
	
	cout << fixed << setprecision(10) << p << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
vector<ll> vec[100000];

ll dfs(ll a) {
  ll ans = 1, cnt[vec[a].size()], i;
  for(i = 0; i < vec[a].size(); ++i) cnt[i] = dfs(vec[a][i]);
  sort(cnt, cnt + vec[a].size(), greater<ll>());
  for(i = 0; i < vec[a].size(); ++i) if(ans < i + cnt[i] + 1) ans = i + cnt[i] + 1;
  return ans;
}

int main(void) {
  ll i, j, n, a;
  scanf("%lld", &n);
  for(i = 1; i < n; ++i) scanf("%lld", &a), vec[--a].push_back(i);
  printf("%lld", dfs(0) - 1);
  return 0;
}

Measured memory_bytes: 16640
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N) {
    cin >> A[i];
  }
  map<int, int> m;
  REP(i, N) {
    if(m.find(A[i]) == m.end()) {
      m[A[i]] = 1;
    } else {
      m[A[i]]++;
    }
  }
  vector<int> c;
  map<int, int>::const_iterator it;
  for(it = m.begin(); it != m.end(); it++) {
    c.push_back(it->second);
  }
  sort(c.begin(), c.end());
  int ans = 0;
  if(c.size() <= K) {
    cout << 0 << endl;
    return 0;
  }
  REP(i, c.size() - K) {
    ans += c[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11516
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <cmath>
#include <bitset>
#include <random>
#include <regex>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(10)
#define int int_fast64_t
using pii = pair<int,int>;
using Graph = vector<vector<pii> >;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

constexpr int dxw[] = {-2, -1, 0, 1, 2, -2, -1, 1, 2, -2, 2, -2, -1, 1, 2, -2, -1, 0, 1, 2};
constexpr int dyw[] = {-2, -2, -2, -2, -2, -1, -1, -1, -1, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2};

signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int h, w, ch, cw, dh, dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;

    --ch, --cw, --dh, --dw;

    vector<string> mat(h);

    rep(i,h){
        cin >> mat[i];
    }

    auto inside = [&h, &w](int y, int x){
        return (0 <= y && y < h && 0 <= x && x < w);
    };

    vector<vector<int> > min_cost(h, vector<int>(w, INF));
    deque<pii> que;
    que.emplace_front(ch, cw);
    min_cost[ch][cw] = 0;

    while(!que.empty()){
        auto [ny, nx] = que.front();
        que.pop_front();
        rep(i,4){
            int next_y = ny + dy[i];
            int next_x = nx + dx[i];
            if(inside(next_y, next_x) && mat[next_y][next_x] != '#' && chmin(min_cost[next_y][next_x], min_cost[ny][nx])){
                que.emplace_front(next_y, next_x);
            }
        }
        rep(i,20){
            int next_y = ny + dyw[i];
            int next_x = nx + dxw[i];
            if(inside(next_y, next_x) && mat[next_y][next_x] != '#' && chmin(min_cost[next_y][next_x], min_cost[ny][nx] + 1)){
                que.emplace_back(next_y, next_x);
            }
        }
    }

    if(min_cost[dh][dw] == INF){
        cout << -1 << '\n';
    }else{
        cout << min_cost[dh][dw] << '\n';
    }

    return 0;
}  

Measured memory_bytes: 12632
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
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 FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#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 ins insert

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 int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	ll total = 0;
	int id = 0;
	for (int i = 0; i < n - 1; ++i) {
		total += (ll) a[id];
		if (i % 2 == 0) {
			++id;
		}
	}
	cout << total << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3968
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s; cin >> s;
    ll b; cin >> b;
    ll count = 0, i = 0;
    while (s[i] == '1'){
        count++;
        i++;
    }
    if(b > count) cout << s[i] << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <stdio.h>
#include <algorithm>
using namespace std;
int d[1001000];
int vis[1001000];
int gcd(int a, int b)
{
	if (!a || !b) return a + b;
	else return a > b ? gcd(a % b, b) : gcd(a, b % a);
}
int a[1001000];
int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	d[1] = 1;
	for (int i = 2; i <= 1000000; i++)
	{
		if (d[i] != 0) continue;
		for (int j = 1; j * i <= 1000000; j++) d[i * j] = i;
	}
	bool pairchk = 0;
	for (int i = 1; i <= n; i++)
	{
		int c = a[i];
		while (d[c] != c)
		{
			int p = d[c];
			if (vis[p])
			{
				pairchk = 1;
				break;
			}
			vis[p] += 1;
			while (c % p == 0) c /= p;
		}
		if (pairchk) break;
		if (c == 1) continue;
		if (vis[c])
		{
			pairchk = 1;
		}
		vis[c] += 1;
	}
	if (!pairchk)
	{
		printf("pairwise coprime");
		return 0;
	}
	int gcd_=a[1];
	for (int i = 1; i <= n; i++)
	{
		gcd_ = gcd(a[i], gcd_);
	}
	if (gcd_ == 1)
	{
		printf("setwise coprime");
		return 0;
	}
	printf("not coprime");
}

Measured memory_bytes: 11304
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int A[1000005],B[1000005];
int main(){
  int N,M;cin>>N>>M;
  int i,j,k,l;
  rep(i,M){
    cin>>A[i]>>B[i];
  }
  int x=1,y=N;
  rep(i,M){
    x=max(x,A[i]);
  }
  rep(i,M){
    y=min(y,B[i]);
  }
  int ans=y-x+1;
  if(ans>0) cout<<ans<<endl;
  else cout<<0<<endl;
}


Measured memory_bytes: 4736
#include<stdio.h>

int main()
{
    int n, k, q,i;
    scanf("%d %d %d", &n, &k, &q);
    int a[q + 1];
    int score[n + 1];
    int winner=0;
    for (i = 1; i <= q; i++)
    {
        scanf("%d", &a[i]);
    }
    for (i = 1; i <= n;i++){
        score[i] = k-q;
    }
    for (i = 1; i <= q; i++)
    {
        score[a[i]]++;
    }
    for (i = 1; i <= n;i++){
        if(score[i]>0){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }
        return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

int dp[100010];
int h[100010];

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(dp, 0x3f, sizeof(dp));
  dp[1] = 0;
  int n, k;
  cin >> n >> k;
  reps(i, 1, n) cin >> h[i];
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= k; ++j) {
      dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
    }
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main ()
{
  prep();
  int n, q;
  cin >> n >> q;
  int arr[n];
  long long evens[n] = {0};
  long long odds[n] = {0};
  long long sum[n] = {0};
  for (int i=0; i<n; i++){
      cin >> arr[i];
      sum[i] = arr[i];
      if (i%2== 0){
          evens[i] = arr[i];
      }else{
          odds[i] = arr[i];
      }
  }
  for (int i=1; i<n; i++){
      sum[i] += sum[i-1];
      evens[i] += evens[i-1];
      odds[i] += odds[i-1];
  }
  
  for (int i=0; i<q; i++){
      int xx;
      cin >> xx;
      int l = 1;
      int r = n/2+n%2;
      int lastgood = 0;
      while (l <= r){
          int mid = (l+r)/2;
          int bottom = max(0, n-mid*2);
          int top = n-mid-1;
          int topdiff = max(arr[top]-xx, 0);
          int bottomdiff;
          if (bottom == 0){
              bottomdiff = 2000000001;
          }else{
              bottomdiff = max(xx-arr[bottom-1], 0);
          }
         
          if (bottomdiff <= topdiff){
              l = mid+1;
          }else{
              r = mid-1;
              lastgood = mid;
          }
      }
      //cout << lastgood << endl;
      long long res = sum[n-1]-sum[n-1-lastgood];
      if (n%2 == 0 && n-lastgood*2-1 >= 0){
          res += odds[n-lastgood*2-1];
      }else if (n-lastgood*2-1 >= 0){
          res += evens[n-lastgood*2-1];
      }
      cout << res << '\n';
  }
  return 0; 
}


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

int main(){
    int a, b;
    cin >> a >> b;
    if( a <= 0 && 0 <= b ){
        cout << "Zero" << endl;
    }else if( (a < 0 && 0 < b) && a%2 != 0 || (a < 0 && b < 0) && (b-a+1)%2 != 0 ){
        cout << "Negative" << endl;
    }else{
        cout << "Positive" << endl;
    }
    
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define print(x) cout<<x<<endl;
typedef long long ll;

int main() {
	int k, s;
	int cnt=0;
	cin >> k >> s;
	rep(x, 0, k + 1) {
		rep(y, 0, k + 1) {
			int z = s - x - y;
			if (0 <= z &&z<= k)cnt += 1;
		}
	}
	print(cnt);
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque

def main():
  h, w, k = map(int, input().split())
  x1, y1, x2, y2 = map(lambda x:int(x)-1, input().split())
  v1 = x1*(w+1)+y1
  v2 = x2*(w+1)+y2
  C = "".join(input().rstrip()+"@" for _ in range(h))
  dist = [-1 if c=="@" else 10**10 for c in C]
  ans = 0
  que = deque()
  que.append(v1)
  dist[v1] = 0
  while que:
    v = que.popleft()
    if v == v2:
      print(dist[v2])
      exit()
    d = dist[v]+1
    for dr in (-(w+1), -1, w+1, 1):
      for i in range(1, k+1):
        nv = v+dr*i
        if 0 <= nv < h*(w+1):
          if dist[nv] > d:
            dist[nv] = d
            que.append(nv)
          elif dist[nv] == d:
            continue
          else:
            break
        else:
          break
  print(-1)
if __name__ == "__main__":
  main()

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    for (int i = a; i <= b; ++i) if (c % i == 0) ans++;
    cout << ans << endl;
}



Measured memory_bytes: 3116
from math import log2, ceil

n, k = map(int, input().split())

chance =[0]*n


for firstDice in range(1, n+1):
    if firstDice >= k:
        chance[firstDice-1] = 1/n

    else:
        chance[firstDice-1] = 1/n * (1/2)**ceil(log2(k/firstDice))

print(sum(chance))

Measured memory_bytes: 6132
#include <iostream>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define mod 1000000007

using namespace std;

llint A, B;
llint a[2005], b[2005];
llint dp[2005][2005], sum[2005][2005];

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

  cin >> A >> B;
  for(int i = 1; i <= A; i++) cin >> a[i];
  for(int i = 1; i <= B; i++) cin >> b[i];

  dp[0][0] = 1;
  for(int i = 0; i <= A; i++) sum[i][0] = 1;
  for(int i = 0; i <= B; i++) sum[0][i] = 1;

  for(int i = 1; i <= A; i++){
    for(int j = 1; j <= B; j++){
      if(a[i] == b[j]) dp[i][j] = sum[i-1][j-1];
      sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + dp[i][j] + mod;
      sum[i][j] %= mod;
    }
  }
  cout << sum[A][B] << endl;

  /*for(int i = 1; i <= A; i++){
    for(int j = 1; j <= B; j++){
      cout << dp[i][j] << " ";
    }
    cout<< endl;
  }
  for(int i = 1; i <= A; i++){
    for(int j = 1; j <= B; j++){
      cout << sum[i][j] << " ";
    }
    cout<< endl;
  }*/

  return 0;
}


Measured memory_bytes: 62848
from collections import Counter, defaultdict
import numpy as np

N, P = map(int, input().split())
A = list(map(int, input().split()))
A = [i % 2 for i in A]

d = defaultdict(int)
d.update(Counter(A).items())

if d[1] == 0:
    if P == 0:
        print(2**N)
    else:
        print(0)
else:
    print(2**(N-1))

Measured memory_bytes: 12448
/*input
15
1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
9
5 4 3 2 1 2 3 4 5
*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;
map<int,int> freq;
int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>x;
		freq[x]++;
	}
	cin>>m;
	for(int i=0;i<m;++i){
		cin>>x;
		if(freq[x]<1) return cout<<"NO",0;
		else freq[x]--;
	}
	cout<<"YES";
}

Measured memory_bytes: 9728
H,W,M = map(int,input().split())
hs = [0] * H
ws = [0] * W
s = set()

for i in range(M):
  r,c = map(int,input().split())
  r -= 1
  c -= 1
  hs[r] += 1
  ws[c] += 1
  s.add((r,c))
mh = 0
mw = 0
for i in range(H):
  mh = max(mh, hs[i])
for j in range(W):
  mw = max(mw, ws[j])

i_s = list()
j_s = list()
for i in range(H):
  if mh == hs[i]:
    i_s.append(i)
for j in range(W):
  if mw == ws[j]:
    j_s.append(j)
ans = mh + mw
for i in i_s:
  for j in j_s:
    if (i,j) in s:
      continue
    print(ans)
    exit()
ans -= 1
print(ans)


Measured memory_bytes: 83460
import java.util.Scanner;

/**
 * Created by ??\??? on 2016/12/2.
 */
public class Main {
    static int run(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
            int T = Integer.parseInt(scan.nextLine());
            int maxv = -1000000000;
            int min = -1;
            int pointer = -1;
            for (int i = 1; i <= T; i++) {
                pointer = Integer.parseInt(scan.nextLine());
                if (i == 1) {
                    min = pointer;
                } else {
                    maxv = (maxv > pointer - min) ? maxv : (pointer-min);
                    min = (min > pointer) ? pointer : min;
                }
            }
            System.out.println(maxv);
        }
        return 0;
    }
    public static void main(String[] args) {
        run(args);
    }
}

Measured memory_bytes: 167480
#include<bits/stdc++.h>
using namespace std;
int n,m,v,p,a[111111],l,r,mid;
long long lst;
bool check()
{
	if (mid<=p) return 1;
	if (a[p]>a[mid]+m) return 0;
	if (p-1+n-mid+1>=v) return 1;
	lst=1ll*m*v-1ll*(p-1+n-mid+1)*m;
	for (int i=p;i<mid;i++)
	{
		lst-=(a[mid]+m-a[i]);
	}
	if (lst<=0) return 1;
	return 0;
}
int main()
{
	scanf("%d%d%d%d",&n,&m,&v,&p);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	l=1;r=n;
	while(l<=r)
	{
		mid=(l+r)>>1;
		if (check()) l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, k;

int main() {
	cin >> n >> k;
	ll ans = ((n-1)%(k-1) == 0)? (n-1)/(k-1) :(n-1)/(k-1)+1;
	cout << ans << endl;
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	string k = "No";
	for(int i = 0;i < s.length() - 1;i++)
	{
		if(s.substr(i,2) == "AC")
		{
			k = "Yes";
		}
	}
	cout << k <<endl;
	return 0;
}


Measured memory_bytes: 256
import math
A,B = map(int, input().split())

for i in range(1,100000):
    if A == math.floor(i*0.08) and B == math.floor(i*0.1):
        print(i)
        break
    if math.floor(i*0.08) > A and math.floor(i*0.1) > B:
        print('-1')
        break


Measured memory_bytes: 2940
import collections

n = int(input())
s =[]
for i in range(n):
    s.append(input())

m = int(input())
t = []
for l in range(m):
    t.append(input())

s_counter = collections.Counter(s)
t_counter = collections.Counter(t)

x_max = 0
for n in s_counter.keys():
    x_max = max(x_max, s_counter[n] - t_counter[n])

print(x_max)

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

int main(int argc, char const *argv[])
{
	int N;
	int ai, a1, a2, a4;

	a1 = a2 = a4 = 0;
	cin >> N;

	while(N--)
	{
		cin >> ai;
		if(ai % 4 == 0)
			a4++;
		else if(ai % 2 == 0)
			a2++;
		else
			a1++;
	}

	if(a2 == 0 && a4 >= a1-1)
		cout << "Yes";
	else if(a2 != 0 && a4 >= a1)
	{
		if(a4 != 0)
			cout << "Yes";
		else if(a2 > 1)
			cout << "Yes";
		else
			cout << "No";
	}
	else
		cout << "No";
	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include<math.h>
#include<stdio.h>
#include<utility>
#include<algorithm>

int main() {
	int n, a [100], m;
	m = 1;
	scanf("%d", &n);
	while (m<= n) {
		scanf("%d", &a[m]);
		m++;
	}
	while (m >= 2) {
		m--;
		printf("%d", a[m]);
		if (m != 1) {
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2708
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using vi = vector<int>;
using pi = pair<int, int>;
using vp = vector<pi>;

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

#define P (1'000'000'007)

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

    vi v[8];

    rep(i, n) {
        int x, y, z;
        cin >> x >> y >> z;

        v[0].push_back(x + y + z);
        v[1].push_back(x + y - z);
        v[2].push_back(x - y + z);
        v[3].push_back(x - y - z);
        v[4].push_back(-x + y + z);
        v[5].push_back(-x + y - z);
        v[6].push_back(-x - y + z);
        v[7].push_back(-x - y - z);
    }

    rep(i, 8) {
        sort(all(v[i]), greater());
    }

    int ans = 0;

    rep(i, 8) {
        int res = 0;
        rep(j, m) {
            res += v[i][j];
        }
        chmax(ans, res);
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3260
import java.util.*;
import java.lang.Math;

public class Main {
  
  
  public Main() {
  }
    
  public static void main(String[] args) {
    
    Scanner scan = new Scanner(System.in);
    
    int size = scan.nextInt();
    int[] num = new int[size];
	
    for(int i = 0; i < size; i++) {
      num[i] = scan.nextInt();
    }
    
    long sum = 0;
    boolean hasZero = false;
    boolean even = true;
    int smallest = Math.abs(num[0]);
    
    for(int i = 0; i < size; i++) {
      if(num[i] == 0) {
        hasZero = true;
      }
      
      if(num[i] < 0) {
        even = !even;
      }
      
      smallest = Math.min(Math.abs(num[i]), smallest);
      sum += Math.abs(num[i]);
    }
    
    if (!even && !hasZero)
      sum -= 2*smallest;
    
    System.out.println(sum);
    
  }
}


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

using namespace std;

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

	int N;
	cin >> N;
	vector<double> heads(N + 1);
	for(int i = 1; i <= N; ++i)
	{
		cin >> heads[i];
	}

	vector<double> dp(N + 1, 0);
	dp[0] = 1;

	for(int i = 1; i <= N; ++i)
	{
		for(int j = N; j >= 0; --j)
		{
			if(j == 0)
			{
				dp[j] *= 1 - heads[i];
			}
			else
			{
				dp[j] = dp[j - 1] * heads[i] + dp[j] * (1 - heads[i]);
			}
		}
	}

	double res = 0;
	for(int i = (N + 1) >> 1; i <= N; ++i)
	{
		res += dp[i];
	}

	cout << fixed << setprecision(10) << res << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, a, b, c, m;
    cin >> n;
    if (n == 2) {
        cin >> a >> b;
        c = b;
    } else {
        cin >> a >> b >> c;
    }
    m = min(a, min(b, c));
    for (int i = 1; i <= m; ++i) {
        if (a % i == 0 && b % i == 0 && c % i == 0) {
            cout << i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  map<int,int> mp;
  rep(i,n){
    mp[a[i]]++;
  }
  if(mp.size()<=k){
    cout << 0 << endl;
    return 0;
  }
  priority_queue<int, vector<int>, greater<int>> q;
  for(auto c:mp){
    q.push(c.second);
  }
  int ans=0;
  rep(i,mp.size()-k){
    ans+=q.top();
    q.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 11516
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int N;
    string S;

    cin >> N >> S;

    int ans = 1;
    REP(i, N-1){
        if(S[i] != S[i+1]) ans++;
    }
    
    cout << ans << endl;
}

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

#define INF 0x3f3f3f3f
#define NINF -0x3f3f3f3f

using namespace std;

typedef pair<int,int> pii;

int main (int argc, char const* argv[])
{
	int n;
	scanf("%d",&n);
	
	map<int,int> dict;
	for (int i = 0; i < n; i += 1)
	{
		int a;
		scanf("%d",&a);
		
		dict[a]++;
	}
	
	int ans = 0;
	for (auto v : dict)
	{
		if (v.second & 1)
			++ans;
	}
	
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 4992
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static Dictionary<Tuple<long, long>, long> dic = new Dictionary<Tuple<long, long>, long>();


        static void Main(string[] args)
        {

            var aa = ReadStringArr();
            var n = aa[0];
            var m = aa[1];

            var res = 0;

            Console.WriteLine(m+n);
        }


        class BitArr
        {
            public bool[] bitArr = new bool[64];

            public BitArr(long l)
            {
                var ll = l;
                for(int i=0; i<64; i++)
                {
                    bitArr[i] = (ll % 2) == 1;
                    ll = ll / 2;
                }
            }
        }

        public static int Digit(long num)
        {
            // Mathf.Log10(0)はNegativeInfinityを返すため、別途処理する。
            return (num == 0) ? 1 : ((int)Math.Log10(num) + 1);
        }

        public static long nCm(long n, long m, long mod)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            var a = n * nCm(n - 1, m - 1, mod) / m;
            return a % mod;
            //return a % 1000000007;
        }

        private static string ReadString()
        {
            return Console.ReadLine();
        }
        private static string[] ReadStringArr()
        {
            return Console.ReadLine().Split(' ');
        }
        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadLongArr()
        {
            string[] s = ReadStringArr();
            long[] l = new long[s.Length];
            for(int i=0; i<l.Length; i++)
            {
                l[i] = long.Parse(s[i]);
            }

            return l;
        }
    }

}


Measured memory_bytes: 13140
#include <iostream>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int H,W;
char F[410][410];
int visited[410][410] = {0};
int dx[4] = {0,0,1,-1},dy[4] = {1,-1,0,0};

bool in(int x,int y){
	return 1<=x && x<=H && 1<=y && y<=W;
}

pair<ll,ll> dfs(int x,int y,int c){
	visited[x][y] = 1;
	P cnt;
	if(c==0) cnt = {1,0};
	else cnt = {0,1};
	for(int i=0;i<4;i++){
		int nx = x+dx[i],ny = y+dy[i];
		if(visited[nx][ny]==0 && in(nx,ny)){
			if(c==0 && F[nx][ny]=='.'){
				P p = dfs(nx,ny,1);
				cnt.first += p.first;
				cnt.second += p.second;
			}
			else if(c==1 && F[nx][ny]=='#'){
				pair<ll,ll> p = dfs(nx,ny,0);
				cnt.first += p.first;
				cnt.second += p.second;
			}
		}
	}
	return cnt;
}

int main(){
	cin >> H >> W;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin >> F[i][j];
		}
	}
	ll ans = 0;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			if(F[i][j]=='#' && visited[i][j]==0){
				P t = dfs(i,j,0);
				ans += t.first*t.second;
			}
		}
	}
	cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    int a[n],b[n];
    int ans=0;
    int c=0;
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
        if(ans<a[i]){
            ans=a[i];
            c=i;
        }
    }
    cout << a[c]+b[c] << endl;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<string.h>
int main(){
  int a[3],b[3],c[3],d[3],e[3],f[3],h,i,j,k;
  for(i=0;i<3;i++) scanf("%d %d %d %d %d %d",&a[i],&b[i],&c[i],&d[i],&e[i],&f[i]);
  for(i=0;i<3;i++){
    h=3600*a[i]+60*b[i]+c[i];
    j=3600*d[i]+60*e[i]+f[i];
    k=j-h;
    printf("%d %d %d\n",k/3600,k%3600/60,k%60);
  }
  return 0;
}

Measured memory_bytes: 600
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int[] W = new int[N];
            for (int i = 0; i < N; i++) W[i] = int.Parse(str[i]);

            int sum = 0;
            for (int i = 0; i < N; i++) sum += W[i];
            int sum2 = 0, ans = 1000000;
            for(int i = 0; i < N; i++)
            {
                sum2 += W[i];
                int  sum1 = sum - sum2;
                ans = Math.Min(ans, Math.Abs(sum1 - sum2));
            }
            Console.WriteLine(ans);
        }
       
    }
}
/*
long a, b, c;
a = long.Parse(Console.ReadLine()); //標準入力
string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
b = long.Parse(str[0]);  //数値で受け取りたい場合は変換する
c = long.Parse(str[1]);
string S = Console.ReadLine();
char[] C = new char[N];
C = S.ToCharArray();
Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
Member = ReadLine().Split(' ').Select(long.Parse).ToArray();

string[] str = Console.ReadLine().Split(' ');
long[] a = new long[N];
for(long i = 0; i < N; i++) a[i] = long.Parse(str[i]);
 */
/*
      static long func(long n)
      {
          long d = 0;
          for (long i = 0; i < 10; i++)
          {
              if (n / longPow(10, i) == 0)
              {
                  d = i;
                  break;
              }
          }
          long ret = A * n + B * d;
          return ret;
      }
      static long longPow(long a, long n)
      {
          long b = 1;
          for (long i = 0; i < n; i++) b = b * a;
          return b;
      }
      */


Measured memory_bytes: 11220
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;


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

    int n, m;
    cin>>n>>m;
    pair<int, int> p[m];
    loop(m){
        cin>>p[i].first>>p[i].second;
    }

    string s;
    bool ok = 1;
    int r, q;
    for(int j = 0; j<1000; j++){
        ok = 1;
        s = to_string(j);
        if(s.size() != n) continue;

        loop(m){
            r = p[i].first - 1;
            q = p[i].second;
            if(s[r] != '0'+q){
                ok = false;
            }
        }

        if(ok){
            cout<<j<<"\n";
            return 0;
        }
    }
    cout<<-1<<"\n";
    return 0;
}

Measured memory_bytes: 256
//abc125_b.cpp
//Tue Apr 30 16:39:20 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

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

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

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


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<int> L(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> L.at(i);
        }
    sort(L.begin(), L.end());
    int A = 0;
    for ( int i = 0; i < N - 2; i++ ) {
        for (int j = i + 1; j < N - 1; j++ ) {
            for( int k = j + 1; k < N; k++ ) {
               if ( L.at(i) + L.at(j) > L.at(k) ) {
                    A += 1;
               }
               else {
                   continue;
                }
            }
          }
     }
    cout << A << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
#define ERASE(a)  (a).erase(unique((a).begin(), (a).end()), (a).end()); // sortしてから
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, d; cin >> n >> d;
    int cnt = 0;
    rep(i, n)
    {
        ll x, y; cin >>x >> y;
        ll a = x * x + y * y ;
        if (sqrt(a) <= d) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3696
N = int(input())
S = input()

if N == 1 or N == 2:
    ans = 0
else:
    R = S.count('R')
    G = S.count('G')
    B = S.count('B')
    rgb = R * G * B

    count = 0
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            k = 2 * j - i
            if k >= N:
                break 
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                count += 1
    ans = rgb - count

print(ans)

Measured memory_bytes: 68128
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		long A[]=new long[N];
		int z=0;
		long y=0,x=1,ans=0;
		while(z<N){
			A[z]=stdIn.nextInt();
			y+=A[z];
			A[z]=y;
			if(A[z]==0)
				ans++;
			z++;
		}z=1;y=1;
		Arrays.sort(A);
		while(z<N){
			if(A[z-1]!=A[z]){
				if(y!=1)
					ans+=x-y;
				y=1;x=1;
			}
			else{
				y++;
				x+=y;
			}
			z++;
		}
		if(y!=1)
			ans+=x-y;
		System.out.println(ans);
	}

}

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

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

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main () {
	int n, k;
	cin >> n >> k;
	int digit = 1;
	while(pow(k, digit) - 1 < n) {
		digit += 1;
	}
	cout << digit << "\n";
	return 0;
}

Measured memory_bytes: 888