akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define N               200005
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pq_max          priority_queue<ll>
#define pq_min          priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void fio(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    fio();

    ll n;
    cin>>n;

    ll a[n];
    for(ll x=0;x<n;x++) cin>>a[x];

    ll cSum[n];
    cSum[n-1] = a[n-1];
    for(ll x=n-2;x>=0;x--) cSum[x] = (a[x] + cSum[x+1]) % mod;

    ll res = 0;
    for(ll x=0;x<n-1;x++){
        res = (res + (cSum[x+1] * a[x]) % mod) % mod;
    }

    cout<<res;

    return 0;
}

Measured memory_bytes: 6768
import java.util.Scanner;
class Main{
	static Scanner sc;
	static int i,L,M,N,T,mth;
	
	public static void main(String[]args){
		sc=new Scanner(System.in);
		L=sc.nextInt();
		while(L>0){
			mth=0;
			T=0;M=0;N=0;
			i=1;
			while(i<13){
				M=sc.nextInt();
				N=sc.nextInt();
				T=T+M-N;
				if(T>=L && mth==0){
					mth=i;
				}
				i++;
			}
			if(mth==0){System.out.println("NA");}
			else{System.out.println(mth);}
			L=sc.nextInt();
		}
	}
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int i = 0, j = k;
    bool flag = true;
    while (j <= n-1) {
        if (a[i] >= a[j]) cout << "No" << endl;
        else cout << "Yes" << endl;
        i++;
        j++;
    }
}

