akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main(){
	int n;
	long long ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}
	cout << ans << endl;
}

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

const int DIGITS[10] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000};

int main()
{
    vector<int> nums;
    nums.resize(8);
    string in_str;
    getline(cin, in_str);
    while(getline(cin, in_str))
    {
        int max_value = 0;
        int min_value = 0;
        for(int j=0; j<8; j++)
        {
            string tmp = in_str.substr(j, 1);
            nums[j] = stoi(tmp);
        }
        std::sort(nums.begin(), nums.end());
        for(int j=0; j<8; j++)
        {
            min_value += nums[j] * DIGITS[7-j]; 
            max_value += nums[j] * DIGITS[j];
        }
        cout << max_value - min_value << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();				//チーム数
		int games = n * (n - 1) / 2;		//試合数
		int teamA;
		int teamB;
		int teamAp;
		int teamBp;
		int winP[] = new int[n];
		for(int i = 0; i < n; i++){
			winP[i] = 0;
		}

		for(int i = 0; i < games; i++){
			teamA = sc.nextInt();
			teamB = sc.nextInt();
			teamAp = sc.nextInt();
			teamBp = sc.nextInt();

			if(teamAp > teamBp){
				winP[teamA-1] += 3;
			}else if(teamAp < teamBp){
				winP[teamB-1] += 3;
			}else{
				winP[teamA-1] += 1;
				winP[teamB-1] += 1;
			}
		}
		int rank[] = new int[n];
		for(int i = 0; i < n; i++){
			rank[i] = 1;
		}
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(winP[i] < winP[j]){
					rank[i]++;
				}
			}
		}
		for(int i = 0; i < n; i++){
			System.out.println(rank[i]);
		}
	}
}

Measured memory_bytes: 42036
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>

using namespace std;

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

