akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(void){
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    for(int i=0; i<M; i++) cin >> a[i] >> b[i];
    
    vector<int> sm;
    vector<int> me;
    for(int i=0; i<M; i++) {
        if(a[i] == 1) sm.push_back(b[i]);
        if(b[i] == N) me.push_back(a[i]);
    }
    sort(sm.begin(), sm.end());
    sort(me.begin(), me.end());
    vector<int> inter;
    set_intersection(sm.begin(), sm.end(), me.begin(), me.end(), back_inserter(inter));
    cout << (inter.size()>0 ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;    
}


Measured memory_bytes: 2812
#include <stdio.h>

int main()
{
	int n,i,j;
	scanf("%d", &n);
	for(i=1;i<=n;i++){
		if(i%3==0){
			printf(" %d",i);
		}else{
			for(j=i;j;j/=10){
				if(j%10==3){
					printf(" %d",i);
					break;
				}
			}
		}
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 596
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, k;
  rd(n, k);
  auto x = new long[](n), y = new long[](n);
  foreach (i; 0 .. n)
    rd(x[i], y[i]);

  long mn = 9 * 10L ^^ 18;
  foreach (a; 0 .. n) {
    foreach (b; 0 .. n) {
      foreach (c; 0 .. n) {
        foreach (d; 0 .. n) {
          auto left = x[a], right = x[b], top = y[c], bottom = y[d];
          int count = 0;
          foreach (i; 0 .. n) {
            if (left <= x[i] && x[i] <= right && bottom <= y[i] && y[i] <= top) {
              count++;
            }
          }
          if (count >= k) {
            mn = min(mn, (right - left) * (top - bottom));
          }
        }
      }
    }
  }
  writeln(mn);
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


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

int main() {
    long long a, b, c;
    cin >> a >> b >> c;
    long long d = c - a - b;

    if (d > 0 && d * d > 4 * a * b) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String name=br.readLine();
		int num;
		int compare;

		int[] a=new int[2];
		int i=0;

		int tmp;
		int x,y;
		while(true){

			try{

				StringTokenizer st=new StringTokenizer(name," ");
			     while (st.hasMoreTokens()) {
			    	 a[i]=Integer.parseInt(st.nextToken());
			    	 i++;
			     }i=0;

			     if (a[0] > a[1]) {
			            x = a[0];
			            y = a[1];
			        } else {
			            x = a[1];
			            y = a[0];
			        }

			     while((tmp=x%y)!=0){
			    	 tmp=x%y;
			    	 x = y;
			         y = tmp;
			     }

			     System.out.println(y+" "+a[0]/y*a[1]);
				a[0]=0;
				a[1]=0;
				x=0;
				y=0;
				tmp=0;
				name=br.readLine();
			}

			catch(Exception e){
				System.exit(0);
			}
		}
	}
}

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

using namespace std;

int ans, n, m, a[(int)1e5];
int dp[(int)1e5+1];
bool br[(int)1e5+1];

int main(){
	cin >> n >> m;
	for(int i = 0; i < m; ++i) cin >> a[i];
	
	for(int i = 0; i < m - 1; ++i){
		if(a[i] + 1 == a[i+1]){
			cout << 0 << endl;
			return 0;
		}
	}
	
	dp[0] = dp[1] = 1;
	for(int i = 0; i < m; ++i) br[a[i]] = true;
	
	for(int i = 2; i <= n; ++i){
		if(!br[i-2]){
			dp[i] += dp[i-2];
			dp[i] %= (int)1e9+7;
		}
		if(!br[i-1]){
			dp[i] += dp[i-1];
			dp[i] %= (int)1e9+7;
		}
	}
	
	cout << dp[n] << endl;
}


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

int main(void) {
  int N, T, c, t;
  cin >> N >> T;

  int answer = 1001;
  for (int i = 1; i <= N; i++) {
    cin >> c >> t;
    if (t <= T && c < answer) {
      answer = c;
    }
  }

  if (answer == 1001) {
    cout << "TLE" << endl;
  } else {
    cout << answer << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   long int n;
   cin>>n;

   if(n >= 30)
        cout<<"Yes\n";
    else
        cout<<"No\n";

   return 0;
}

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

using namespace std;

typedef long long ll;
const int N = 1e6+10;
struct Edge{
    int u,v;
    ll w;
    bool const operator < (const Edge & a) const
    {
        return w < a.w;
    }
}edge[N];
int tot = 0;
struct Node{
    int u,v,ind;
}node[N];
int cmp1(Node a,Node b){ return a.u < b.u;}
int cmp2(Node a,Node b){  return a.v < b.v;}
int pre[N];
int find(int x){    return x == pre[x]?x:pre[x] = find(pre[x]);}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0; i <= n;i++)
        pre[i] = i;
    for(int i = 0; i < n;i++)
        scanf("%d%d",&node[i].u,&node[i].v),node[i].ind = i;
    sort(node,node+n,cmp1);
    for(int i = 1;i < n;i++)
        edge[tot].u = node[i-1].ind,edge[tot].v = node[i].ind,edge[tot++].w = abs(node[i].u - node[i-1].u);
    sort(node,node+n,cmp2);
    for(int i = 1;i < n;i++)
        edge[tot].u = node[i-1].ind,edge[tot].v = node[i].ind,edge[tot++].w = abs(node[i].v - node[i-1].v);
    sort(edge,edge+tot);
    ll ans = 0;
    for(int i = 0;i < tot;i++)
    {
        int u = edge[i].u,v = edge[i].v;
        ll w = edge[i].w;
        int preu = find(u),prev = find(v);
        if(preu != prev)
        {
            ans += w;
            pre[preu] = prev;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
#include <atcoder/all>

using namespace std;
using namespace atcoder;
typedef long long ll;

/*
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
void Add(ll &pos,ll val){pos=mod(pos+val);}
void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
*/

#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

typedef long double dd;
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
dd EPS=1E-12;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second

#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;


using mint = modint998244353;
//using mint = modint1000000007;
//////////////////////////

struct S{
    ll sum,c0,c1;
};
S op(S l,S r){
    return S{l.sum+r.sum+l.c1*r.c0,l.c0+r.c0,l.c1+r.c1};
}
S e(){
    return S{0,0,0};
}
struct F{
    bool f;
};
S mapping(F f,S x){
    if(!f.f)return x;
    ll n=x.c0+x.c1;
    return S{n*(n-1)/2-x.c0*(x.c0-1)/2-x.c1*(x.c1-1)/2-x.sum,x.c1,x.c0};
}
F composition(F f,F g){
    F ret;
    ret.f=f.f^g.f;
    return ret;
}
F id(){
    return F{false};
}

int main(){fastio
    ll n,q;cin>>n>>q;
    vector<S>a(n+1);
    rep(i,1,n){
        ll x;cin>>x;
        if(x==0){
            a[i]=S{0,1,0};
        }else{
            a[i]=S{0,0,1};
        }
    }
    lazy_segtree<S,op,e,F,mapping,composition,id>seg(a);
    
    while(q--){
        ll t,l,r;cin>>t>>l>>r;
        if(t==1){
            seg.apply(l,r+1,F{true});
        }else{
            cout<<seg.prod(l,r+1).sum<<endl;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 20416
#include<bits/stdc++.h>
 #define ll long long int
 ll dp[3010][3030];
using namespace std;
int main()
{
   ll n;
   cin>>n;
   ll a[n];
   for(ll i=0;i<n;i++)
    cin>>a[i];
    for(int i=n-1;i>=0;i--)
        for(int j=i;j<n;j++)
            if(i==j)
                dp[i][j]=a[i];
            else
                dp[i][j]=max((a[i]-dp[i+1][j]),(a[j]-dp[i][j-1]));
    cout<<dp[0][n-1]<<endl;
}

Measured memory_bytes: 49776
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>

#define ll long long
using namespace std;

int main() {
	ll n, hoge, max, sum;
	vector<int> l;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> hoge;
		l.push_back(hoge);
	}
	auto itr = max_element(l.begin(), l.end());
	sum = accumulate(l.begin(), l.end(), 0);
	sum -= *itr;
	if (sum > *itr)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int n = Integer.parseInt(sc.nextLine());

			List<Integer> list = new ArrayList<Integer>();
			for (int i = 0; i < n; i++) {
				int d = Integer.parseInt(sc.nextLine());
				if (!list.contains(d)) {
					list.add(d);
				}
			}

			System.out.println(list.size());

			sc.close();
		}
}

Measured memory_bytes: 21844
howmany = []
howmuch = []
x = gets
until x.nil?
 y = x.split(",")
 howmany << (y[0].to_i * y[1].to_i)
 howmuch << y[1].to_f
 x = gets
end

averegemuch = howmuch.sum / howmuch.length
totalmoney = averegemuch.round
totalsum = howmany.sum
puts totalsum
puts totalmoney


Measured memory_bytes: 6856
#include <iostream>
#include <vector>
#include <map>

using namespace std;

int main() {
	while(true) {
		int W, Q;
		cin >> W >> Q;
		if(!W && !Q) break;

		vector<bool> wall(W+1, true);
		wall[W] = false;
		map<int, pair<int, int> > catpos;
		while(Q--) {
			char c;
			cin >> c;
			if(c == 's') {
				int id, w;
				cin >> id >> w;
				for(int i = 0; i < W; ++i) {
					if(!wall[i]) continue;
					bool ok = true;
					for(int j = i; j < i+w; ++j) {
						if(!wall[j]) {
							i = j;
							ok = false;
							break;
						}
					}
					if(ok) {
						for(int j = i; j < i+w; ++j) {
							wall[j] = false;
						}
						catpos[id] = make_pair(i, w);
						cout << i << endl;
						goto next;
					}
				}
				cout << "impossible" << endl;
			}
			else {
				int id;
				cin >> id;
				int i = catpos[id].first;
				int w = catpos[id].second;
				for(int j = 0; j < w; ++j) {
					wall[i+j] = true;
				}
			}
next:
			;
		}
		cout << "END" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char s[256], t[256];
    int ans = 0;
    scanf("%s", &s);
    scanf("%*c%s", &t);
    for (int i = 0; i <= 2; i++)
    {
        if (s[i] == t[i]){
            ans++;
        }
    }
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int d(int a,int b)
{
	int c;
	if(a<=b){
		c=b-a;
	}else if(a>b){
		c=a-b;
	}
	return c;
}

int main(void)
{
	int n,k,x[101],i,a=0;
	scanf("%d%d",&n,&k);
	for(i=0; i<n; i++){
		scanf("%d",&x[i]);
		if(x[i]>=d(x[i],k)){
			a=a+d(x[i],k)*2;
		}else if(x[i]<d(x[i],k)){
			a=a+x[i]*2;
		}
	}
	printf("%d\n",a);
	return 0;
}

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

int N;
int Z;
int W;
int as[11451];

int main() {
  scanf("%d%d%d", &N, &Z, &W);
  for (int i=0; i<N; i++) {
    scanf("%d", &as[i]);
  }

  if (N == 1) {
    printf("%d\n", abs(W-as[0]));
    return 0;
  }

  printf("%d\n", max(abs(as[N-1]-as[N-2]), abs(as[N-1]-W)));
}
  


Measured memory_bytes: 256
#include <iostream>
using i64 = long long;

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

    i64 ret = 0;
    for (i64 i = 1; i <= n; i++) ret += i * (n - i + 1);

    for (int i = 1; i < n; i++) {
        i64 u, v;
        std::cin >> u >> v;
        if (u > v) std::swap(u, v);
        ret -= u * (n - v + 1);
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define pb              push_back
#define endl            "\n"
 
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define mii             map <int, int>
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>
 
#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))
 
#define M               1000000007
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()
 
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl
 
inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}
 
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
 
const int N = 2e5 + 7;
 
 
 
void solve()
{
	int k;
	cin >> k;
	int sum = 0;
	loop(a, 1, k + 1)
	{
		loop(b, 1, k + 1)
		{
			loop(c, 1, k + 1)
			{
				sum += __gcd(a, __gcd(b, c));
			}
		}
	}
	cout << sum;
	return;
}
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
 
 
	cout << setprecision(9) << fixed;
 
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
 
 
	return 0;
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main() {
	string s; cin >> s;
	int mi = 1e9,cnt1=0,cnt2=0;
	rep(i, 0, s.size()) {
		if (s[i] == '0') cnt1++;
		else cnt2++;
	}
	if (cnt1==s.size()||cnt2 == s.size()) {
		cout << s.size() << endl;
		return 0;
	}
	rep(i, 0, s.size()-1) {
		if (s[i] != s[i + 1]) {
			if (mi > max(i+1, (int)s.size() - i-1)) {
				mi = max(i+1, (int)s.size() - i-1);
			}
		}
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	int n;
	int c[4][13] = {{}};
	int i;
	char a;
	int b;
	cin >> n;

	for (i = 0; i < n; i++){
		cin >> a >> b;
		switch (a){
		case 'S':
			c[0][b - 1] = 1;
			break;
		case 'H':
			c[1][b - 1] = 1;
			break;
		case 'C':
			c[2][b - 1] = 1;
			break;
		case 'D':
			c[3][b - 1] = 1;
			break;
		}
	}

	for (i = 0; i < 52; i++){
		switch (i / 13){
		case 0:
			if (c[0][i % 13] == 0)cout << "S " << i % 13 + 1 << endl;  break;
		case 1:
			if (c[1][i % 13] == 0)cout << "H " << i % 13 + 1 << endl;  break;
		case 2:
			if (c[2][i % 13] == 0)cout << "C " << i % 13 + 1 << endl;  break;
        case 3:
			if (c[3][i % 13] == 0)cout << "D " << i % 13 + 1 << endl;  break;
		}
	}

	return 0;
}
   





Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    int r = 0;
    ll sum = 0;
    ll ans = 0;
    rep(l,n){
        while(r < n && (sum ^ a[r]) == (sum + a[r])){
            sum += a[r];
            r++;
        }
        ans += r-l;
        if(l == r) r++;
        else sum -= a[l];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	long long int a,b,t,m,n;
	long long int x; 
	scanf("%lld%lld",&a,&b);
	m=a;
	n=b;
	    if(a<b)
	{
		t=a;a=b;b=t;
	 } 
	 while(a%b)
	 {
	 	t=b;
	 	b=a%b;
	 	a=t;
	 }
	 x=m*n/b;
	 printf("%lld",x);  
	return 0;
}

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

int main(){
    int H,W;
    string in[100];
    cin>>H>>W;
    for(int i=0;i<H;i++) {
        cin>>in[i];
        cout<<in[i]<<endl<<in[i]<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b,c,d,e,k;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&k);

    if(e-a<=k && d-a<=k && c-a<=k && b-a<=k){
        printf("Yay!\n");
    }
    else if(e-a>k || d-a>k || c-a>k || b-a>k){
        printf(":(\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1LL<<60;

int main()
{
  ll N;cin>>N;
  // ll A[N];
  // ll even=0;
  ll odd =0;
  rep(i, N) {
    ll tmp; cin>>tmp;
    if(tmp%2!=0) odd++;
  }

  if(odd%2==0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	set<int> s = { 1,2,3,5,6,9,10,13,17 };
	cout << (s.find(n) == s.end() ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
map<char, int> m;
signed main() {
   int n;
   cin >> n;
   vector<int> a(n);
   rep(i,n) {
       cin>>a[i];
   }
   int gc = a[0];
   rep(i,n) {
       gc = __gcd(gc,a[i]);
   }
   cout << gc << endl;
   

}



Measured memory_bytes: 3964
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: l,r,i,j,md

    read*, l,r
    if (r-l+1 >= 3000) then
        print'(i0)', 0
        stop
    end if
    md=50000000
    do i=l,r-1
        do j=i+1,r
            md=min(md,mod(i*j,2019))
        end do
    end do
    print'(i0)', md
end program name

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;

int main()
{
    string s;
    cin >> s;
    for(int i=0; i<3; i++){
        if(s[i]=='9') s[i]='1';
        else if(s[i]=='1') s[i]='9';
    }
    cout << s << endl;




    return 0;
}

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

using namespace std;
typedef long long ll;

const ll INF = 4e18;
const int MN = 424;
int n;
int a[MN];
ll pf[MN];
ll dp[MN][MN];

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

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

    for (int l = 2; l <= n; l++) {
        for (int i = 1; ; i++) {
            int j = i + l - 1;
            if (j > n) break;
            ll tmp = INF;
            for (int k = i; k <= j - 1; k++) {
                tmp = min(tmp, dp[i][k] + dp[k + 1][j]);
            }
            dp[i][j] = tmp + pf[j] - pf[i - 1];
        }
    }
    cout << dp[1][n] << endl;
    return 0;
}

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

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

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

const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];

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

    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    dp[0] = 0;

    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
string a, b, c;
int main() {
	cin >> a >> b >> c;
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	reverse(c.begin(), c.end());
	int t = 0;
	while(true) {
		if(t == 0) {
			if(!a.size()) {
				cout << 'A' << endl;
				return 0;
			}
			t = a.back() - 97;
			a.pop_back();
		}
		else if(t == 1) {
			if(!b.size()) {
				cout << 'B' << endl;
				return 0;
			}
			t = b.back() - 97;
			b.pop_back();
		}
		else {
			if(!c.size()) {
				cout << 'C' << endl;
				return 0;
			}
			t = c.back() - 97;
			c.pop_back();
		}
	}
	return 0;
}

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

int main() {
    int n;
    std::string s;
    std::cin >> n >> s;

    int ans = 0;

    for (int a = 0; a < 1000; ++a) {
        std::string p = std::to_string(a);
        while (p.length() < 3) p = "0" + p;

        int k = 0;
        for (char c : s) {
            if (c == p[k]) k++;
            if (k == 3) break;
        }

        if (k == 3) ++ans;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
 
int main() {
  vector<int> A(9);
  rep(i, 9) cin >> A.at(i);
  int N; cin >> N;
  vector<int> b(N);
  rep(i,N) {
    int b; cin >> b;
    auto it = find(all(A), b);
    if (it != A.end()) {
      A.at(it-A.begin()) = 0;
    }
  }
  string ans = "No";
  // 横の列のジャッジ
  if (A[0]+A[1]+A[2] == 0) ans = "Yes";
  if (A[3]+A[4]+A[5] == 0) ans = "Yes";
  if (A[6]+A[7]+A[8] == 0) ans = "Yes";
  // 縦の列のジャッジ
  if (A[0]+A[3]+A[6] == 0) ans = "Yes";
  if (A[1]+A[4]+A[7] == 0) ans = "Yes";
  if (A[2]+A[5]+A[8] == 0) ans = "Yes";
  // 斜めのジャッジ
  if (A[2]+A[4]+A[6] == 0) ans = "Yes";
  if (A[0]+A[4]+A[8] == 0) ans = "Yes";

  cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * @jakestrj
 */

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include "bits/stdc++.h"
using namespace std;
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define rep(i, j, k) for(int i=(j);i<(k);++i)
#define repi(i, j, k) for(int i=(j);i<=(k);++i)
#define per(i, j, k) for(int i=(j);i>(k);--i)
#define peri(i, j, k) for(int i=(j);i>=(k);--i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).begin(),(x).end(), greater<int>()
#define mem(a, b) memset(a, (b), sizeof(a))
#define mem2(a, b) memset(a, (b), sizeof(a[0][0])*len(a)*len(a[0]))
#define sz(x) ((int)(x).size())
#define len(x) (int)(sizeof(x)/sizeof(x[0]))
#define endl "\n"
#define INF 1e18
#define EPS 1e-9
#define PI 2*acos(0)
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
typedef tuple<int, int, int> trio;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef map<int,int> mpii;
typedef set<int> si;

int nearestEven(int to){
	return (to % 2 == 0) ? to : (to-1);
}

struct A {
	void solve(std::istream& cin, std::ostream& cout) {
		ll A,B,c, X,Y; cin >> A >> B >> c >> X >> Y;
		bool pref=false; //f=use split cost
		if(2ll*c > A+B) pref=true;
		ll res=INF;
		for(ll i=0; i<=(max(X,Y)); ++i){
			ll buy_a = (X-i > 0) ? (X-i) : 0, buy_b = (Y-i>0 ? (Y-i) : 0);
			res = min(res, (buy_a*A + buy_b*B + (2*c*i)));
		}
		cout << res << endl;
	}
};


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	A solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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


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

	    if(s[2]==s[3] and s[4]==s[5]){
	        cout<<"Yes"<<"\n";
	        return 0;
	    }
	     cout<<"No"<<"\n";
	return 0; 
} 


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define last Last
const int N=1e5+5;
int n,ans,a[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
signed main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n;i++)
	{
		if(a[i]==i)
		{
			ans++;
			swap(a[i],a[i+1]);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <math.h>
using namespace std;



int main(){
  int64_t L,R;

  cin >> L>>R;

  int64_t ans=10000;

  if((R-L)>=2019){
    cout << 0 << endl;
  }
  else{
    for(int64_t i=L;i<=R;i++){
      for(int64_t j=L;j<=R;j++){
        if(i==j){
          continue;
        }
        else{
          ans=min(ans,((i%2019)*(j%2019))%2019);
        }
      }
    }
    cout << ans << endl;
  }

}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 10;
int n, x, y, dist[N], ans[N];
vector<int> gg[N];
bool used[N];
queue<int> q;
int main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin>>n>>x>>y;
	for (int i=1; i<=n-1; i++){
		gg[i].push_back(i+1);
		gg[i+1].push_back(i);
	}
	gg[x].push_back(y);
	gg[y].push_back(x);
	for (int i=1; i<=n; i++){
		for (int j=1; j<=n; j++){
			used[j] = false;
			dist[j] = 0;
		}
		q.push(i);
		used[i] = true;
		dist[i] = 0;
		while (!q.empty()){
			int cur = q.front();
			q.pop();
			for (int j=0; j<gg[cur].size(); j++){
				int child = gg[cur][j];
				if (used[child] == false){
					q.push(child);
					used[child] = true;
					dist[child] = dist[cur] + 1;
				}
			}
		}
		for (int j=1; j<=n; j++){
			ans[dist[j]]++;
		}
	}
	for (int i=1; i<=n-1; i++){
		ans[i] = ans[i] / 2;
		cout<<ans[i]<<'\n';
	}
}

Measured memory_bytes: 384
from sys import exit
s=input()
x,y=map(int,input().split())

def groupby(a):
    a2=[[a[0],1]]
    for i in range(1,len(a)):
        if a2[-1][0]==a[i]:
            a2[-1][1]+=1
        else:
            a2.append([a[i],1])
    return a2

s=groupby(s)
a,b=[],[]
turn=True
#初めまっすぐの場合
if s[0][0]=="F":
    x-=s[0][1]
    s.pop(0)
for i in s:
    if i[0]=="F":
        if turn:
            a.append(-i[1])
        else:
            b.append(-i[1])
    elif i[1]%2==1:
        turn=not turn
a.sort()
b.sort()
for i in a:
    x=abs(x)-abs(i)
if x!=0:
    print("No")
    exit()
for i in b:
    y=abs(y)-abs(i)
if y!=0:
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 3828
using System;


namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());
            int K = 1;
            while(X * K % 360 != 0)
            {
                K++;
            }

            Console.WriteLine(K);
        }
    }
}

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

#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define REPR(i, n) for(ll i = n; i >= 1; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define INF 1e9+123
#define VEC(type,A,N) vector<type> A(N+10)
#define VECi(type,A,N,i) vector<type> A(N+10,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N+10,vector<type>(M+10))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N+10,vector<type>(M+10,i))
#define ALL(v) v.begin()+1, v.end()-9
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
int main(){
    ll N;
    cin>>N;
    switch(N%10){
        case 0:case 1:case 6:case 8:
        cout<<"pon";
        break;
        case 2:case 4:case 5:case 7:case 9:
        cout<<"hon";
        break;
        case 3:
        cout<<"bon";
        break;
    }
    
    
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
	int D; cin >> D; 
	int C[30] = {}; 
	for(int i = 1; i <= 26; i++) cin >> C[i]; 
	int S[370][30] = {}; 
	for(int i = 1; i <= D; i++){
		for(int j = 1; j <= 26; j++){
			cin >> S[i][j]; 
		}
	}
	int ans[370] = {}; 
	int L[30] = {}; 
	for(int i = 1; i < D; i+= 2){
		int E[700] = {}; 
		for(int j = 1; j <= 676; j++){
			int p = (j - 1) % 26 + 1; // i日目
			int q = (j - 1) / 26 + 1; // i+1日目
			int M[30] = {}; 
			for(int k = 1; k <= 26; k++){
				M[k] = L[k]; 
			}
			E[j] += S[i][p] + C[p] * (i - M[p]) * min(365-i, 8); 
			M[p] = i; 
			E[j] += S[i+1][q] + C[q] * (i + 1 - M[q]) * min(365-i, 8);
		}
		int a = 0; int mx = -1145141919; 
		for(int j = 1; j <= 676; j++){
			if(E[j] > mx){
				a = j; mx = E[j]; 
			}
		}
		ans[i] = (a-1) % 26 + 1; ans[i+1] = (a-1) / 26 + 1; 
		L[(a-1) % 26 + 1] = i; L[(a-1) / 26 + 1] = i + 1; 
	}
	for(int i = D; i <= D; i++){
		int E[30] = {}; 
		for(int j = 1; j <= 26; j++){
			E[j] = S[i][j] + C[j] * (i - L[j]); 
		}
		int a = 0; int mx = -1145141919; 
		for(int j = 1; j <= 26; j++){
			if(E[j] > mx){
				a = j; mx = E[j]; 
			}
		}
		ans[i] = a; L[a] = i; 
	}
	for(int i = 1; i <= D; i++) cout << ans[i] << endl; 
}

Measured memory_bytes: 3660
n = int(input())
a = list(map(int, input().split()))
spots = [0] + a + [0]
costs = []

for i in range(1, n + 2):
    costs.append(abs(spots[i] - spots[i - 1]))

total = sum(costs)
for i in range(1, n + 1):
    tmp = total
    tmp -= costs[i - 1]
    tmp -= costs[i]
    tmp += abs(spots[i - 1] - spots[i + 1])
    print(tmp)


Measured memory_bytes: 13920
#include<stdio.h>
int main(){
    char str[21]={0};
    int cou=0;
    scanf("%s",str);
    for(int i=0;str[i]!='\0';i++){
        cou++;
    }
    for(int i=cou-1;i>=0;i--){
        printf("%c",str[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 932
#include<iostream>
#include<cstdio>
#include<cmath>
#define DB double
using namespace std;
int n,L,cnt;
DB ansx,ansy,tmp;
const int N=3005;
const DB PI=acos(-1);
DB t[N];
int main()
{
	cin>>n>>L;
	for(int i=1;i<=n;++i)scanf("%lf",&t[i]);
	for(int i=1;i<=n;++i)
		for(int j=i+1;j<=n;++j)
		{
			cnt=j-i-1;tmp=PI*(t[i]+t[j])/L;
			ansx+=cos(tmp)*(n-2*cnt-2);ansy+=sin(tmp)*(n-2*cnt-2);
		}
	ansx/=(DB)n*(n-1)*(n-2)/6;ansy/=(DB)n*(n-1)*(n-2)/6;
	printf("%0.12f %0.12f",ansx,ansy);
	return 0;
}

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

void dfs(const vector<vector<int>> &G, int v, int p, vector<int> &C){
  for(auto v_ : G[v]){
    if(v_ == p) continue;
    C[v_] = 1 - C[v];
    dfs(G,v_,v,C);
  }
}

int main(){
  int N;
  cin >> N;
  vector<vector<int>> G(N);
  for(int i = 1; i < N; ++i){
    int a, b;
    cin >> a >> b;
    --a,--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> C(N,0);
  dfs(G,0,-1,C);
  int c = 0;
  for(int i = 0; i < N; ++i) c += C[i];
  if(c > N/2){
    for(int i = 0; i < N; ++i) C[i] = 1 - C[i];
    c = N-c;
  }
  vector<int> A(N,-1);
  vector<vector<int>> T(3);
  for(int i = 0; i < N; ++i){
    T[(i+1)%3].push_back(i+1);
  }
  if(c <= T[0].size()){
    for(int i = 0; i < N; ++i){
      if(C[i] == 1) A[i] = T[0].back(), T[0].pop_back();
      else continue;
    }
    for(int i = 0; i < N; ++i){
      if(C[i] == 1) continue;
      for(int j = 2; j >= 0; --j){
        if(T[j].size()){
          A[i] = T[j].back();
          T[j].pop_back();
          break;
        }
      }
    }
  }else{
    for(int i = 0; i < N; ++i){
      if(C[i] != 1) continue;
      if(T[2].size())
        A[i] = T[2].back(), T[2].pop_back();
      else{
        A[i] = T[0].back(), T[0].pop_back();
      }
    }
    for(int i = 0; i < N; ++i){
      if(C[i] == 1) continue;
      for(int j = 0; j < 3; ++j){
        if(T[j].size()){
          A[i] = T[j].back();
          T[j].pop_back();
          break;
        }
      }
    }
  }
  for(int i = 0; i < N; ++i){
    cout << A[i] << (i+1 < N ? " " : "\n");
  }
}


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

int main(){
    long long int n,k;
    cin >> n >> k;
    long long int counter = 0;
    vector<long long int > snakes(n+1,0);
    for(int ii = 0; ii < k ;ii++){
        long long int d;
        cin >> d;
        for(int jj  =0 ; jj < d; jj++){
            long long int temp;
            cin >> temp;
            snakes[temp] = 1;
        }
    }
    for(int jj  =1 ; jj < n+1; jj++){
            if(snakes[jj]==0)
            counter++;
    }
    cout << counter;
}

Measured memory_bytes: 3148
N = int(input())
a = [None]
for _ in range(N):
    a.append(int(input()))

x = 1
count = 0
while True:
    if x == 2:
        print(count)
        break
    if a[x] is None:
        print(-1)
        break
    else:
        count += 1
        temp = a[x]
        a[x] = None
        x = temp


Measured memory_bytes: 7080
N, h = gets.chomp.split.map(&:to_i)
as, bs = [], []
N.times do |i|
    as[i], bs[i] = gets.chomp.split.map(&:to_i)
end

a_max = as.max
bs = bs.sort.reverse

count = 0
while bs.length > 0 && bs[0] > a_max
    h -= bs[0]
    count += 1
    if h <= 0
        print count
        exit
    end
    bs.shift
end

count += (h - 1) / a_max + 1

print count

Measured memory_bytes: 5004
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        
        int[] x = new int[4];
        int[] y = new int[4];
        for (int i = 0; i < 2; i++) {
            x[i] = Integer.parseInt(sc.next());
            y[i] = Integer.parseInt(sc.next());
        }
      
        int dx = x[1] - x[0];
        int dy = y[1] - y[0];
        x[2] = x[1] - dy;
        y[2] = y[1] + dx;
        x[3] = x[2] - dx;
        y[3] = y[2] - dy;

        out.println(x[2] + " " + y[2] + " " + x[3] + " " + y[3]);
        
        out.flush();
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define maxn 10005
#define maxm 10000005
#define Rint register int
#define INF 0x3f3f3f3f
using namespace std;
typedef long long lxl;

template <typename T>
inline void read(T &x)
{
	x=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	x*=f;
}

int prime[maxm],cnt;
bool flag[maxm];

inline void sieve()
{
	for(int i=2;i<maxm;++i)
	{
		if(!flag[i]) prime[++cnt]=i;
		for(int j=1;j<=cnt&&i*prime[j]<maxm;++j)
		{
			flag[i*prime[j]]=true;
			if(!(i%prime[j])) break;
		}
	}
	flag[1]=flag[2]=true;
}

struct edge
{
	int u,v,next;
	edge(int u,int v,int next):u(u),v(v),next(next){}
	edge(){}
}e[maxn<<1];

int head[maxn],k;

inline void add(int u,int v)
{
	e[k]=edge(u,v,head[u]);
	head[u]=k++;
}

int n;
int a[maxn],f[maxm],L[maxn],R[maxn];
int match[maxn];
bool vis[maxn];

inline int findpath(int u)
{
	for(int i=head[u];~i;i=e[i].next)
	{
		int v=e[i].v;
		if(!vis[v])
		{
			vis[v]=true;
			if(!match[v]||findpath(match[v]))
			{
				match[v]=u;
				return true;
			}
		}
	}
	return false;
}

inline int Hungary()
{
	int res=0;
	for(int i=1;i<=L[0];++i)
	{
		memset(vis,0,sizeof(vis));
		res+=findpath(i);
	}
	return res;
}

int main()
{
	sieve();
	read(n);
	int up=0;
	for(int i=1;i<=n;++i)
	{
		read(a[i]);
		++f[a[i]];
		up=max(up,a[i]);
	}
	for(int i=1;i<=up+1;++i)
		if(f[i]!=f[i-1])
		{
			if(i&1) L[++L[0]]=i;
			else R[++R[0]]=i;
		}
	memset(head,-1,sizeof(head));
	for(int i=1;i<=L[0];++i)
		for(int j=1;j<=R[0];++j)
			if(!flag[abs(L[i]-R[j])])
				add(i,j);
	int maxmatch=Hungary();
	int ans=maxmatch;
	ans+=(L[0]-maxmatch)/2*2+(R[0]-maxmatch)/2*2;
	ans+=((L[0]-maxmatch)&1)*3;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 15888
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int[][] a = new int[N][N];
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) a[i][j] = scanner.nextInt();

    long[] dp = new long[1 << N];
    int msb = 0;
    for (int i = 1; i < (1 << N); i++) {
      if (i == 1 << (msb + 1)) msb++;
      dp[i] = dp[i ^ (1 << msb)];

      int k = i;
      int j = 0;
      while (k > 0) {
        if (k % 2 == 1) dp[i] += a[msb][j];
        k >>= 1;
        j++;
      }
    }

    for (int i = 1; i < (1 << N); i++)
      for (int j = i; j > 0; j = (j - 1) & i)
        dp[i] = Math.max(dp[i], dp[j] + dp[i ^ j]);

    System.out.println(dp[(1 << N) - 1]);
  }
}


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

int main(){
  ll n,i,a,b;
  cin >> n >> a >> b;
  vector<ll> x(n);
  for(i=0;i<n;++i){
    cin >> x[i];
  }
  ll hi=0;
  for(i=0;i<n-1;++i){
    if((x[i+1]-x[i])*a<b){
      hi+=(x[i+1]-x[i])*a;
    }else{
      hi+=b;
    }
  }
  cout << hi << endl;
  return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(n%2==1){
    cout<<"No";
    return 0;
  }
  for(int i=0;i<n/2;i++){
    if(s[i]!=s[i+n/2]){
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;
typedef long long ll;
int N, M, a, b, gn;
int p[100001], arr[100001], ngn[100001], chk[100001];
vector<pair<int, int>> group[100001], all;
ll res = 0;

int find(int x) {
	if (p[x] < 0) return x;
	return p[x] = find(p[x]);
}

int merge_(int x, int y) {
	x = find(x), y = find(y);
	if (x == y) return false;
	p[x] = y; return true;
}

int main() {
	cin.tie(NULL); cout.tie(NULL);
	ios::sync_with_stdio(false);
	memset(ngn, -1, sizeof(ngn));
	memset(p, -1, sizeof(p));

	cin >> N >> M;
	for (int i = 0; i < N; ++i) {
		cin >> arr[i];
		all.push_back({ arr[i], i });
	}

	for (int i = 1; i <= M; ++i) {
		cin >> a >> b;
		merge_(a, b);
	}

	for (int i = 0; i < N; ++i) {
		a = find(i);
		if (ngn[a] == -1) ngn[a] = ++gn;
		group[ngn[a]].push_back({ arr[i], i });
	}

	if (gn == 1) {
		cout << 0; return 0;
	}

	for (int i = 1; i <= gn; ++i) {
		sort(group[i].begin(), group[i].end());
		chk[group[i][0].second] = 1;
		res += group[i][0].first;
	}

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

	int cnt = gn - 2;
	for (int i = 0; i < N; ++i) {
		if (cnt == 0) break;
		if (chk[all[i].second]) continue;
		res += all[i].first;
		cnt--;
	}

	if (cnt) {
		cout << "Impossible"; return 0;
	}
	cout << res;

}


Measured memory_bytes: 8052
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[400005],b[400005];
int c[400005],d[400005];
ll m[2][400005];
ll h[2][400005];
ll calc(int aa,int bb){ return c[aa]^d[bb]; }
int main(){
	cin >> n;
	rep(i,n) cin >> c[i];
	rep(i,n) cin >> d[i];
	
	rep(i,n) a[i] = (c[(i+1)%n] ^ c[i]);
	rep(i,n) b[i] = (d[(i+1)%n] ^ d[i]);
	
	rep(i,n) a[n+i] = a[i];
  
	m[0][0] = m[1][0] = 1;
	repn(i,400003){
		m[0][i] = m[0][i-1] * 37LL % mod;
		m[1][i] = m[1][i-1] * 41LL % mod;
	}
	rep(i,2*n){
		h[0][i] = m[0][i] * a[i];
		h[1][i] = m[1][i] * a[i];
		if(i) h[0][i] += h[0][i-1];
		if(i) h[1][i] += h[1][i-1];
		h[0][i] %= mod;
		h[1][i] %= mod;
	}
	ll sum[2] = {};
	rep(i,n) rep(j,2){
		sum[j] = (sum[j] + m[j][i] * b[i]) % mod;
	}
	rep(k,n){
		ll a = h[0][k+n-1]; if(k) a -= h[0][k-1];
		ll b = h[1][k+n-1]; if(k) b -= h[1][k-1];
		a = (a%mod+mod)%mod;
		b = (b%mod+mod)%mod;
		
		ll c = sum[0];
		ll d = sum[1];
		c = (c*m[0][k]%mod+mod)%mod;
		d = (d*m[1][k]%mod+mod)%mod;
		if(a == c && b == d){
			cout << k << " " << calc(k,0) << '\n';
		}
	}
}


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> bad(10, false);
    for (int i = 0; i < k; i++) {
        int x;
        cin >> x;
        bad[x] = true;
    }
    auto ok = [&] (int x) {
        while (x > 0) {
            if (bad[x % 10]) {
                return false;
            }
            x /= 10;
        }
        return true;
    };
    while (true) {
        if (ok(n)) {
            cout << n << '\n';
            break;
        }
        n++;
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

NO = "IMPOSSIBLE"  # type: str

def solve(A: int, B: int):
    if (A + B) % 2 :
        print(NO)
    else:
        print(int((A + B)/2))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
	long long a[10001];
	long long n;
	cin>>n;
	for(long long i=0;i<n;i++){
		cin>>a[i];
	}
	
	long long s=0;
	for(long long i=0;i<n;i++){
		s+=a[i];
	}
	long long  p=10000009;
	for(long long i=0;i<n;i++){
		if(p>a[i])p=a[i];
		
		
		
		}
	long long q=-10000009;
		for(long long i=0;i<n;i++){
		if(q<a[i])q=a[i];
		
		
		
		}
	cout<<p<<" "<<q<<" "<<s<<endl;
	return 0;
}



Measured memory_bytes: 3176
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

// #include <unordered_set>
// #include <unordered_map>

#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

#define pb push_back
#define mp make_pair

int gcd(int a, int b) {
    int c;
    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

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

typedef std::pair<int, int> P;
typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;
const int INF = 1e9;
const ll LINF = INF * 1ll * INF;
const ld DINF = 1e200;
const double EPS = 1e-10;
const double PI = acos(-1.0);


//#define int long long

using namespace std;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {-1, 0, 1, 0};


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

    string keyword = "keyence";

    for (int i = 0; i < 8; i++) {
        if (s.substr(0, i) == keyword.substr(0, i) && (s.substr(s.size() - 7 + i, s.size()) ==
                                                       keyword.substr(keyword.size() - 7 + i, keyword.size()))) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


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


ll gcd ( ll a , ll b)
{
    if( b ==0 )
    {
        return a;
    }
    return gcd( b, a%b);
}
ll cnt( ll a, ll b , ll c)
{
    ll temp1 = a/c;
    ll temp2  = b/c;
    ll ans = temp1 - temp2;
    if( b% c ==0)
        ans++;
    return ans;
}
int main()
{
  ll a , b, c, d;
  cin>>a>>b>>c>>d;
  ll ans = b-a +1;
  ans = ans - cnt(b , a, c);

  ans = ans - cnt( b ,a,d);

  ll temp = (c*d)/gcd( c,d);

  ans += cnt( b,a,temp );

  cout<<ans;

}

Measured memory_bytes: 3568