Measured memory_bytes: 4040
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
using namespace std;
int main() {
	int r, d, x;
	cin >> r >> d >> x;
	for (int i = 2000; i < 2010; i++) {
		x = x * r - d;
		cout << x << endl;
	}

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=(int)1e9+7;
	static readonly int[][] di=new int[][]{new int[]{-1,0},new int[]{1,0},new int[]{0,-1},new int[]{0,1}};
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		string[] h=new string[s[0]+2];
		var pq=new Pq(100000,true);
		bool[][] b=new bool[s[0]+2][];
		for(int i = 1;i<=s[0];i++) {
			h[i]="#"+sc.S+"#";
			b[i]=new bool[s[1]+2];
			for(int j = 1;j<=s[1];j++) {
				if(h[i][j]=='#'){
					pq.Push(new Mo(0,i,j));
					b[i][j]=true;
				}
			}
		}
		h[0]=new string('#',s[1]+2);
		h[s[0]+1]=new string('#',s[1]+2);
		b[0]=new bool[s[1]+2];
		b[s[0]+1]=new bool[s[1]+2];
		int ans=0;
		while(pq.cnt>0){
			Mo q=pq.Top;
			pq.Pop();
			//if(b[q.d0][q.d1]){continue;}
			//b[q.d0][q.d1]=true;
			ans=q.n;
			for(int i = 0;i<4;i++) {
				if(h[q.d0+di[i][0]][q.d1+di[i][1]]=='.'&&!b[q.d0+di[i][0]][q.d1+di[i][1]]){
					pq.Push(new Mo(q.n+1,q.d0+di[i][0],q.d1+di[i][1]));
					b[q.d0+di[i][0]][q.d1+di[i][1]]=true;
				}
			}
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Mo{
	public int n;
	public int d0,d1;
	public Mo(int n,int d0,int d1){this.n=n;this.d0=d0;this.d1=d1;}
	public int CompareTo(object obj){
		Mo mymo=(Mo)obj;
		if(mymo.n>n){return -1;}
		else if(mymo.n<n){return 1;}
		else{return 0;}
	}
}
public class Pq{
	private Mo[] he;
	public int cnt=0,max=0;
	private Func<Mo,Mo,int> compare;
	public Pq(int max,bool mm){
		this.max=max;
		he=new Mo[max];
		if(mm){compare=Ao;}
		else{compare=Do;}
	}
	public void Push(Mo x){
		if(cnt==max){Extend();}
		int j=cnt;
		while(j!=0&&compare(x,he[(j-1)/2])>0){he[j]=he[(j-1)/2];j=(j-1)/2;}
		he[j]=x;
		cnt++;
	}
	public void Pop(){
		cnt--;
		Mo r=he[cnt];
		int j=0;
		while(true){
			if(j*2+1<cnt){
				if(compare(he[j*2+1],he[j*2+2])>0){j=j*2+1;}
				else{j=j*2+2;}
			}
			else if(j*2<cnt){j=j*2+1;}
			else{break;}
			if(compare(he[j],r)<=0){j=(j-1)/2;break;}
			he[(j-1)/2]=he[j];
		}
		he[j]=r;
	}
	private int Ao(Mo x,Mo y){return y.CompareTo(x);}
	private int Do(Mo x,Mo y){return x.CompareTo(y);}
	public Mo Top{get{return he[0];}}
	private void Extend(){
		Mo[] nhe=new Mo[max<<1];
		Array.Copy(he,nhe,max);
		he=nhe;
		max<<=1;
	}
}
class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
}

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

int main() {
  int N , L , R ;
  cin >> N;
  int U = 0 ;
  for (int i = 0; i < N; i++){
   cin  >> L >> R ;
   U += R - L + 1;
  }
  cout << U << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <tuple>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>

int main(){
  int N,M,R;
  std::cin >> N >> M >> R;

  int R_arr[8] = {};
  std::vector<std::tuple<int,int>> t_arr[201];
  for(int i = 0; i < R; i++) std::cin >> R_arr[i];
  for(int i = 0; i < M; i++){
    int a,b,c;
    std::cin >> a >> b >> c;
    t_arr[a].push_back(std::make_tuple(b,c));
    t_arr[b].push_back(std::make_tuple(a,c));
  }

  int rr_arr[8][8] = {};
  for(int ri = 0; ri < R; ri++){
    int r = R_arr[ri];
    std::vector<int> node_l(N+1, -1);
    std::priority_queue<std::tuple<int, int>> pq;
    pq.push(std::make_tuple(0,r));
    while(pq.size() > 0){
      int node, length;
      std::tie(length, node) = pq.top();
      pq.pop();
      if(node_l[node] != -1) continue;
      node_l[node] = -length;
      for(auto&& it: t_arr[node]){
        int neigh, nlength;
        std::tie(neigh, nlength) = it;
        pq.push(std::make_tuple(length-nlength, neigh));
      }
    }
    for(int i = 0; i < R; i++){
      rr_arr[ri][i] = node_l[R_arr[i]];
    }
  }

  int length_min = std::numeric_limits<int>::max();
  std::vector<int> r_p(R);
  for(int i = 0; i < R; i++) r_p[i] = i;
  do{
    int length = 0;
    for(int ri = 0; ri < R-1; ri++){
      length += rr_arr[r_p[ri]][r_p[ri+1]];
    }
    length_min = std::min(length_min, length);
  }while(std::next_permutation(r_p.begin(), r_p.end()));

  std::cout << length_min;

  return 0;
}



Measured memory_bytes: 1568
#include <bits/stdc++.h>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
 
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;
 
int d[1010][1010];

int main() {
    int h,w,ch,cw,dh,dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    char s[h][w];
    rep(i,h) rep(j,w) cin >> s[i][j];
 
    rep(i,h+10) rep(j,w+10) d[i][j] = INF; d[ch][cw] = 0;
    queue<P> que; que.push(P(cw,ch));
    while(que.size()){
        P p = que.front(); que.pop();
        queue<P> que2; que2.push(p); 
        vector<P> v; v.push_back(p);
        while(que2.size()){
            P p2 = que2.front(); que2.pop();
            for(int my = -1; my <= 1; my++){
                for(int mx = -1; mx <= 1; mx++){
                    if(abs(mx)+abs(my) != 1) continue;
                    int nx = p2.first+mx,ny = p2.second+my;
                    if(nx < 1 || w < nx || ny < 1 || h < ny) continue;
                    if(s[ny-1][nx-1] == '#') continue;
                    if(d[ny][nx] > d[p2.second][p2.first]){
                        que2.push(P(nx,ny));
                        v.push_back(P(nx,ny));
                        d[ny][nx] = d[p2.second][p2.first];
                    }
                }
            }
        }
        for(auto x : v){
            for(int my = -2; my <= 2; my++){
                for(int mx = -2; mx <= 2; mx++){
                    if(mx == 0 && my == 0) continue;
                    int nx = x.first+mx,ny = x.second+my;
                    if(nx < 1 || w < nx || ny < 1 || h < ny) continue;
                    if(s[ny-1][nx-1] == '#') continue;
                    if(d[ny][nx] > d[x.second][x.first]+1){
                        que.push(P(nx,ny));
                        d[ny][nx] = d[x.second][x.first]+1;
                    }
                }
            }
        }
    }
    cout << (d[dh][dw]!=INF?d[dh][dw]:-1) << endl;
 
	return 0;
}

Measured memory_bytes: 8568
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

scr = sum(B)
for i in range(1,N):
    if A[i] == A[i-1] + 1:
        scr += C[A[i]-2]

print(scr)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define re register
#define rep(i,a,b) for(re int i=a,i##end=b; i<=i##end; i++)
#define drep(i,a,b) for(re int i=a,i##end=b; i>=i##end; i--)
#define repp(i,a,b) for(re int i=a,i##end=b; i<i##end; i++)
#define drepp(i,a,b) for(re int i=a,i##end=b; i>i##end; i--)
#define Erep(i,x) for(int i=head[x]; ~i; i=Edge[i].nxt)
#define ms(x,a) memset(x,a,sizeof x)
#define se second
#define fi first
#define lowbit(x) (x&-x)
#define debug(x) cerr<<#x<<" = "<<x<<endl
#define coint const int
typedef long long ll;
using namespace std;
template<class T>inline T rd(){
	static char ch;static bool neg;static T x;
	for(neg=0,ch=0; ch>'9'||ch<'0'; neg|=(ch=='-'),ch=getchar());
	for(x=0; ch<='9'&&ch>='0'; x=(x<<1)+(x<<3)+(ch-'0'),ch=getchar());
	return neg?-x:x;
}
template<class T>inline T Max(const T &x, const T &y){
	return x>y?x:y;
}
template<class T>inline T Min(const T &x, const T &y){
	return x<y?x:y;
}
coint N=1000+5;
int A[N][N];
int cnt[N],dis[N];
int n;
struct node{
	int x,dis;
};
queue<int>Q;
int main(){
	n=rd<int>();
	rep(i,1,n) repp(j,1,n) A[i][j]=rd<int>();
	rep(i,1,n) cnt[i]=1;
	int tot=n*(n-1)/2,ans=0;
	rep(i,1,n) cnt[i]=dis[i]=1;
	rep(i,1,n){
		Q.push(i);
	}
	while(!Q.empty()){
		int now=Q.front(); Q.pop();
		int res=A[now][cnt[now]];
		if(A[res][cnt[res]]==now)
			Q.push(res), Q.push(now), dis[now]=dis[res]=Max(dis[now],dis[res]), ans=Max(ans,dis[res]), dis[res]++, dis[now]++, cnt[res]++, cnt[now]++, tot--;
	}
	if(tot) ans=-1;
	printf("%d\n",ans);
	return 0;
}



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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    REP(i, n){
        if(int(to_string(i+1).length()) % 2 == 1) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3708
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)




template<class T>
class SegTree {
	int n;
	vector<T>data;
	T def;
	function<T(T, T)>operation;
	function<T(T, T)>update;

	T _query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return def;
		if (a <= l && r <= b)return data[k];
		else {
			T c1 = _query(a,b,2*k+1,l,(l+r)/2);
			T c2 = _query(a,b,2*k+2,(l+r)/2,r);
			return operation(c1, c2);
		}
	}

public:
	SegTree(size_t _n, T _def, function<T(T, T)>_operation,
		function<T(T, T)>_update) 
		:def(_def), operation(_operation), update(_update) {
		n = 1;
		while (n < _n) {
			n *= 2;
		}
		data = vector<T>(2 * n - 1, def);
	}

	void change(int i,T x){
		i += n - 1;
		data[i] = update(data[i],x);
		while (i > 0) {
			i = (i - 1) / 2;
			data[i] = operation(data[2*i+1],data[2*i+2]);
		}
	}

	//[a,b)
	T query(int a, int b) {
		return _query(a, b, 0, 0, n);
	}

	T operator[](int i) {
		return data[i + n - 1];
	}
};


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

	int n, q;
	cin >> n >> q;
	SegTree<ll>st(n, (1LL << 31) - 1,
		[](ll a, ll b) {return min(a, b); },
		[](ll a, ll b) { return b; });

	for (int i = 0; i < q; i++) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0)st.change(x,y);
		else puts(st.query(x,y+1));
	}

	return 0;
}



