akhauriyash/Code-Regression huggingface dataset:
// Problem : A - ι⊥l
// Contest : AtCoder - AtCoder Beginner Contest 058
// URL : https://atcoder.jp/contests/abc058/tasks/abc058_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

double pi=acos(-1.0);
const int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int a,b,c;cin>>a>>b>>c;
if(b-a==c-b)
{
	cout<<"YES";
}
else
cout<<"NO";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#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 n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    rep(i, n){
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
int main()
{
	int a,b,c,n,s=0;
	cin>>a>>b>>c>>n;
	for(int i=0;i<=a;i++)
	{
		for(int j=0;j<=b;j++)
		{
			for(int k=0;k<=c;k++){
				if((i*500+j*100+k*50)==n)
				s++;
			}
		}
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h, w;
char s[55][55];
int dist[55][55];
queue < pair < int, int > > q;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int main() {
    cin >> h >> w;
    int all = 0;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> s[i][j];
            if (s[i][j] == '.') all++;
        }
    }
    for (int i = 1; i <= 50; i++) {
        for (int j = 1; j <= 50; j++) dist[i][j] = -1;
    }
    dist[1][1] = 0;
    q.push(make_pair(1, 1));
    while (!q.empty()) {
        pair < int, int > v = q.front();
        q.pop();
        int x = v.first;
        int y = v.second;
        for (int k = 0; k < 4; k++) {
            int tox = x + dx[k];
            int toy = y + dy[k];
            if (1 <= tox && tox <= h && 1 <= toy && toy <= w) {
                if (s[tox][toy] == '#') continue;
                if (dist[tox][toy] != -1) continue;
                dist[tox][toy] = dist[x][y] + 1;
                q.push(make_pair(tox, toy));
            }
        }
    }
    if (dist[h][w] == -1) {
        cout << -1;
    }
    else {
        cout << all - dist[h][w] - 1;
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
#print(n,a)

four = 0
two = 0
odd = 0

for x in a:
    if x%4 == 0:
        four += 1
    elif x%2 == 0:
        two += 1
    else:
        odd += 1
#print(four,two,odd)        

ans = 0
if two == 0 and odd - four == 1:
    ans = 0
else:
    if odd > four:
        ans = 1
if ans == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 15020
import numpy as np
N = int(input())
S = str(input())

E = np.cumsum([1 if s == "E" else 0 for s in S])
W = np.cumsum([1 if s == "W" else 0 for s in S])

ans = float("inf")
for i, v in enumerate(S):
    if v == "E":
        ans = min(ans, (E[-1] - E[i]) + W[i])
    else:
        ans = min(ans, (E[-1] - E[i]) + W[i] - 1)
    

print(ans)

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

int main(){
  int n,k;
  cin >> n >> k;
  int p[n];
  long long int sum=0,max=0;
  for(int i=0;i<k;i++){
    cin >> p[i];
    sum+=p[i];
  }
  max = sum;
  for(int i=k;i<n;i++){
    cin >> p[i];
    sum = sum + p[i]-p[i-k];
    if(max < sum ) {
      max = sum;
    }
  }
  printf("%.6f\n",(double)(max+k)/2);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    ll s, w;
    cin >> s >> w;
    if(w >= s){
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{

    int N;
    cin >> N;
    vector<int> v(N);
    vector<long> tmp(100);

    for (auto &x : v)
    {
        cin >> x;
    }

    for (int i = 1; i < 101; i++)
    {
        for (auto &x : v)
        {
            tmp[i - 1] += (x - i)*(x - i);
        }
    }
 
    cout << *min_element(tmp.begin(), tmp.end()) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <vector>

template<typename Monoid>
struct SegTree {
  using value_type = typename Monoid::value_type;
  using Index0 = int;

  const int N;
  std::vector<value_type> nodes;

  SegTree(int size) : SegTree(size, 1 << (32 - __builtin_clz(size - 1))) {}
  SegTree(int size, int aligned) : N(aligned), nodes(aligned * 2, Monoid::empty()) {}

  template<typename F>
  void modify(int x, F f) {
    x += N;
    nodes[x] = f(nodes[x]);
    while (x > 1) {
      x >>= 1;
      nodes[x] = Monoid::append(nodes[x << 1], nodes[x << 1 | 1]);
    }
  }

  value_type query(Index0 a, Index0 b) const {
    auto x = Monoid::empty();
    for (int l = a + N, r = b + N; l < r; l >>= 1, r >>= 1) {
      if (l & 1) x = Monoid::append(x, nodes[l++]);
      if (r & 1) x = Monoid::append(x, nodes[--r]);
    }
    return x;
  }
};

#include <cstdio>
#include <limits>
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
template<typename T=int>inline T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
template<typename T=int>inline void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}

struct Min {
  using value_type = int;
  static const int empty() { return std::numeric_limits<int>::max(); }
  static const int append(int x, int y) { return std::min(x, y); }
};

int main() {
  int N = rd(), Q = rd();
  SegTree<Min> st(N);
  for (int i = 0; i < Q; i++) {
    int c = rd(), x = rd(), y = rd();
    if (c == 0) {
      st.modify(x, [y](int a){ return y; });
    } else {
      wr(st.query(x, y + 1));
    }
  }
  return 0;
}

Measured memory_bytes: 3316
'''
Sを連続する値の数のリストに変換
(ただし、左右端は必ず1が0個以上存在するとする)
S='0111010011' -> A=[0,1,3,1,1,2,2]

K=1なら、
sum(A[0:3]), sum(A[2:5]), sum(A[4:7])のmaxが答え
'''

N, K = map(int, input().split())
S = input()

# Sを0,1の区切りで分解したときのそれぞれの長さ
A = []
cur = S[0]
c = 0
for s in S[1:] + '*':
    c += 1
    if cur != s:
        cur = s
        A.append(c)
        c = 0

# 先頭、末尾が"0"のときは0を追加
if S[0] == '0':
    A = [0] + A
if S[-1] == '0':
    A = A + [0]

# Aの累積値を計算
AA = [None] * len(A)
AA[0] = A[0]
for i in range(1, len(A)):
    AA[i] = AA[i-1] + A[i]

# Aの偶数番号インデックス(0始まり)から計算される
# 2K+1個の連続する要素の和の最大値が求める値
if len(A) <= 2 * K + 1:
    print(sum(A))
else:
    m = 0
    i = 0
    while i + 2*K <= len(A):
        # p: sum(A[i: i+2*K+1])
        p = AA[i+2*K] - (AA[i-1] if i > 0 else 0)
        m = max(m, p)
        i += 2
    print(m)


Measured memory_bytes: 7820
#include <iostream>

using namespace std;

int main() {
    int x, y;
    while (true) {
        cin >> x >> y;
        if (x == 0 && y == 0) {
            break;
        }
        if (x > y) {
            swap(x, y);
        }
        cout << x << " " << y << endl;
    }
    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define mian main
int mian()
{
	string sa, sb;
	cin >> sa >> sb;
	int cnt = 0;
	for(int i=0; i<sa.size(); i++)
		if(sa[i] != sb[i])
			cnt++;
	printf("%d", cnt); 
}

Measured memory_bytes: 3916
#include <stdio.h>

int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    char str[a+b+2];
    scanf("%s", str);
    
    int flag = 1;
    
    if(str[a] != '-'){
        flag = 0;
    }
    
    else{
        for(int i = 0; str[i] != '\0'; i++){
            if(i != a && str[i] >= 48 && str[i] <= 57){
                
            }
            else if(i != a && (str[i] <48 || str[i] >57)){
                flag = 0;
            }
        }
    }
    
    flag ? printf("Yes\n") : printf("No\n");
    
    return 0;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
int main(){
    ll n;cin>>n;
    ll a=0;
    for(ll i=2;i*i<=n;i++)
        if(!(n%i))a=i;
    cout<<(a?(a+(n/a)-2):n-1);
}


Measured memory_bytes: 256
using System;

namespace test
{
  class Program
  {
   	static void Main(string[] args)
   	{
     	string[] s = Console.ReadLine().Split(' ');
     	int age = int.Parse(s[0]);
      	int price = int.Parse(s[1]);
        
      if(age>=13)
      {
        Console.WriteLine(price);
      }
      else if(age>=6)
      {
        Console.WriteLine(price/2);
      }
      else
      {
        Console.WriteLine(0);
      }     
   	}
  }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define INFTY 2000000001
#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n = 0;
int adm[MAX][MAX];
int color[MAX];
int d[MAX], p[MAX];
queue<int> queueBfs;


void sp() {
  for ( int i = 0; i < n; i++ ) {
    color[i] = WHITE;
    d[i] = INFTY;
    p[i] = -1;
  }
  d[0] = 0;

  while (true) {
    int mincost = INFTY;
    int u; //訪問する頂点

    for (int i = 0; i < n; i++) {
      if (color[i] != BLACK && d[i] < mincost) {
        mincost = d[i];
        u = i;
      }
    }
    if (mincost == INFTY) break;

    color[u] = BLACK;

    // u周りの頂点vの情報を入れる
    for (int v = 0; v < n; v++) {
      if (color[v] != BLACK && adm[u][v] != INFTY && d[u]+adm[u][v] < d[v]) {
        d[v] = d[u]+adm[u][v];
        p[v] = u;
        color[v] = GRAY;
      }
    }
  }

  for (int v = 0; v < n; v++) {
    printf("%d %d\n", v, d[v]);
  }
}

int main() {
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++) {
      adm[i][j] = INFTY;
    }
  }
  for ( int i = 0; i < n; i++ ) {
    int stash, k;
    scanf("%d %d", &stash, &k);
    for ( int j = 0; j < k; j++) {
      int v;
      scanf("%d", &v);
      scanf("%d", &adm[i][v]);
    }
  }

  sp();

  return 0;
}



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

int main()
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    char b;
    cin >> b;
    map<char, char> conv;
    conv['A'] = 'T';
    conv['T'] = 'A';
    conv['G'] = 'C';
    conv['C'] = 'G';
    cout << conv[b] << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<P,ll>;
using V = std::vector<ll>;
 
#define REP(i,b,e) for(ll i=b; i<e; i++)
#define fi first
#define se second
 
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
 
int main(){
	int h, w;
	scanf("%d %d", &h, &w);
	int sx, sy, gx, gy;
	scanf("%d %d %d %d", &sx, &sy, &gx, &gy);
	sx--, sy--, gx--, gy--;
	
	char fie[h][w+1];
	REP(i, 0, h) scanf("%s", fie[i]);
	
	ll dist[h][w] = {};
	REP(i, 0, h) REP(j, 0, w) dist[i][j] = -1;
	bool used[h][w] = {};
	std::deque<PP> deq;
	deq.emplace_back(P(sx,sy), 0);
	while(!deq.empty()){
		PP pp = deq.front();
		deq.pop_front();
		P p = pp.fi;
		ll d = pp.se;
		if(used[p.fi][p.se]) continue;
		used[p.fi][p.se] = true;
		dist[p.fi][p.se] = d;
		
		REP(i, 0, 4){
			int nx = p.fi + dx[i], ny = p.se + dy[i];
			if(0<=nx && nx<h && 0<=ny && ny<w && fie[nx][ny]!='#'){
				deq.emplace_front(P(nx,ny), d);
			}
		}
 
		REP(i, -2, 3) REP(j, -2, 3) if(i!=0 || j!=0) {
			int nx = p.fi + i, ny = p.se + j;
			if(0<=nx && nx<h && 0<=ny && ny<w && fie[nx][ny]!='#'){
				deq.emplace_back(P(nx, ny), d+1);
			}
		}
	}
	printf("%ld\n", dist[gx][gy]);
	return 0;
}

Measured memory_bytes: 16228
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

// struct murmur_hash {
//     const unsigned int random = random_device{}();
//     unsigned int operator()(const string& s) const {
//         const unsigned int m = 0x5bd1e995;
//         const int r = 24;
//         unsigned int len = s.size(), h = (random ^ len);
//         const char *c = s.c_str();
//         while(len >= 4){
//             unsigned int k = *(unsigned int*)c;
//             k *= m, k = (k^(k>>r))*m, h = (h*m)^k;
//             c += 4, len -= 4;
//         }
//         switch(len)
//         {
//         case 3u: h ^= (c[2] << 16);
//         case 2u: h ^= (c[1] << 16);
//         case 1u: h ^= c[0];
//                  h *= m;
//         }
//         h = (h^(h>>13))*m;
//         return (h^(h>>15));
//     }
// };

unordered_map<string, unordered_map<string,int> > mp[2];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    n *= 2;
    string s;
    cin >> s;
    rep(i,(1 << (n-n/2))){
        string red,blue;
        rep(j,n-n/2){
            if((i >> j) & 1){
                red.pb(s[j+n/2]);
            }else{
                blue.pb(s[j+n/2]);
            }
        }
        reverse(all(blue));
        if(len(red) <= len(blue)){
            mp[0][blue][red]++;
        }else{
            mp[1][red][blue]++;
        }
    }
    ll ans = 0;
    rep(i,(1 << n/2)){
        string red, blue;
        rep(j,n/2){
            if((i >> j) & 1){
                red.pb(s[j]);
            }else{
                blue.pb(s[j]);
            }
        }
        reverse(all(blue));
        if(len(red) >= len(blue)){
            ans += mp[0][red][blue];
        }else{
            ans += mp[1][blue][red];
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 138392
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T3;

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

	ll ans = 1;//nをカウント
	if(n > 2)ans++;//n-1が条件を満たす

	for(ll i = 2;i * i <= (n-1);i++){
		if((n-1) % i == 0){
			if(i * i != (n-1))ans += 2;
			else ans++;
		}
	}

	for(ll i = 2;i * i <= n;i++){
		if(n % i == 0){
			ll now1 = n;
			while(now1 % i == 0)now1 /= i;
			if(now1 % i == 1)ans++;

			if(i * i != n){
				ll now2 = n;
				ll j = n / i;
				while(now2 % j == 0)now2 /= j;
				if(now2 % j == 1)ans++;
			}
		}
	}
	cout << ans << endl;
}


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

const int N = 200001;
const ll MAX = (1LL<<61);

int main () {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll n, m; cin >> n >> m;
	ll a[n], p[n+1];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	p[0] = 0;
	for (int i = 0; i < n; i++)
		p[i+1] = p[i]+a[i];
	map<ll,ll> rems;
	for (int i = 0; i <= n; i++)
		rems[p[i]%m]++;
	ll tot = 0;
	for (pair<ll,ll> x : rems)
		tot += (x.second*(x.second-1LL))/2LL;
	cout << tot << endl;
	return 0;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
using P = pair<ll, ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((ll)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((ll)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()
 
ll N;
ll Main() {
    cin >> N;
    vl A(N);
    
    rep(i, N) {
        cin >> A[i];
    }
    
    sort(all(A), greater<ll>());
    ll ans = 0;
    ll idx = 0;
    ll cnt = 1;
    rep(i, N-1) {
        ans += A[idx];
        cnt++;
        if (cnt == 2) {
            cnt = 0;
            idx++;
        }
    }
 
    cout << ans << endl;
    return 0;
}
 
int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 4792
//B
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    int x,y;cin>>x>>y;
    if(y-2*x>=0&&(y-2*x)%2==0&&x-((y-2*x)/2)>=0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3576
#include<stdio.h>
int main(void)
{
	int a,b,x,y,s;
	int i,temp;

	while(scanf("%d %d",&a,&b)!=EOF){
		x=a;
		y=b;
		if(a<b){
			
			temp=a;
			a=b;
			b=temp;
		}
		while(b!=0){
			a=a%b;
			temp=a;
			a=b;
			b=temp;
		}
		x=x/a;
		y=y/a;
		s=a*x*y;
		printf("%d %d\n",a,s);
	}
	return 0;
}

		

Measured memory_bytes: 1024
x = int(input())
li = []
for i in range(1,32):
    for j in range(2,32):
        if i**j<=1000:
            li.append(i**j)
li = list(set(li))
li.sort()
for k in range(len(li)-1,-1,-1):
    if li[k]<=x:
        print(li[k])
        break

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>

using namespace std;
typedef long long int ll;

int main() {
  ll dp[100005], h[100005], n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
    dp[i] = INT_MAX;
  }
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i < n; i++) {
  	for (int j = 1; j <= k; j++) {
  		if(j > i)
  			break;
  		if(dp[i-j] + abs(h[i] - h[i-j]) < dp[i]) {
  			dp[i] = dp[i-j] + abs(h[i] - h[i-j]);
  		}
  	}
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1920
#include <iostream>
using namespace std;
int x,y,z;
int main(void){
    
    string a;
    cin>>a;
    for(int i=0;i<a.size();i++){
        if(a[i]=='a')x=1;
        if(a[i]=='b')y=1;
        if(a[i]=='c')z=1;
    }
    if(x+y+z==3)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	int A , B , C;
	cin >> A >> B >> C;
	bool ans = false;
	for (int k = 1; k < B; ++k) {
		if (k*A%B == C)
			ans = true;
	}
	if (ans)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
//import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static long cnt = 0;
	public static void main(String[] args) throws IOException {
		//System.setIn(new FileInputStream("./ALDS1_5_D-in19.txt"));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		//long start = System.nanoTime();
		
		String[] t = br.readLine().split(" ");
		int[] s = new int[n];
		for(int i = 0; i < n; ++i){
			s[i] = Integer.parseInt(t[i]);
		}
		//int[] s = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		//System.out.println((System.nanoTime() - start)/1000/1000 + "ms");
		
		mergeSort(s, 0, n);

		System.out.println(cnt);
	}
	public static void printArray(int[] s){
		for(int i = 0; i < s.length; ++i) {
			System.out.print(" " + s[i]);
		}
		System.out.println(": " + cnt);
	}
	public static void mergeSort(int[] s, int left, int right) {
		if(left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(s, left, mid);
			mergeSort(s, mid, right);
			merge(s, left, mid, right);
			//printArray(s);
		}
	}
	public static void merge(int[] s, int left, int mid, int right) {
		int[] s1 = Arrays.copyOfRange(s, left, mid + 1);
		int[] s2 = Arrays.copyOfRange(s, mid, right + 1);
		
		s1[mid - left] = Integer.MAX_VALUE;
		s2[right - mid] = Integer.MAX_VALUE;
		int i = 0;
		int j = 0;
		for(int k = left; k < right; ++k) {
			if(s1[i] <= s2[j]){
				s[k] = s1[i];
				if(k < left + i){
					cnt += left + i - k;
				}
				i += 1;
				
			}else{
				s[k] = s2[j];
				if(k < mid + j){
					cnt += mid + j - k;
				}
				j += 1;
				
			}
		}
		
	}
	
}

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

// #define int ll
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp        make_pair
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second

int inf(0x3fffffff);
int mod(1000000007);
double pi(acos(-1.0));

int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#endif

  int a;
  cin >> a;
  cout << a + a * a + a* a * a;

  return 0;
}


Measured memory_bytes: 3648
H, W = map(int, input().split())
STAGE = [input() for _ in range(H)]

dp = [[0] * W for _ in range(H)]
dp[0][0] = 1

MOD = 10 ** 9 + 7

for y in range(H):
	for x in range(W):
		if y + 1 < H and STAGE[y + 1][x] == ".":
			dp[y + 1][x] += dp[y][x] % MOD
		if x + 1 < W and STAGE[y][x + 1] == ".":
			dp[y][x + 1] += dp[y][x] % MOD

print(dp[-1][-1] % MOD)


Measured memory_bytes: 43692
while 1:
    a,b=map(int,input().split())
    if a==b==0:break
    c=0
    for i in range(1,a+1):
        for j in range(i+1,a+1):
            for k in range(j+1,a+1):
                if i+j+k==b:
                    c+=1
    print(c)


Measured memory_bytes: 5596
# お約束
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1
def parse(*args):
    # (tuple(map(int, input().split())) for _ in range(N))
    return tuple(p(v) for p, v in zip(args, input().split()))

A = int(input())
S = input()

if A < 3200:
	print("red")
else:
	print(S)


Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 100000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
using namespace std;

int main() {
	ll N; cin >> N;
	ll cnt = 0;
	for (ll i = 1; i <= N; i++) {
		if (i % 3 == 0 or i % 5 == 0) {
			continue;
		}
		else {
			cnt += i;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>

using namespace std;

int main(void) {
    while (1) {
        int n, m, s[502][502] = {0};
        cin >> n >> m;
        if (n == 0) return 0;

        for (int i = 0; i < m; ++i) {
            int a, b;
            cin >> a >> b;
            s[a][b] = true;
            s[b][a] = true;
        }

        bool mem[502] = {0};
        for (int i = 2; i <= n; ++i) {
            if (!s[1][i])continue;
            mem[i] = true;
            for (int j = 2; j <= n; ++j) {
                if (s[i][j])mem[j] = true;
            }
        }
        int result = 0;
        for (int i = 2; i <= n; ++i) {
            if (mem[i]) result++;
        }
        cout << result << endl;
    }
}

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

int main(){
    int N;cin>>N;
    string S;cin>>S;
    vector<int>r;
    vector<int>g;
    vector<int>b;

    for (int i=0;i<N;i++){
        if(S[i]=='R')r.push_back(i);
        if(S[i]=='G')g.push_back(i);
        if(S[i]=='B')b.push_back(i);
    }
    //cout<<r.size()<<g.size()<<b.size()<<endl;
    long long res=0;
    for (int i=0;i<r.size();i++){
        for(int j=0;j<g.size();j++){
            int count=0;
            //cout<<"hi"<<r[i]<<g[j]<<endl;
            if(max(r[i],g[j])+abs(r[i]-g[j])<=N-1){
            if(S.at(max(r[i],g[j])+abs(r[i]-g[j]))=='B'){
                count+=1;
            }
            }
            if(min(r[i],g[j])-abs(r[i]-g[j])>=0){
                if(S.at(min(r[i],g[j])-abs(r[i]-g[j]))=='B'){
                    count+=1;
                }
            }
            if(abs(r[i]-g[j])%2==0){
                if(S[(r[i]+g[j])/2]=='B'){
                    count+=1;
                }
            }
            //cout<<count<<endl;
            res+=b.size()-count;
            //cout<<res<<endl;



        }
    }
    cout<<res<<endl;


}

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


int main(){
    string a,b,c;
    cin>>a>>b>>c;

    cout<< 'A' << b[0] << 'C' <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}


int main(){
    string s; cin >> s;
    int ans = 0;
    for(int i = 1; i < s.size(); i++){
        if ((s.size() - i) % 2 == 0){
            bool flg = true;
            for(int j = 0; j < (s.size()-i)/2; j++){
                if (s[j] != s[(s.size()-i)/2 + j]) flg = false;
            }
            if (flg){
                cout << s.size() - i << endl;
                return 0;
            }
        } else {
            continue;
        }
    }
    //cout << ans << endl;
}
  



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a, b;
  char op;

  for( ; ; )
  {
    scanf("%d %c %d", &a, &op, &b);

    if( op == '+' )
      printf("%d\n", a + b);
    else if( op == '-' )
      printf("%d\n", a - b);
    else if( op == '*' )
      printf("%d\n", a * b);
    else if( op == '/' )
      printf("%d\n", a / b);
    else if( op == '?' )
      break;
  }
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

// エラストテネスの篩
const int N = 1e6+1;
bool is_prime[N];
void build_sieve(){
    fill(is_prime, is_prime + N, true);
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i < N; ++i)if(is_prime[i]){
        for(int j = 2*i; j < N; j+=i)is_prime[j] = false;
    }
}

int main(){
    ll n; cin >> n;
    build_sieve();
    while(is_prime[n] == 0)n++;
    cout << n << endl;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int n, i, j, total = 0, maxv, minv = 0;
  int *R;

  scanf("%d", &n);
  
  R = (int *)malloc(n * sizeof(int));

  for(i = 0; i < n; i++) scanf("%d", &R[i]);

  maxv = R[1] - R[0];
  minv = R[0];

  for(j = 1; j <= n - 1; j++){
    if(R[j] - minv > maxv) maxv = R[j] - minv;
    if(R[j] < minv) minv = R[j];
  }
 
  printf("%d\n", maxv);

  free(R);

  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;
int main(){
	string s;
	int ans = 0;
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == 'o')ans++;
	}
	ans += 15 - s.size();
	if (ans >= 8)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

int main(){
	int n; cin >> n;
	vector<int> a(n),b(n);
	ll ans=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i])b[i]=1;
		else b[i]=0;
	}
	ll sum=0;
	for(int i=0;i<n;i++){
		if(b[i]){
			sum+=a[i];
		}
		else{
			ans+=(sum/2);
			sum=0;
		}
	}
	if(sum)ans+=sum/2;
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main (void)
{
	int H,W,t,y,g,r;

	while (1)
	{
		scanf("%d %d",&H ,&W);
		if((H==0)&&(W==0))break;

		for(t=0;t<H;t++)//?????????????????????
		{
			for(y=0;y<W;y++)//?¨????????????????
			{
				g = y % 2;
				r = t % 2;

				 if((g==0)&&(r==0))
				{
					printf("#");
				}
				 if((g==0)&&(r==1))
				{
					printf(".");
				}
				 if((g==1)&&(r==0))
				{
					printf(".");
				}
				 if((g==1)&&(r==1))
				{
					printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	

				

	return 0;
}

Measured memory_bytes: 572
/*
Wai u read my code xD
*/
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vi vector <ll> 
#define qu queue <ll>
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


void solve()
{
    double L; cin >> L;
    double ans = pow(L/3,3);
    cout << fixed << setprecision(7) << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 512
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;
int dp[N*10][2] ;
// dp[i][0] is when exact amount is paid
// dp[i][1] is when one extra is paid 
void solve(){
	cin >> s ;
	int n = sz(s) ;
	for(int i = 0 ; i < n+4 ; i++) dp[i][0] = dp[i][1] = INF ;
	s = "0" + s ;
	n++ ;dp[0][0] = 0 ;
	for(int i = 0 ; i < n ; i++){
		int x = s[i] - '0' ;
		dp[i+1][0] = min(dp[i+1][0], dp[i][0]+x) ; // exact 
		dp[i+1][1] = min(dp[i+1][1], dp[i][0]+x+1) ; // exact + one extra 
		dp[i+1][0] = min(dp[i+1][0], dp[i][1]+10-x) ; // exact with paid ith step extra 
		dp[i+1][1] = min(dp[i+1][1], dp[i][1]+10-(x+1)) ; // previous extra + cur_extra
	//	cout << dp[i+1][0] << ' ' << dp[i+1][1] << endl ;
	}
	cout << dp[n][0] << endl ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 18716
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
	string S, T;
	cin >> S >> T;
 
	int ans = T.size();
 
	for (int start = 0; start <= S.size() - T.size(); start++)
	{
		int diff = 0;
		for (int i = 0; i < T.size(); i++)
		{
			if (T[i] != S[start + i]) {
				diff++;
			}
		}
		ans = min(ans, diff);
	}
 
	cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int a[3],cnt = 0,mx;
    cin >> a[0] >> a[1] >> a[2];
    
    sort(a,a+3);
    mx = a[2];
    if((3*a[2]) %2 == (a[0]+a[1]+a[2]) % 2){
        cnt = (3*mx - (a[0]+a[1]+a[2]));
        cnt /= 2;
    }else{
        while(1){
            if(a[1] == a[2]) break;
            a[0]++;
            a[1]++;
            cnt++;
        }
        int tmp = a[2]-a[0]+1;
        tmp /= 2;
        tmp++;
        cnt += tmp;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import sys


def read_data():
    r_data = []
    n = int(sys.stdin.readline().strip())
    
    for _ in range(n):
        r = int(sys.stdin.readline().strip())
        r_data.append(r)

    return n, r_data
    
def main():
    n, r_data = read_data()
    maxv = -1000000000
    minv = r_data[0]
    
    for j in range(1, n):
        if r_data[j] - minv > maxv:
            maxv = r_data[j] - minv

        if r_data[j] < minv:
            minv = r_data[j]

    print(maxv)

if __name__ == '__main__':
    main()

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

int main() {
	int x,y,n,m;
	cin>>n>>m>>x>>y;
	vector<int> a(n), b(m);
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=0;i<m;i++) cin>>b[i];
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	if((a[n-1]-x) + (y-b[0]) < y-x && a[n-1] < y && b[0] > x) cout << "No War" << endl;
	else cout << "War" << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int four = 0, two = 0, rest = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;

    if (x % 4 == 0) {
      ++four;
    } else if (x % 2 == 0) {
      ++two;
    } else {
      ++rest;
    }
  }

  if (four >= two + rest) {
    cout << "Yes\n";
  } else if (four >= rest) {
    cout << "Yes\n";
  } else if (four == rest - 1 && two == 0) {
    cout << "Yes\n";
  } else if (four == 0 && rest == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    double a, b, x, theta;
    cin >> a >> b >> x;
    if (x > a * a * b / 2) {
        theta = atan(2 * (a * a * b - x) / (a * a * a));
    } else {
        theta = atan((a * b * b) / (2 * x));
    }
    theta = theta * 180 / M_PI;
    printf("%.7lf\n", theta);
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        int n = sc.nextInt();
        int m = sc.nextInt();

        int min = 1;
        int max = m / n;

        List<Integer> factor = new ArrayList<>();

        for (int i=1; i<=Math.sqrt(m)+1; i++) {
            if (m % i ==0) {
                factor.add(i);
                factor.add(m / i);
            }
        }

        Collections.sort(factor);
//        System.out.print(factor);
//        System.out.print(min);
//        System.out.print(max);

        for (int l: factor) {
            if (l <= max) min = Math.max(min, l);
        }

        System.out.print(min);

    }


}



Measured memory_bytes: 36048
// 解説前
#include <iostream>

// $i = N$のとき、$M_N = N - 1$が最大値 ⇒ $P_i = N - 1$
// $i = N - 1$のとき、$M_{N-1} = N - 2$が最大値 ⇒ $P_i = N - 2$
// ...
// $i = 2$のとき、$M_2 = 1$が最大値 ⇒ $P_i = 1$
// $i = 1$のとき、$M_1 = 0$が最大値 ⇒ $P_i = N$
// したがって、$\sum_{i=1}^N M_i = \sum_{i=0}^{N-1} i$
// => $N$が偶数ならば、`N * ((N - 1) / 2) + (N / 2)`
//    $N$が奇数ならば、`N * ((N - 1) / 2)`
int solve_D() {
  size_t N = 0;
  std::cin >> N;

  size_t result = N * ((N - 1) / 2);
  if (N % 2 == 0) result += N / 2;
  std::cout << result;
  return 0;
}

int main() { return solve_D(); }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll Q=1000000007;

bool exist(string X,int n){//0<=n<=25
  int N=X.size();
  char y = 'a' + n;
  for(int i=0;i<N;i++){
    if(X[i]==y){
      return true;
    }
  }
  return false;
}

int main(){
  string S;
  cin >>S;
  for(int i=0;i<26;i++){
    if(!exist(S,i)){
      char ans = 'a' + i;
      cout << ans << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll mod = 1e9+7;

int main(){

	int n;
	cin>>n;

	string s;
	cin>>s;

	vector<int> a[3];

	for(int i = 0; i < n; i++){
		if(s[i] == 'R')
			a[0].push_back(i);
		else if(s[i] == 'G')
			a[1].push_back(i);
		else
			a[2].push_back(i);
	}
	ll ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			if(s[i] == s[j])	continue;

			int k = 0;
			if(s[i]!='R' && s[j]!='R')
				k = 0;
			else if(s[i]!='G' && s[j]!='G')
				k = 1;
			else
				k = 2;

			int diff = j-i;

			ll idx = upper_bound(a[k].begin(),a[k].end(), j) - a[k].begin();
			idx = a[k].size()-idx;
			ans += idx;

			auto it = lower_bound(a[k].begin(),a[k].end(),j+diff);

			if(it!=a[k].end()){
				if(*it == j+diff)
					ans--;
			}
		}
	}

	cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 3628
//It is made by Awson on 2018.1.28
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define dob complex<double>
#define Abs(a) ((a) < 0 ? (-(a)) : (a))
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
#define writeln(x) (write(x), putchar('\n'))
#define lowbit(x) ((x)&(-(x)))
using namespace std;
const int N = 100;
void read(int &x) {
    char ch; bool flag = 0;
    for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1); ch = getchar());
    for (x = 0; isdigit(ch); x = (x<<1)+(x<<3)+ch-48, ch = getchar());
    x *= 1-2*flag;
}
void write(int x) {
    if (x > 9) write(x/10);
    putchar(x%10+48);
}

int n, f[N+5][2], a[N+5][2];

void work() {
    read(n);
    for (int i = 0; i <= 1; i++) for (int j = 1; j <= n; j++) read(a[j][i]);
    for (int i = 1; i <= n; i++) f[i][0] = f[i-1][0]+a[i][0];
    for (int i = 1; i <= n; i++) f[i][1] = Max(f[i-1][1], f[i][0])+a[i][1];
    writeln(f[n][1]);
}
int main() {
    work(); return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

vector<vector<long long>> B;

long long ans0(int T)
{
  long long R = 0;
  for (int i = 1; i < B.at(T).size(); i++)
  {
    if (B.at(T).at(i) != -1 && B.at(T).at(i - 1) != -1)
      R += abs(B.at(T).at(i) - B.at(T).at(i - 1));
  }
  return R;
}

int main()
{
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  sort(A.begin(), A.end());
  
  vector<long long> B0, B1;
  int a, b;
  int n = (N + 1) / 2 * 2;

  for (int i = 0; i < (N - 1) / 2; i++)
  {
    B0.push_back(A.at(i));
    B0.push_back(A.at(N - 1 - i));
    B1.push_back(A.at(N - 1 - i));
    B1.push_back(A.at(i));
  }
  
  if (N % 2 == 0) a = A.at(N / 2 - 1), b = A.at(N / 2);
  else a = A.at(N / 2), b = -1;
  
  B0.insert(B0.begin(), a);
  B0.push_back(b);
  B.push_back(B0);
  
  swap(B0.at(0), B0.at(n - 1));
  B.push_back(B0);
  
  B1.insert(B1.begin(), a);
  B1.push_back(b);
  B.push_back(B1);
  
  swap(B1.at(0), B1.at(n - 1));
  B.push_back(B1);
  
  /*
  for (int i = 0; i < 4; i++)
  {
    for (int j = 0; j < B.at(i).size(); j++)
    {
      cout << B.at(i).at(j) << " ";
    }
    cout << endl;
  }
  */
  
  long long ans = max({ans0(0), ans0(1), ans0(2), ans0(3)});
  
  cout << ans << endl;
}

Measured memory_bytes: 5996
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<LL> count(N+1, 0);
  REP(i, N) {
    cin >> A[i];
    count[A[i]]++;
  }
  LL total = 0;
  for(const auto& i : count) {
    total += i * (i-1) / 2;
  }
  REP(i, N) {
    cout << total - (count[A[i]] - 1) << endl;
  }
}

Measured memory_bytes: 5624
//verma_ankit484

#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

vector<pair<ll, ll> > vc;
ll w, n;

ll dp[101][100002];

ll rec(ll idx,ll wt) {
  // if(wt > w) return 0;
  if(dp[idx][wt] != -1) return dp[idx][wt];
  if(idx == n) return dp[idx][wt] = 0;
  ll k1, k2;
  k1 = k2 = 0;
  k1= rec(idx+1, wt);
  if(wt+vc[idx].second <= w) k2 = vc[idx].first+rec(idx+1, wt+vc[idx].second);
  return dp[idx][wt] = max(k1, k2);
}


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifdef AV
  freopen("int.txt", "r", stdin);
  #endif
  // ll n;
  memset(dp, -1, sizeof(dp));
  cin >> n >> w;
  vc.resize(n);
  for(ll i = 0; i < n; i++) {
    cin >> vc[i].second;
    cin >> vc[i].first;
  }
  cout << rec(0, 0) << '\n';
  return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)998244353;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

ll power(ll a,ll n){
    if(n==0) return 1;
    ll res=1;
    while(n>0){
        if(n%2==1) res=res*a%MOD;
        a=a*a%MOD;
        n/=2;
    }
    return res;
}

int main(){
    ll N,ans=1,M=0,d;
    map<ll,ll> m;
    cin>>N;
    for(ll i=0;i<N;i++){
        ll D;
        cin>>D;
        if(i==0) d=D;
        m[D]++;
        M=max(M,D);
    }
    if(m[0]!=1||d!=0){
        cout<<"0"<<endl;
        return 0;
    }
    for(ll i=1;i<=M;i++){
        ans*=power(m[i-1],m[i]);
        ans%=MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6528