int bi(int x){
    int res = 0;
    while(x % 2 == 0){
        x /= 2;
        res++; 
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    int ans = 1000000000;
    rep(i, n) ans = min(ans, bi(a[i]));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;


int main()
{
    ll N;
    cin >> N;
    if (N / 100 == N % 10) {
        cout << "Yes" << endl;
    } else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
#sys.exit()
#sorted( ,reverse=True)
N = int(input())
S = str(input())
r = S.count("R")
g = S.count("G")
b = S.count("B")
ans = (r*g*b)
for i in range (N-2):
    for j in range (i+1,N-1):
        k = 2*j-i
        if k < N and S[i]!=S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -=1
                #print(r2[i],g2[j],b2[k])
print(ans)


Measured memory_bytes: 9168
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string.h>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;

int n;
int a[15];

ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	else return gcd(b, a%b);

}

ll lcm(ll a, ll b)
{
	ll c = gcd(a, b);
	return (a*b) / c;
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	ll ans=a[0];
	for (int i = 1; i < n; i++) {
		ans = lcm(ans, a[i]);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>
#include <vector>
#include <string>
using namespace std;

int main(){
	int n,a = 0,w=0,t = 0,r = 0;
	scanf("%d",&n);
	char s[4];
	vector<string>vec(n);
	for(int i = 0;i<n;i++){
		scanf("%s",&s);
		vec[i] = s;
	}
	for (int i = 0; i < n; i++)
	{
		if(vec[i] == "AC"){
			a++;
		}
		else if(vec[i] == "WA"){
			w++;
		}
		else if(vec[i] == "TLE"){
			t++;
		}
		else if(vec[i] == "RE"){
			r++;
		}
	}
	printf("AC x %d\n",a);
	printf("WA x %d\n",w);
	printf("TLE x %d\n",t);
	printf("RE x %d\n",r);
	
	return 0;
}


Measured memory_bytes: 5928
#include<iostream>
#include<sstream>
#include<string>
#include<cstdlib>
using namespace std;
int main(){
  unsigned long long int N;
  unsigned long long int kouho;
  unsigned long long int min = 1000000;
  cin >> N;
  for(unsigned long long int i = 1; i*i <= N; ++i){
    if(N % i == 0){
      kouho = N / i;
    }
    stringstream ss;
    ss << kouho;
    string string = ss.str();
    if(string.length() < min){
      min = string.length();
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const ll MOD = 1000000007;
using pint = pair<ll, ll>;

int main() {
  ll N;
  cin >> N;
  map<ll, ll> A;
  for (int i = 0; i < N; i++){
    ll tmp = 0;
    cin >> tmp;
    A[tmp]++;
  }
  ll cnt = 0;
  for (auto i : A){
    if (i.second % 2 == 0) continue;
    else{
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 9844
var cnt,n:qword;
begin
        readln(n);
        if n mod 2 <> 0 then begin
                writeln(0);
                exit;
        end else begin
                n := n div 2;
                while n>0 do begin
                cnt:=cnt+n div 5;
                n:=n div 5;
                end;
        end;
        writeln(cnt);
end.

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<functional>
#include<deque>
#define rep(i,rept)	for(int i = 0; i<(ll)rept;++i)
typedef long long ll;
using namespace std;

int main() {
	int n = 0, p[10000] = {};
	cin >> n;
	rep(i, n) {
		cin >> p[i];
	}
	sort(p, p + n,std::greater<int>());
	int ans = p[0] / 2;
	for (int i = 1; i < n; i++) {
		ans += p[i];
	}
	cout << ans << endl;


		return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  double n;
  cin >> n;
  out((n - floor(n / 2.0)) / n);
  return 0;
}


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

const int N = 88;
const int M = 6400;
int n, m, A[N][N], B[N][N];
std::bitset<M * 2 + 1> dp[N][N];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			scanf("%d", A[i] + j);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			scanf("%d", B[i] + j);
	dp[0][1].set(M);
	dp[1][0].set(M);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			int d = std::abs(A[i][j] - B[i][j]);
			dp[i][j] |= (dp[i - 1][j] << d) | (dp[i - 1][j] >> d);
			dp[i][j] |= (dp[i][j - 1] << d) | (dp[i][j - 1] >> d);
		}
	int ans = 1e9;
	for (int i = 0; i <= 2 * M; i++)
		if (dp[n][m].test(i))
			ans = std::min(ans, std::abs(i - M));
	printf("%d\n", ans);
	return 0;
}

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

int N, M;
int64_t XYZ[1005][3];
int64_t val[8][1005] = {};

int main()
{
    cin >> N >> M;
    for ( int i = 0; i < N; i++ ) {
        cin >> XYZ[i][0] >> XYZ[i][1] >> XYZ[i][2];
        for ( int bit = 0; bit < 8; bit++ ) {
            for ( int j = 0; j < 3; j++ ) {
                if ( (bit >> j) & 1 ) {
                    val[bit][i] += XYZ[i][j];
                } else {
                    val[bit][i] -= XYZ[i][j];
                }
            }
        }
    }
    int64_t maxv = 0;
    for ( int bit = 0; bit < 8; bit++ ) {
        int64_t sum = 0;
        sort(val[bit], val[bit] + N, greater <> ());
        for ( int i = 0; i < M; i++ ) {
            sum += val[bit][i];
        }
        maxv = max(maxv, sum);
    }
    cout << maxv << endl;
    return ( 0 );
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);
int n;
typedef pair <int,int> ii;
int f[300001];
ii a[300001];
long long dp[300001];
const long long Mod = 998244353;
int Max[300001];
int Bs(int x)
{
    int l=1,r=n;
    int ans = 0;
    while(l<=r)
    {
        int mid = l+r>>1;
        if(a[mid].first<x)
        {
            ans = mid;
            l=mid+1;
        }
        else
            r=mid-1;
    }
    return ans;
}
void update(int pos,int val)
{
    for(int i = pos;i<=n ;i+=i&(-i))
        Max[i]=max(Max[i],val);
}
int Get(int pos)
{
    int M = 0;
    for(int i=pos;i>0;i -= i & (-i))
        M=max(M,Max[i]);
    return M;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i].first>>a[i].second;
    }
    for(int i=1;i<=n;i++)
    {
        f[i]=i;
        update(i,f[i]);
    }
    sort(a+1,a+n+1);
    f[n]=n;
    for(int i=n-1;i>=1 ; i--)
    {
        int t = a[i].first + a[i].second;
        t = Bs(t);
        f[i] = Get(t);
        update(i,f[i]);
    }
    dp[n+1]=1;
    for(int i = n ; i>=1; i--)
    {
        int id = f[i]+1;
        dp[i]+=dp[i+1] + dp[id];
        dp[i]%=Mod;
    }
    cout<<dp[1];
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;

struct Node {
    Node *prev, *next;
    int key;
};

Node *nil;

Node* listSearch(int key) {
    Node *cur = nil->next;
    while ( cur != nil && cur->key != key ) {
        cur = cur->next;
    }
    return cur;
}

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList() {
    Node *cur = nil->next;
    int isf = 0;
    while (true) {
        if ( cur == nil ) break;
        if ( isf++ > 0 ) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t) {
    if ( t == nil ) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    deleteNode(listSearch(key));
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main() {
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for ( i = 0; i < n; i++ ) {
        scanf("%s%d", com, &key);
        if ( com[0] == 'i' ) {
            insert(key);
            np++;
            size++;
        } else if ( com[0] == 'd' ) {
            if ( strlen(com) > 6 ) {
                if ( com[6] == 'F' ) deleteFirst();
                else if ( com[6] == 'L' ) deleteLast();
            } else {
                deleteKey(key);
                nd++;
            }
            size--;
        }
    }
    
    printList();
    
    return 0;
}

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

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    cout << (A-1)*(B-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  long long la,lb;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a >> b >> c;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------
  a = a-b;
  if(a>c) ans = 0;
  else ans = c-a;

  cout << ans << endl;

}

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

#define ll long long int
#define pi 3.141592653589793238
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007

    ll mod_pow(ll a,ll b,ll m)
    {
        ll res=1;
        while(b)
        {
            if(b&1)
                res=(res*a)%m;

            a=(a*a)%m;
            b>>=1;
        }
        return res;
    }

void solve()
{
    ll n;
    cin>>n;
    ll cnt=0;
    for(ll i=0;i<n;i++)
    {
        ll d1,d2;
        cin>>d1>>d2;
        if(d1==d2)
            cnt++;
        else
            cnt=0;
        if(cnt==3)
        {
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
    return;
}

int main()
{
    FAST;
    #ifndef ONLINE_JUDGE
        freopen("input1.txt","r",stdin);
        freopen("output1.txt","w",stdout);
    #endif
    ll q;
    q=1;
    // cin>>q;
    while(q--)
        solve();
    return 0;
}


Measured memory_bytes: 3656
using System;
using System.Linq;
using System.Collections.Generic;

class Cmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(x=>Int64.Parse(x)).ToArray();
        var count4 = 0;
        var count2 = 0;
        for (int i = 0; i < N; ++i)
        {
            if (a[i] % 4 == 0) count4++;
            else if (a[i] % 2 == 0) count2++;
        }
        var ans = (N / 2) <= (count4+count2/2) ? "Yes" : "No";
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 22880
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(ll i=p;i<n;i++)
#define fr1(i,p,n) for(ll i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n+1];
        fr(i,0,n+1) cin>>a[i];
        if(n==0)
        {
             if(a[0]==1) cout<<1<<endl;
             else cout<<-1<<endl;
             continue;
        }
        ll mn[n+1],mx[n+1];
        mx[0]=1,mn[0]=a[0]+1;
        mx[n]=a[n],mn[n]=a[n];
        fr(i,1,n)
        {
            if((mx[i-1]-a[i-1])<pow(2,62)) mx[i]=(mx[i-1]-a[i-1])*2;
            else mx[i]=LLONG_MAX;
            mn[i]=a[i]+1;
        }
        fr1(i,n-1,1)
        {
            mx[i]=min(mx[i],mx[i+1]+a[i]);
            mn[i]=max(mn[i],(ll)(ceil(mn[i+1]/2.0))+a[i]);
        }
        ll ans=0;
        bool f=0;
        fr(i,0,n+1)
        {
            ans+=mx[i];
            if(mn[i]>mx[i])
            {
                f=1;
                break;
            }
        }
        if(f==1) cout<<-1<<endl;
        else cout<<ans<<endl;
    }
    return 0;
}


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

int main(){
    int n,m;
    cin >> n;
    vector<long long> d(n,0);
    for(int i=0;i<n;i++)cin >> d[i];
    cin >> m;
    vector<long long> t(m,0);
    for(int i=0;i<m;i++)cin >> t[i];
    sort(d.begin(),d.end());
    sort(t.begin(),t.end());
    int frg=1,st=0;
    for(int i=0;i<m;i++){
        for(int j=st;j<n;j++){
            if(t[i]==d[j]){
                st=j+1;
                break;
            }else if(t[i]<d[j]){
                frg=0;
                break;
            }else if(m-i>n-j){
                frg=0;
                break;
            }
        }
        if(!frg)break;
    }
    if(frg)cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N;

int main(){
	cin >> N;
	cout << N*N*N << endl;
}

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

using namespace std;

int main(){
	int n,one;
	int sum = 0;

	while(cin >> n , n!=0){
		vector<int> v;
		sum = 0;
		
		for (int i = 0; i < n; i++)
		{
			cin >> one;
			v.push_back(one);
		}
		sort(v.begin(),v.end());
		for (int i = 1; i < v.size() -1 ; i++)
		{
			sum += v[i];
		}
		cout << sum/(v.size() - 2) << endl;
	}
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <algorithm>

int n,m;
int a[100];

int main()
{
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    int sum=0;
    for(int i=0;i<n;i++) sum+=a[i];
    std::sort(a,a+n);
    if(a[n-m]>=(double)sum/(4*m))printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 128
n = int(input())
flag = 0
flagg = 1
for _ in range(n):
    a, b = map(int, input().split())
    if flagg:
        if a==b:
            flag+=1
        else:
            flag = 0
        if flag==3:
            print('Yes')
            flagg = 0
if flag<3:
    print('No')


Measured memory_bytes: 9104
# https://atcoder.jp/contests/abc087/tasks/arc090_b
# ノードL→RへのコストはDであるとすれば、有向グラフと見なせる
# 任意のノードからbfsをして座標をメモしていけば良い。
# 探索済みのノードに到達したときに座標があっているかチェック、あっていればそれ以上探索する必要はない。

# 連結していないグラフがあるかもしれない。(だけど連結していないグラフはお互いに独立)
# 0以上10**9以下っていう制約なのでそこでWAを出されるかと思ったがそんなことなかった


import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


from collections import defaultdict, deque

N, M = read_ints()
graph = defaultdict(lambda: [])  # 有向グラフ、隣接リスト形式
for _ in range(M):  # データ読み込み
    l, r, d = read_ints()
    l -= 1
    r -= 1
    graph[l].append((r, d))
    graph[r].append((l, -d))

# bfs
X = [None] * N  # visitedも兼ねる


def bfs(u):  # スタートするノードを入れる
    que = deque([(u, 0)])  # (今のノード,今の座標)
    X[u] = 0
    while que:
        u, x = que.popleft()
        # print(u, x)
        for nu, add in graph[u]:
            nx = x + add
            if X[nu] == nx:
                continue
            # 次の探索
            if X[nu] is not None and X[nu] != nx:
                print('No')
                exit()
            X[nu] = nx
            que.append((nu, nx))


for u in range(N):
    if X[u] is None:
        bfs(u)
print('Yes')


Measured memory_bytes: 80552
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;

int getint(){
	int f=1,x=0;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
#define N 5100
#define inf 100000000000000000ll
int n,k;
pair<ll,int> a[N];
ll f[N][N];
int main(){
	n=getint(); k=getint();
	for(int i=1;i<=n;i++) a[i].first=getint(), a[i].second=i;
	sort(a+1,a+1+n);
	f[0][0]=0;
	for(int j=1;j<=k;j++) f[0][j]=inf;
	for(int i=n;i>=1;i--) {
		ll x=a[i].first;
		for(int j=1;j<=k;j++) {
			f[i][j]=f[i+1][j];
			if(j>x) f[i][j]=max(f[i][j],f[i+1][j-x]+x);
		}
	}
	int ans=n;
	for(int i=1;i<=n;i++) {
		ll x=a[i].first;
		if(x>=k||f[i+1][k]+x>=k) {
			ans=i-1;
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 200960
#include <iostream>


using namespace std;


int main()
{
    int H, W;
    cin >> H >> W;

    char C[100][100] = { { 0 } };
    for( int i = 0; i < H; ++i ){
        for( int j = 0; j < W; ++j ){
            cin >> C[i][j];
        }
    }


    char ans[200][100] = { { 0 } };
    for( int i = 0; i < H; ++i ){
        for( int j = 0; j < W; ++j ){
            ans[2*i][j] = C[i][j];
            ans[2*i+1][j] = C[i][j];
        }
    }


    for( int i = 0; i < 2*H; ++i ){
        for( int j = 0; j < W; ++j ){
            cout << ans[i][j];
        }
        cout << endl;
    }


    return 0;
}

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

using namespace std;
#define ll long long

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

    int n,k;
    cin>>n>>k;

    vector<int> arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];

    sort(arr.begin(), arr.end());

    int sum = 0;
    for(int i=0;i<k;i++)
        sum += arr[i];
    
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3648
import java.util.*;
import java.awt.geom.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(sc.hasNextLine()){
            Path2D.Double sank = new Path2D.Double();
            String[] data = sc.nextLine().split(" ");
            double[] z = new double[8];
            for(int i=0;i<8;i++){
                z[i]=Double.parseDouble(data[i]);
            }
            sank.moveTo(z[0], z[1]);
            sank.lineTo(z[2], z[3]);
            sank.lineTo(z[4], z[5]);
            
            Point2D.Double pt = new Point2D.Double(z[6], z[7]);
            String ans = "NO";
            if(sank.contains(pt)){
                ans="YES";
            }
            System.out.println(ans);
        }
    }
}

Measured memory_bytes: 16432
n,w=list(map(int, input().split()))
wv=[list(map(int, input().split())) for _ in range(n)]

dp = [[-float("inf") for _ in range(w+1)] for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
    for j in range(w+1):
        if j >= wv[i][0]:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - wv[i][0]] + wv[i][1])
        else:
            dp[i+1][j] = dp[i][j]

print(max(dp[-1]))



Measured memory_bytes: 319940
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int a = 0, b = 0, c = 0;
    cin >> a >> b >> c;
    int maxi = max(a, max(b, c));
    int diff = maxi * 3 - a - b - c;
    if (diff%2 == 0) {
        cout << diff/2 << endl;
    }
    else {
        cout << diff/2+2 << endl;
    }
    return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
int H,W;
char A[1010][1010];
queue<pii> pa[2];
int i,j,ans;
int px[] = {1, 0, -1, 0}, py[] = {0, 1, 0, -1};
int main(){
    scanf("%d%d", &H,&W);
    fornum(i,0,H){
        scanf("%s", A[i]);
    }
    fornum(i,0,H){
        fornum(j,0,W){
            if(A[i][j]=='#'){
                pa[0].push({i, j});
            }
        }
    }
    
    while(!pa[ans%2].empty()){
        int a = ans % 2;
        ans++;
        while(!pa[a].empty()){
            auto p = pa[a].front();
            pa[a].pop();
            fornum(i,0,4){
                int y = p.first + py[i];
                int x = p.second + px[i];
                if(0<=y&&y<H&&0<=x&&x<W&&A[y][x]=='.'){
                    A[y][x]='#';
                    pa[!a].push({y, x});
                }
            }
        }
    }
    printf("%d",ans-1);
    return 0;
}

Measured memory_bytes: 9360
// AOJ 2013: Osaki
// 2017.11.1 bal4u@uu
// 2017.12.30

#include <stdio.h>
#include <stdlib.h>

typedef struct { int t; int a; } T;
T tbl[20005]; int sz; 
char buf[30], *p;

int in()
{
	int n;
	n = *p++ & 0xf;
	n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}

int cmp(T *a, T *b) { if (a->t - b->t) return a->t - b->t; return a->a - b->a; }

int main()
{
	int n, i, h, m, s, t, ans;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		sz = 0;
		while (n--) {
			fgets(p=buf, 30, stdin);
			h = in(), m = in(), s = in();
			tbl[sz].t = ((h*60)+m)*60+s, tbl[sz++].a = 1;

			h = in(), m = in(), s = in();
			tbl[sz].t = ((h*60)+m)*60+s, tbl[sz++].a = -1;
		}

		qsort(tbl, sz, sizeof(T), cmp);

		ans = t = 0;
		for (i = 0; i < sz; i++) {
			t += tbl[i].a;
			if (t > ans) ans = t;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1948
#define ll long long int
#include<bits/stdc++.h>
using namespace std;
ll max(ll x,ll y)
{
    if(x>=y)
    {
        return x;
    }
    else
    {
        return y;
    }
}
int main()
{


    ll n,m,s=0;
    cin>>n>>m;
 ll a[n+1];
 a[0]=0;
 for(ll i=1;i<=n;i++)
 {
     ll k;
     cin>>k;
     a[i]=s+k;
     s=a[i];
 }
 ll sum=0;
 for(ll i=m;i<=n;i++)
 {
     //cout<<a[i]<<endl;
     sum=max(a[i]-a[i-m],sum);

 }
 ll sum1= (sum+m)/2;
 if(sum1*2==sum+m)
 {
     cout<<sum1<<".000000000000";
 }
 else
 {
     cout<<sum1<<".500000000000";
 }

}

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

bool isPalindrome(const string& s1, int a, int b) {
	for (int i = a, j = b - 1; i <= b && j >= a; i++, j--) {
		if (s1[i] != s1[j])
			return false;
	}
	
	return true;
}

bool strongPalindrome(const string& s1, int n) {
	bool palindrome1 = isPalindrome(s1, 0, n);
	bool palindrome2 = isPalindrome(s1, 0, (n - 1) / 2);
	bool palindrome3 = isPalindrome(s1, (n + 3) / 2, n - 1);

	if (palindrome1 && palindrome2 && palindrome3)
		return true;

	return false;
}

int main() {
	string s; cin >> s;
	if (strongPalindrome(s, s.size()))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()

res = 0
cnt = 0
if N == 1:
    res = 1
for i in range(N):
    if i == 0:
        cnt = 1
    else:
        if A[i-1]==A[i]:
            cnt += 1
            if i == N-1:
                res += cnt%2
        else:
            res += cnt%2
            cnt = 1
            if i == N-1:
                res += 1
print(res)

Measured memory_bytes: 7492
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int leng_s;
  leng_s=s.size();
  int ans=0;
  int zeroco=0;
  int oneco=0;
  for(int i=0;i<leng_s;i++){
    if(s.at(i) =='0'){
      zeroco++;
    }else{
    oneco++;
    }
  }
  ans=2*min(zeroco,oneco);
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
signed main() {
  ll n; cin >> n;
  ll weights[n];
  map<ll, ll> left_mp, right_mp;
  for(ll i = 0; i < n; ++i) {
    cin >> weights[i];
    ++left_mp[i - weights[i]];
    ++right_mp[i + weights[i]];
  }
  ll ans = 0;
  for(auto& right : right_mp) ans += right.second * left_mp[right.first];
  cout << ans << "\n";
  return 0;
}

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

//ABC156D
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}


 
int main() {
  int n, m;
  cin >> n >> m;
  
  mint ans=0;
  if(n>1) {
      ans+=choose(n,2);
  }
  if(m>1) {
      ans+=choose(m,2);
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>

#define reps(i,f,n) for(int i = f; i < int(n); i++)
#define rep(i,n) reps(i,0,n)
using namespace std;

int to[10000];
int memo[10000];

void init(){
	int L,S;
	char rstr[8];
	char str[8];
	rep(i,10000)memo[i] = -1;
	rep(i,10000){
		sprintf(rstr,"%04d", i);
		sprintf(str,"%04d", i);
		sort(rstr,rstr+4);
		sort(str,str+4);
		reverse(str, str+4);
		L = atoi(str);
		S = atoi(rstr);
		to[i] = L-S;
	}
}

int main(void){
	int n;
	init();
	
	while(scanf("%d", &n),n){
		int ans = 0;
		int n_ = n;
		if(to[n] == 0){
			puts("NA");
			continue;
		}
		if(memo[n] != -1){
			ans = memo[n];
		}else{
			while(n != 6174){
				n = to[n];
				ans++;
			}
			memo[n_] = ans;
		}
		printf("%d\n", ans);
	}
	
	return 0;
}

Measured memory_bytes: 1300
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
using namespace std;

int main()
{
	int nA,nB;
	cin >> nA >> nB;
	char strS[20];
	memset(strS, NULL, sizeof(strS));
	cin >> strS;
	char szTmpValA[20];
	memset(szTmpValA, NULL, sizeof(szTmpValA));
	strncpy(szTmpValA, strS, nA);
	char szTmpValB[20];
	memset(szTmpValB, NULL, sizeof(szTmpValB));
	strncpy(szTmpValB, &strS[nA+2], nB);

	int nTotalLen = nA + nB + 1;
	if (strlen(strS) != nTotalLen)
	{
		cout << "No";
		return 0;
	}

	bool bErr = false;
	for (int i = 0; i < nTotalLen; i++)
	{
	
		if (i != nA)
		{
			if (0 == isdigit(strS[i]))
			{
				bErr = true;
				break;
			}
		}
		else
		{
			if ('-' != strS[i])
			{
				bErr = true;
				break;
			}
		}
	}

	if (bErr)
		cout << "No";
	else
		cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
from heapq import heappop,heappush
import sys
input=sys.stdin.readline

q=int(input())
query=[list(map(int,input().split())) for _ in range(q)]
inf=10**12
left=[inf]
left_sum=0
right=[inf]
right_sum=0

cnt=0
b=0
for i in range(q):
    if query[i][0]==1:
        a=query[i][1]
        b+=query[i][2]
        if cnt==0:
            d=right[0]
            if a>d:
                heappush(left,-heappop(right))
                heappush(right,a)
                right_sum+=a-d
                left_sum-=d
            else:
                heappush(left,-a)
                left_sum-=a
            cnt=1
        else:
            c=-left[0]
            if a<c:
                heappush(right,-heappop(left))
                heappush(left,-a)
                right_sum+=c
                left_sum+=c-a
            else:
                heappush(right,a)
                right_sum+=a
            cnt=0
    else:
        x=-left[0]
        if cnt==0:
            print(x,b+right_sum+left_sum)
        else:
            print(x,b+x+right_sum+left_sum)

Measured memory_bytes: 107996
using System;

class Program
{
    static void Main()
    {
        double r = double.Parse(Console.ReadLine());
        //面積
        double a = r * r * Math.PI;
        //円周
        double b = (r + r) * Math.PI;
        
        string result = string.Format("{0:f6} {1:f6}", a, b);
        Console.WriteLine(result);
    }
}


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

int main() {
    int n, ans, mini = 100000000;
    cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    // int sum = accumulate(x.begin(), x.end(), 0);
    rep(i, 100) {
        int dist = 0;
        rep(j, n) { dist += (i - x[j]) * (i - x[j]); }
        if(mini > dist) {
            mini = dist;
            ans = i;
        }
        // cout << mini << endl;
    }
    cout << mini << endl;
    return 0;
}


Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include <numeric>
#include<vector>

#define LL long long
#define MOD 1000000007

using namespace std;

LL gcd(LL C, LL D) {
	if (C < D) gcd(D, C);

	if (C%D == 0)return D;
	else gcd(D, C%D);
}


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

	for (int i = 0; i < n; i++) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0 && a[i] % 5 != 0) {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
	cin >> n;
	return 0;

}





Measured memory_bytes: 256
import java.util.Scanner;

//Luck Manipulator
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt(), A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), X = sc.nextInt();
			if((n|A|B|C|X)==0)break;
			int[] y = new int[n];
			for(int i=0;i<n;i++)y[i]=sc.nextInt();
			int f = 0, k = 0, x = X;
			while(f<=10000){
				if(y[k]==x)k++;
				if(k==n)break;
				x = (A*x+B)%C;
				f++;
			}
			System.out.println(k==n?f:-1);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,m;
    cin >> n >> m;
    int a,b;
    vector <int> v(50,0);
    REP(i,m){
        cin >> a >> b;
        v[a-1]++;
        v[b-1]++;
    }
    REP(i,n){
        cout << v[i] << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  if (A == B && B == C)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 1005

ll n,m;
vector<ll> adj[MAX];
vector<ll> transpose[MAX];

bool ans;
vector<ll> final;
ll root;
ll visited[MAX];

bool f(ll s,ll parent,bool ok){
	visited[s]=1;

	bool no_back = 1;
	for(ll x:adj[s])
	{
		if(visited[x]==2) continue;
		if(x==root) continue;
		if(visited[x]==1) no_back = 0;
	}
	for(ll x:transpose[s])
	{
		if(visited[x]==2) continue;
		if(x==parent) continue;
		if(visited[x]==1) {
			no_back = 0;
		}
	}

	for(ll x:adj[s])
	{
		if(visited[x]==1 && x==root && ok && no_back)
		{
			ans = 1;
			final.pb(s);
			return 1;
		} 
	}	

	for(ll x:adj[s]) if(visited[x]==0)
	{
		if(f(x,s,ok && no_back)){
			final.pb(s);
			return 1;
		}
	}

	visited[s]=2;
	return 0;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ans = 0;
	cin>>n>>m;
	For(i,0,m){
		ll x,y;cin>>x>>y;x--;y--;
		adj[x].pb(y);
		transpose[y].pb(x);
	}

	For(start,0,n)
	{
		memset(visited,0,sizeof(visited));
		root = start;
		f(root,-1,1);
		if(ans){
			cout<<final.size()<<endl;
			for(ll x:final){
				cout<<x+1<<endl;
			}
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;





























	
}

Measured memory_bytes: 384
//          ★★ ASHWINI SHARMA ★★ 
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define ull unsigned long long int
#define ll long long int
#define ui unsigned int
#define pb push_back
 
#define PI 3.1415926535897932385
#define INF 1e9
#define EPS 1e-7
#define MAXN 1000000005
#define MOD 1000000007 
                              //          ★★ ASHWINI SHARMA ★★      
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll exp(ll x, ll y, ll p)
{
    ll res = 1;   
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)    
            res = (res*x) % p;
        y = y>>1;     
        x = (x*x) % p; 
    }
    return res;
}

int smallest_div[1000005];
 
void Sieve(int n) {
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
    for(int p=2;p*p<=n;p++)
    {
        if(prime[p])
        {
            for(int i=p*p;i<=n;i+=p)
            {
                prime[i] = false;
                smallest_div[i] = min(smallest_div[i], p);
            }
        }
    }
}


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

    rep(i, 1000005)
    smallest_div[i] = i;
    Sieve(1000000);
    int a[n];
    int gcd_all;
    bool ans = true;
    unordered_set<int> us;
    vector<int> v1;
    rep(i, n)
    {
        cin >> a[i];
        if(i == 0)
            gcd_all = a[i];
        else
            gcd_all = gcd(gcd_all, a[i]);

        int y = a[i];
    
        v1.clear();
        int div = smallest_div[y];
        if(div != 1)
        v1.pb(div);
        if(us.count(div))
        {
           ans = false;
           //cout << div << " ";
       }
        while(y != 1 && ans)
        {
            while(y % div == 0)
            {
                y /= div;
            }
            div = smallest_div[y];
            if(div != 1)
            v1.pb(div);
            if(us.count(div))
            {
                ans = false;
                //cout << div << " ";
            }
        }
        if(ans)
        {
            rep(j, v1.size())
            us.insert(v1[j]);
        }
                
         //cout << endl;       
                
        
            
    }
    if(ans)
        cout << "pairwise coprime";
    else if(gcd_all == 1)
        cout << "setwise coprime";
    else
        cout << "not coprime";




    







    return 0; 
}

Measured memory_bytes: 11504
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
#define LL long long
const int N = 1e5+5;
int x[N];
 
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	int ans=0x3f3f3f3f;
	for(int i=1;i<=n;i++)
		scanf("%d",&x[i]);
 
	for(int i=1;i<=n-k+1;i++){
		int l=i,r=i+k-1;
		if(x[l]<=0&&x[r]<=0){
			ans=min(ans,-x[l]);
		}
		else if(x[l]<=0&&x[r]>=0){
			ans=min(ans,-2*x[l]+x[r]);
			ans=min(ans,-x[l]+2*x[r]);
		}else{
			ans=min(ans,x[r]);
		}
	}
	printf("%d\n",ans);
 
 
 
	return 0;
}

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

using namespace std;
#define ll long long
const int N = 1e5 + 5;
vector<int> g[N];
int dist[N][3];

int bfs(int source, int target) {
    for (int i = 0; i < N; i++) for (int j = 0; j < 3; j++) dist[i][j] = 1e8;
    queue<pair<int, int> > q;
    q.push({source, 0});
    dist[source][0] = 0;
    while (q.size()) {
        int node = q.front().first;
        int mod = q.front().second;
        q.pop();
        for (auto child:g[node]) {
            int nmod = (mod + 1) % 3;
            if (dist[child][nmod] > dist[node][mod] + 1) {
                dist[child][nmod] = dist[node][mod] + 1;
                q.push({child, nmod});
            }
        }
    }
    if (dist[target][0] > 1e7) return -1;
    return dist[target][0] / 3;
}

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

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
     }
    int s, t;
    cin >> s >> t;
    cout << bfs(s, t) << endl;
    return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    vector<ll> am;
    ll am_total = 0;
    ll bm_total = 0, bm_cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == b[i])
        {
            continue;
        }
        else if (a[i] > b[i])
        {
            am_total += (a[i] - b[i]);
            am.push_back(a[i] - b[i]);
        }
        else if (b[i] > a[i])
        {
            bm_total += (b[i] - a[i]);
            ++bm_cnt;
        }
    }
    if (am_total < bm_total)
    {
        cout << -1 << endl;
        return 0;
    }
    if (bm_total == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    sort(am.begin(), am.end());
    reverse(am.begin(), am.end());
    ll total = 0;
    for (int i = 0; i < am.size(); i++)
    {
        total += am[i];
        if (total >= bm_total)
        {
            cout << i + 1 + bm_cnt << endl;
            return 0;
        }
    }
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
};

Measured memory_bytes: 5460
#include<bits/stdc++.h>
using namespace std;
long long mod =998244353;
int a[200009];
int b[200009];
main(){
    int n;
    cin >> n;
    set<pair<int,int> > s;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int k = 0;
    for(int i = 0; i < n; i++){
        cin >> b[i];
        if(b[i] == a[i]) k++;
        else
        s.insert({b[i], i});
    }
    long long t= 0;
    while(s.size()){
        auto it = --s.end();
        int x = it->second;
        s.erase(s.find({b[x],x}));
        int u = b[(x+1)%n], v = b[(x+n-1)%n];
        int m = max(a[x], max(u,v));
        int K = max(1, (b[x] - m + u + v - 1) / (u + v));

        t += K;
        b[x] -= K * (u+v);
        if(b[x] < a[x]){
            cout<<-1<<endl;
            return 0;
        } else if(a[x] != b[x]) s.insert({b[x],x});
      //  t++;

    }
    cout << t << endl;

}


Measured memory_bytes: 13184
X = int(input())
def is_prime(n): 
  i = 2
  while i * i <=n:
    if n % i == 0:
      return False
    i += 1
  return True
  
INF = 10 ** 9
  
judge = is_prime(X)

if judge == True:
  print(X)
else:
  if X % 2 == 0:
    X = X + 1
    for i in range(X,INF,2):
      judge = is_prime(i)
      if judge == True:
        print(i)
        break
  else:
    for i in range(X,INF,2):
      judge = is_prime(i)
      if judge == True:
        print(i)
        break

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

int n, id;
string s[1000];
char c[1000];
int depth[1000];

int f(int d) {
	if (isdigit(c[id])) {
		int ret = c[id] - '0';
		id++;
		return ret;
	}
	if (c[id] == '+') {
		id++;
		int ret = 0;
		while (id < n && depth[id] == d + 1) {
			ret += f(d + 1);
		}
		return ret;
	}
	id++;
	int ret = 1;
	while (id < n && depth[id] == d + 1) {
		ret *= f(d + 1);
	}
	return ret;
}

int main() {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> s[i];
			depth[i] = s[i].size() - 1;
			c[i] = s[i].back();
		}
		id = 0;
		cout << f(0) << endl;
	}

}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数leng
#define INF 9223372036854775807 //  巨大数INF
using namespace std;

signed main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N) cin >> a[i];
  sort(a.begin(), a.end());
  a.at(N-1) /= 2;
  int ans = 0;
  rep(i, N) ans += a[i];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 1e5;
int N, U[Nmax], V[Nmax];
ll W[Nmax];

void dfs(int v, vector<vector<pair<int, int> > > &graph, vector<int> &ans){
    // cout << v << endl;
    for(auto p: graph[v]){
        if(ans[p.first]>=0) continue;
        if(p.second==0){
            ans[p.first] = ans[v];
        } else {
            ans[p.first] = 1-ans[v];
        }
        dfs(p.first, graph, ans);
    }
}
int main(){
    cin >> N;
    for(int i=0; i<N-1; i++){
        cin >> U[i] >> V[i] >> W[i];
        U[i]--; V[i]--;
    }
    vector<vector<pair<int, int> > > graph(N);
    for(int i=0; i<N-1; i++){
        // cout << U[i] << " " << V[i] << endl;
        graph[U[i]].push_back({V[i], W[i]%2});
        graph[V[i]].push_back({U[i], W[i]%2});
    }
    vector<int> ans(N, -1);

    ans[0] = 0;
    dfs(0, graph, ans);

    for(int i=0; i<N; i++){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 10496
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll a,b;
    std::cin >> a>>b;
    if(a+b==15){
        std::cout << "+" << std::endl;
    }else if(a*b==15){
        std::cout << "*" << std::endl;
    }else{
        std::cout << "x" << std::endl;
    }
}


Measured memory_bytes: 256