Measured memory_bytes: 4960
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define SENTINEL INT_MAX
using namespace std;

long long counter = 0;
template <typename Iter>
void merge(Iter leftBegin, Iter leftEnd, Iter rightBegin, Iter rightEnd,
           Iter target) {
  while (leftBegin != leftEnd && rightBegin != rightEnd) {
    if (*leftBegin <= *rightBegin) {
      *target++ = *leftBegin++;
    } else {
      *target++ = *rightBegin++;
      counter+= leftEnd - leftBegin;
    }
  }
  while (leftBegin != leftEnd) {
    *target++ = *leftBegin++;
  }
  while (rightBegin != rightEnd) {
    *target++ = *rightBegin++;
  }
}

template <typename Iter> void merge_sort(Iter begin, Iter end) {
  auto dest = end - begin;
  if (dest < 2) {
    return;
  }
  auto middle = begin + dest / 2;
  vector<typename iterator_traits<Iter>::value_type> left(begin, middle);
  vector<typename iterator_traits<Iter>::value_type> right(middle, end);
  merge_sort(left.begin(), left.end());
  merge_sort(right.begin(), right.end());
  merge(left.begin(), left.end(), right.begin(), right.end(), begin);
}

int main() {
  int n;
  cin >> n;
  vector<int> S;
  int temp;
  rep(_, n) {
    cin >> temp;
    S.push_back(temp);
  }
  merge_sort(S.begin(), S.end());
  cout << counter << endl;
}



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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10e9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;

             
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;  

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif
  
  ll n; cin >> n;
  --n;
  ll m; cin >> m;
  ll x = ((((n + 1) / 2) & 1) ^ ((n & 1) ? 0 : n));
  ll y = ((((m + 1) / 2) & 1) ^ ((m & 1) ? 0 : m));
  cout << (x ^ y) << endl;
            
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define inf 1000000007;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, m;

signed main() {
	cin >> n >> m;
	for (int i = m / n; i >= 1; i--) {
		if (m%i == 0) { cout << i << endl; return 0; }
	}
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    int n,m;
    cin >> n >> m;
    int mx = pow(10,n)+0.1;
    vector<int> s(m);
    vector<char> c(m);
    rep(i,m){
        int st; char ct;
        cin >> st >> ct;
        s[i] = st-1;
        c[i] = ct;
    }
    rep(i,mx){
        string now = to_string(i);
        if(now.size()!=n) continue;
        bool ok = true;
        rep(j,m){
            if(now[s[j]]!=c[j]){
                ok=false;
                break;
            }
        }
        if(ok){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    k=I()
    s=S()
    if len(s)<=k:
        print(s)
    else:
        print(s[:k]+'...')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    string s;
    cin >> s;
    rep(i, s.size()){
        if (i%2 == 0) {
            cout << s[i];
        }
    }
    cout << endl;
    return 0;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) const { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) const { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) const { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const char* sep = " ", const char* term = "\n") const {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    bool ok = N >= 30;
    cout << (ok ? "Yes\n" : "No\n");
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main(void){
    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c); /*入力部分*/
    
    if(a+b>=c){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
import math
N = int(input())
days = []
temp = [list(map(int, input().split(" "))) for _ in range(N)]
days.extend(temp)


dp = [[-1 for _ in range(3)] for _ in range(N + 1) ]


dp[1] = days[0]

for d in range(1,N ):
    for a in range(3): #d+1日目にする活動
        cands = []
        for i in range(3):
            if i != a:
                cands.append(dp[d][i])

        dp[d+1][a] = max(cands) + days[d][a]

print(max(dp[-1]))

Measured memory_bytes: 48132
S = input()
T = input()

min = len(T)

for index in range( len(S)-len(T)+1 ):
  temp = 0
  for index2 in range(len(T)):
    if T[index2] != S[index+index2]:
      temp += 1
  if temp < min:
    min = temp

print(min)

Measured memory_bytes: 8940
#include<bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll arra[n+5];
    ll ans=0;
    for(int i=0;i<n;i++) {
        cin>>arra[i];
    }
    ll sum=0;
    for(int i=n-1;i>=0;i--) {
        ans+=(sum*arra[i]);
        sum+=arra[i];
    ans%=MOD;
    sum%=MOD;


    }
    cout<<ans<<endl;

}


Measured memory_bytes: 5180
#include<bits/stdc++.h>
//#include <iostream>
//#include <iomanip>
//#include <vector>
//#include <cmath>
//#include <algorithm>
using namespace std;


#define F first
#define PB push_back
#define MP make_pair

typedef unsigned long long ll;

ll p = pow(10, 9) + 7;




int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long x, k;
    cin >> x >> k;
    bool done = false;

    while(!done)
    {
        if(x > k)
        {
            x = x % k;
        }else
        {
            if(abs(k - x) < x)
            {
                x = k - x;
            }
            done  = true;
        }
    }
    cout << x << endl;


}


Measured memory_bytes: 256
from sys import stdin
data = stdin.readlines()

N = int(data[0])
l = [0, 0]
i = 1
while i <= N:
    l.append(int(data[i].split()[0]))
    l.append(int(data[i].split()[1])+int(data[i].split()[2]))
    i += 1

def check(x):
    diffrent_time = l[2*x] - l[2*x-2]
    diffrent_place = abs(l[2*x+1] - l[2*x-1])
    return diffrent_time % 2 == diffrent_place % 2 and diffrent_time >= diffrent_place

count = 0
i = 1
while i <= N:
    if check(i) == False:
        count = 1
    i += 1
if count == 0:
    print("Yes")
elif count == 1:
    print("No")

Measured memory_bytes: 23940
import sys
input=sys.stdin.readline
def unite(x,y):
	rx=root(x);ry=root(y)
	if rank[rx]>rank[ry]:
		parent[ry]=rx
		size[rx]+=size[ry]
	else:
		parent[rx]=ry
		size[ry]+=size[rx]
		if rank[rx]==rank[ry]:
			rank[ry]+=1
def root(x):
	if x!=parent[x]:
		return root(parent[x])
	return x
def same(x,y):
	return root(x)==root(y)
n,m=map(int,input().split())
parent=list(range(n))
rank=[0]*n
size=[1]*n
for i in range(m):
	a,b=map(int,input().split())
	if same(a-1,b-1)==False:
		unite(a-1,b-1)

print(max(size))

Measured memory_bytes: 87324
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    vector<int> A(5);
    for (int i=0; i < 5; i++){
        cin >> A.at(i);
        if (A[i] == 0){
            cout << i+1 << endl;
            break;
        }
    }
    
}


Measured memory_bytes: 3576
def f(k):
    if k==1:return d
    if k==0:return 0
    if k in m:return m[k]
    s=min(k*d,f(k//2)+a+k%2*d,f((k+1)//2)+a+-k%2*d,f(k//3)+b+k%3*d,f((k+2)//3)+b+-k%3*d,f(k//5)+c+k%5*d,f((k+4)//5)+c+-k%5*d)
    m[k]=s
    return s
for _ in range(int(input())):
    m={}
    n,a,b,c,d=map(int,input().split())
    print(f(n))

Measured memory_bytes: 10936
A, B, C, D = map(int,(input().split()))
from decimal import Decimal as d
import fractions
cd = C * D / d(fractions.gcd(C, D))

# B-A+1 - (B//C - A//C) - (B//D - A//D) + (B//cd - A//cd)

if (A % C == 0 and A % D != 0) or (A % C != 0 and A % D == 0):
    print(B-A+1 - (B//C - A//C + 1) - (B//D - A//D) + (B//cd - A//cd))
elif A % cd == 0:
    print(B-A+1 - (B//C - A//C + 1) - (B//D - A//D + 1) + (B//cd - A//cd + 1))
else:
    print(B-A+1 - (B//C - A//C) - (B//D - A//D) + (B//cd - A//cd))


Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int total=0;

    for(int i=1;i<=n;i++){
            int y=i;
            int sum=0;
           // while(y>0){
             //   sum=sum+(y%10);
          //      int y=y/10;
        //    }//
            for(int j=0;j<5;j++){
            if(y<=0){
                break;
            }
            int m=y%10;
                sum=sum+m;
                y=y/10;

            }





            if((sum>=a)&&(sum<=b)){
                  
                total=total+i;

            }

    }
    cout<<total<<endl;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main(void){
   int n,d;
   scanf("%d %d",&n,&d);
   int a;
   a=2*d+1;
   if(n%a==0){
     printf("%d",n/a);
   }else{
     printf("%d",n/a +1);
   }
   return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A[NMAX],B[NMAX],C[NMAX],D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = {};

void solve(){
  // main algorithm
  for (int i = 0; i < N; ++i)
  {
    ll b = B[i];
    ll smallA = lower_bound(A, A + N, b) - begin(A);
    ll bigC = N - (upper_bound(C, C + N, b) - begin(C));
    ans += (smallA) * (bigC);
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N;
  for (int i = 0; i < N; ++i)
  {
    scanf("%lld", &A[i]);
  }
  sort(A, A + N);
  for (int i = 0; i < N; ++i)
  {
    scanf("%lld", &B[i]);
  }
  sort(B, B + N);
  for (int i = 0; i < N; ++i)
  {
    scanf("%lld", &C[i]);
  }
  sort(C, C + N);
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 2688
#include<stdio.h>

int main(){

int N,ans=0;
scanf("%d",&N);

int A[N];
for (int i = 1; i <= N; i++)
{
  scanf("%d",&A[i]);
}

for (int i = 1; i <= N; i++){
  if (i%2!=0)
  {
    if(A[i]%2!=0) ans++;
  }
}

printf("%d",ans);

return 0;

}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {


	int n;
	string ans="No";

	cin>>n;

	for(int i=0; i<25; ++i){
		for(int j=0; j<15; ++j){
			if(4*i+7*j==n){
				ans="Yes";
			}
		}
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
import sys 
from decimal import Decimal
readline = sys.stdin.buffer.readline
N,K = map(int, readline().split())
l = [2**i for i in range(18)]
ans = 0
for i in range(1,N+1):
  for j in l:
    if i*j < K:
      continue
    ans += 1/j
    break
print(ans/N)
      


Measured memory_bytes: 5076
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  double t, a;
  double h[1005];
  int mini = 0;

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

  for(int i = 1;i < n;i++){
    if(fabs(a - (t - h[mini] * 0.006)) > fabs(a - (t - h[i] * 0.006))){
      mini = i;
    }
  }

  cout << mini + 1 << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
using namespace std;
typedef long long ll;
int INF=1<<29;

int main(){
	ll n,sei=0,hu=0,zero=0;
	cin>>n;
	vector<ll> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]>0) sei++;
		else if(a[i]<0) hu++;
		else zero++;
		a[i]=abs(a[i]);
	}
	sort(a.begin(),a.end());
	ll sum=accumulate(a.begin(),a.end(),0LL);
	if(hu%2==0 || (hu+zero)%2==0) cout<<sum<<endl;
	else if(hu%2==1) cout<<sum-2*a[0]<<endl;
	return 0;
}



Measured memory_bytes: 1024
N = int(input())
a = list(map(int, input().split()))
cnt = 0
cnt2 = 0
cnt3 = 0
for i in a:
    if i % 2 != 0:
        cnt3 += 1
    elif i % 4 == 0:
        cnt += 1
    else:
        cnt2 += 1

if cnt2 == 0:
    if cnt3 <= cnt + 1:
        print('Yes')
    else:
        print('No')
else:
    if cnt3 <= cnt:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 15148
while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break
      
    for h in range(H):
        for w in range(W):
            if h == 0 or h == H-1 or w == 0 or w == W - 1:
                print('#', end='')
            else:
                print('.', end='')
        print()
      
    print()

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

int main(){
    int n; cin>>n;
    int a, b;
    vector<pair<int, int>> vec(n);
    vector<int> num(n);
    for(int i=0;i<n;i++){
        cin>>a>>b;
        vec[i] = {a, b};
        num[i] = i+1;
        //cout<<num[i];
    }
    long double sum=0;
    double count=0;
    do{
        for(int i=0;i<n-1;i++){
            int x1 = vec[num[i]-1].first; int y1 = vec[num[i]-1].second;
            int x2 = vec[num[i+1]-1].first; int y2 = vec[num[i+1]-1].second;
            sum+=sqrt(( (x1-x2)*(x1-x2) ) + ( (y1-y2)*(y1-y2) ));
        }//cout<<"test\n";
        count++;
    }while(next_permutation(num.begin(),num.end()));
    cout.precision(10);
    cout<<sum/count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

map<PII, bool> seen;
void dfs(set<PII> &p, PII &pq, PII xy){
    seen[xy] = true;

    for(PII n: {make_pair(xy.first+pq.first, xy.second+pq.second), make_pair(xy.first-pq.first, xy.second-pq.second)})
        if (!seen[n] && p.count(n))
            dfs(p, pq, n);
}

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

int N; cin >> N;
VI x(N), y(N); 
set<PII> p;
rep(i, 0, N) {
    cin >> x[i] >> y[i];
    p.insert(make_pair(x[i], y[i]));
}

if (N == 1){
    cout << "1\n";
    return 0;
}

int mini = INF;
rep(i, 0, N)
    rep(j, i+1, N){
        int cnt = 0;
        PII pq = make_pair(x[i] - x[j], y[i] - y[j]);
        seen.clear();
        for(PII xy: p)
            if (!seen[xy]){
                dfs(p, pq, xy);
                ++cnt;
            }
        mini = min(mini, cnt);
    }

cout << mini << "\n";
}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define forn(i, a, n) for(ll i = a; i < n; i++)

#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<iomanip>
#include<cassert>
#include<stack>
#include<deque>
#include<list>
#include<sstream>
#include<unordered_map>
#include<time.h>
#include<functional>
#pragma comment(linker, "/STACK:8809999999")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef pair<ld, ld> pld;
typedef pair<ll, pll> pllp;
typedef pair<pll, ll> ppll;
typedef pair<pll, pll> ppp;
typedef vector<vector<vector<ll>>> vvv;
const ll mod = 1e9 + 7;
const ll atcmod = 998244353;
const ld eps = 1e-9;
const ll settled = 400007;


int main()
{
	ios_base::sync_with_stdio(false); cout.tie(NULL);
#ifndef overlord
	/*freopen("capitals.in", "r", stdin);
	freopen("capitals.out", "w", stdout);*/
#else
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n, k;
	cin >> n >> k;
	cout << (n - k + 1);
	return 0;
}

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

using namespace std;

void reverse(string &s) {
	for (int i = 0, j = s.length() - 1; i < j; i++, j--)
		swap(s[i], s[j]);
}

int main() {
	string s; cin >> s;
	int q; cin >> q;
	int k = 0;
	string cc1, cc2;
	while (q--) {
		int t; cin >> t;
		if (t == 1) {
			k++;
		} else {
			int f; string c; cin >> f >> c;
			if (k % 2)
				f = 3 - f;
			if (f == 1)
				cc1.append(c);
			else
				cc2.append(c);
		}
	}
	if (k % 2) {
		reverse(s);
		cc1.swap(cc2);
	}
	reverse(cc1);
	cout << cc1 << s << cc2 << '\n';
	return 0;
}


Measured memory_bytes: 1088
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int a,b,c;
cin >> a >> b  >> c;
if(a+c==b*2) {
  cout << "YES" << endl;
} else {
  cout << "NO" << endl;
}
return 0;
}


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

using namespace std;

int n;
char s[500010];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	if(s[1]=='0'||s[n]=='1')
	{
		puts("-1");
		return 0;
	}
	for(int i=2;i<=n-1;i++)
		if(s[i]!=s[n-i])
		{
			puts("-1");
			return 0;
		}
	int tmp=2,pr=1;
	while(tmp<=n)
	{
		int st=tmp; 
		printf("%d %d\n",pr,st);
		while(s[tmp]=='0') tmp++;
		for(int j=st+1;j<=min(n,tmp);j++)
			printf("%d %d\n",st,j);
		tmp++; pr=st;
	}
	return 0;	
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>

using namespace std;

const int NMAX = 100000 + 5;
typedef long long int lint;

int N, M;
vector <int> graph[NMAX];

bool vis[NMAX];
bool color[NMAX];

bool odd;
void dfs(int node) {
    vis[node] = true;
    for (auto it: graph[node])
        if (!vis[it]) {
            color[it] = color[node] ^ 1;
            dfs(it);
        }
        else if (color[it] != (color[node] ^ 1))
            odd = true;
}

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

    cin >> N >> M;
    for (int i = 1; i <= M; ++ i) {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int iz = 0, c[2] = {0};
    for (int i = 1; i <= N; ++ i)
        if (graph[i].empty())
            ++ iz;
        else if (!vis[i]) {
            odd = false;
            dfs(i);
            ++ c[odd];
        }

    lint ans = 2LL * c[0] * c[1] + 1LL * c[1] * c[1] + 2LL * c[0] * c[0];
    for (int i = 1; i <= iz; ++ i)
        ans += 2 * (N --) - 1;
    cout << ans << '\n';
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    vector<int> S, T;
    int n, q;
    cin >> n;
    S.resize(n);
    rep(i, n) { cin >> S[i]; }
    cin >> q;
    T.resize(q);
    rep(i, q) { cin >> T[i]; }
    int cnt = 0;
    for (auto t : T) {
        bool hasKey = false;
        for (auto s : S) {
            if (s == t) {
                hasKey = true;
            }
        }
        if (hasKey) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3244
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(A: int, B: int):
    print(max([A*B, A-B, A+B]))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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: 5600
let is_mod_3 n =
  (n mod 3) = 0

let rec is_include_3 n =
  if n = 0 then false
  else if (n mod 10) = 3 then true
  else is_include_3 (n / 10)

let () =
  let lim = read_int () in
  let rec loop i cont =
    if i > lim then cont []
    else if is_mod_3 i || is_include_3 i then loop (i+1) (fun x -> cont (i::x))
    else loop (i+1) cont in
  let l = loop 3 (fun x -> x) in
  List.iter (fun n -> print_string (Printf.sprintf " %d" n)) l;
  print_newline ()

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int n;
    cin>>n;
    Vi a(n);
    map<int,int> mp;
    REP(i,0,n){
        cin>>a[i];
        mp[a[i]]=mp[a[i]-1]+1;
    }
    int ans=0;
    for(auto x : mp){
        if(x.second>ans) ans=x.second;
    }
    cout<<n-ans<<endl;
    return 0;
}


Measured memory_bytes: 14336
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp std::make_pair
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int N;
int main(){
  cin>>N;
  int n=1;
  while((n+1)*n/2<N) n++;
  int dis=(n+1)*n/2-N;
  rep1(i,n){
    if(i!=dis) prin(i);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) cout << "Left" << endl;
  if (a + b == c + d) cout << "Balanced" << endl;
  if (a + b < c + d) cout << "Right" << endl;
  return 0;
}

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

using namespace std;

const int MOD = 1e9 + 7;

int main() {
   ios_base::sync_with_stdio(false);
   int N, K;
   cin >> N >> K;
   vector<int> dp(N + 1);
   dp[N] = 1;
   for (int i = 0; i < K; ++i) {
      vector<int> ndp(N + 1);
      int suff = 0;
      for (int j = N - 1; j >= 0; --j) {
         suff += dp[j + 1];
         if (suff >= MOD) suff -= MOD;
         ndp[j] += suff;
         if (ndp[j] >= MOD) ndp[j] -= MOD;
         if (j < N - i && j) {
            ndp[j] += dp[j];
            if (ndp[j] >= MOD) ndp[j] -= MOD;
         }
      }
      dp = move(ndp);
   }
   int ans = dp[0];
   for (int i = K + 1; i <= N - 1; ++i) {
      ans += ans;
      if (ans >= MOD) ans -= MOD;
   }
   cout << ans << "\n";
   return 0;
}


Measured memory_bytes: 256
# i が与えられたとき a1~aiまでの和を計算する( O(log n) )
def bitsum(bit,i):
    s = 0
    while i > 0:
        s += bit[i]
        i -= i&(-i)
    return s
    
# i と x が与えられたとき ai += x とする ( O(log n) )
def bitadd(bit,i,x):
    while i <= N:
        bit[i] += x
        i += i&(-i)
    return bit
import sys
import math
input = sys.stdin.readline
N,M,Q = [int(x) for x in input().split()]
qinfo = []
for i in range(M+Q):
  if i<M:
    L,R = [int(x) for x in input().split()]
    qinfo.append([L,R,-1])
  if i>=M:
    L,R = [int(x) for x in input().split()]
    qinfo.append([L,R,i-M])
qinfo = sorted(qinfo,key=lambda x : x[1])
#print(qinfo)
n_ = int(math.log2(N)) + 1
bit = [0] * (2**n_)
bit.insert(0,0)
ans = [0]*(Q+1)
for i in range(M+Q):
  if qinfo[i][2]==-1:
    bit = bitadd(bit,qinfo[i][0],1)
  else:
    ans[qinfo[i][2]]=bitsum(bit,qinfo[i][1])-bitsum(bit,qinfo[i][0]-1)
for i in range(Q):
  print(ans[i])

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

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

    ll ans = 0; // A = N-1 のとき, 下限
    // A - B = C の値で全探索
    // C < A, A + C <= N-1 より, C <= N/2 - 1
    ll dp[N-1]; // DP[j]はCをj回やってからAでゴール
    for (int i = 1; i <= N/2 -1; ++i) {
        // ll dp[(N-1)/i]; // DP[j]はCをj回やってからAでゴール
        dp[0] = 0;
        for (int j = 1; j < (N-1)/i; ++j) {
            if((N-1-i*j == i*j) || (N-1-i*j == i*(j-1))) break;
            dp[j] = dp[j-1] + s[N-1-i*j] + s[i*j];
            ans = max(ans, dp[j]);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <utility>
#include <stdint.h>
#include <set>

using namespace std;

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

  set<int> X;
  
  for (int k=0; k<K; ++k) {
    int D;
    cin >> D;
    for (int d=0; d<D; ++d) {
      int a;
      cin >> a;
      X.emplace(a);
    }
  }

  cout << N-X.size() << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void) {
	int ABC[3];
	int i;
	int go = 0, siti = 0;
	if (scanf("%d%d%d", &ABC[0], &ABC[1], &ABC[2]) != 3) return 1;
	for (i = 0; i < 3; i++) {
		if (ABC[i] == 5) go++;
		if (ABC[i] == 7) siti++;
	}
	puts(go == 2 && siti == 1 ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 128
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PI acos(-1)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int compare_base(const void *b, const void *f) {
  return (*(int *)b - *(int *)f);
}

int main(void) {
  /* 標準入力フラグ */
  int   scan;

  /* 数入力 */
  ll    answer;
  ll    n;
  ll    k; 
  ll    *p;
  answer = 0;
  scan = scanf("%lld", &n);
  scan = scanf("%lld", &k);
  p = (ll *)malloc(sizeof(ll) * n);

  for (ll i = 0; i < n; i++) {
    scan = scanf("%lld", &p[i]);
  }
 
  /* プログラムを書く */
  qsort(p, n, sizeof(ll), compare_base);

  for (ll t = 0; t < k; t++) {
    answer += p[t];
  }

  /* 数回答 */
  printf("%lld", answer);

  return (0);
}



Measured memory_bytes: 1748