akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define forn for(int i=1;i<=n;i++)
#define form for(int j=0;j<m;j++)
#define pb push_back
#define mp make_pair
#define sc second
#define f first
#define kek cout<<"\n"
#define all(v)        ((v).begin()), ((v).end())
#define pob pop_back()
const ll MOD=1e9+7;
const ll INF=1e8;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
      
      string s;
      cin>>s;
      int n=s.size();
      forn cout<<'x';
      
      
      
      
      
      
      return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
if len(s) < len(t):
  print("LESS")
elif len(s) > len(t):
  print("GREATER")
else:
  for i in range(len(s)):
    if int(s[i]) < int(t[i]):
      print("LESS")
      break
    elif int(s[i]) > int(t[i]):
      print("GREATER")
      break
  else:
    print("EQUAL")

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

#define o cout<<"Hello did you expect this?"<<endl;
#define ll long long
#define pb push_back
#define mp make_pair//with Z
#define F first
#define S second

using namespace std;

const int N = 6e6 + 100;
const int mod = 1e9 + 7;

void hey () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int a[100][100];
int c[100];int pref[100];
int main () {
	hey();
	int n, m, x;
	cin >> n >> m >> x;
	for (int i = 1; i <= n; i++) {
		cin >> c[i];
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
		}
	}
	int ans = 1e9;
	for (int i = 0; i < (1 << n); i++) {
		int kol = 0;
		memset(pref, 0, sizeof pref);
		for (int k = 1; k <= n; k++) {
			if ((1 << (k - 1)) & i) {
				kol += c[k];
				for (int j = 1; j <= m; j++) {
					pref[j] += a[k][j];
				}
			}
		}
		bool bruh = 0;
		for (int j = 1; j <= m; j++)
		{
			if (pref[j] < x)
			{
				bruh = 1;
			}
		}
		if (!bruh)
		{
			ans = min(ans, kol);
		}
	}
	cout << (ans == 1e9 ? -1 : ans);
}



Measured memory_bytes: 3664
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		BufferedReader br=  new BufferedReader(new InputStreamReader(System.in));
		
		String[] in = br.readLine().split(" ");
		int n = Integer.parseInt(in[0]);
		int k = Integer.parseInt(in[1]);
		
// 		StringBuilder str = new StringBuilder();
		
		in = br.readLine().split(" ");
		int[] arr = new int[n];

        for(int i=0;i<n;i++){
            arr[i] = Integer.parseInt(in[i]);
        }
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = dp[0]+Math.abs(arr[0]-arr[1]);
        for(int i=2;i<n;i++){
            dp[i] = Integer.MAX_VALUE;
            int curr = i;
            for(int j=1;j<=k && curr>=1;j++,curr--){
                dp[i] = Math.min(dp[i-j]+Math.abs(arr[i-j]-arr[i]),dp[i]);
            }
        }
        System.out.println(dp[n-1]);
	}
}


Measured memory_bytes: 35404
#include <bits/stdc++.h>
using namespace std; 
int maehutatsu (int n){
  n /= 1000;
  return n;
}
int usirohutatsu (int m){
  int ans = 0;
  m = m % 100;
  ans += m / 10 +((m % 10) *10);
  return ans ;
}
int main(){
  int A,B;
  cin >> A >> B ;
  int count = 0;
  for(int i = A;i<=B;i++){
  if(maehutatsu(i) == usirohutatsu(i)){
    count++;
  }
}
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
constexpr ll MOD = 998244353;

using Data = int;
const int len = 1 << 18;

struct BIT {
  vector<Data> data;
  BIT() : data(len, 0) {}
  void update(int i, Data value) {
    for (; i < len; i |= i+1) data[i] += value;
  }
  Data query(int i) {
    Data s = 0;
    for (; i >= 0; i = (i&i+1)-1) s += data[i];
    return s;
  }
};

ll p2m(ll i) {
  if (i == 0) return 1;
  if ((i%2) == 1) return (2*p2m(i-1))%MOD;
  ll h = p2m(i/2);
  return (h*h)%MOD;
}

int main()
{
  int n;
  cin>>n;
  vector<tuple<int,int>> vt;
  vecint vy;
  REP(i,n) {
    int x,y;
    cin>>x>>y;
    vt.emplace_back(x,y);
    vy.push_back(y);
  }
  sort(ALL(vt));
  sort(ALL(vy));
  ll sum = 0;
  BIT bit;
  REP(i,n) {
    int x,y;
    tie(x,y) = vt[i];
    int idx = lower_bound(ALL(vy), y) - begin(vy);
    int a = bit.query(idx);
    int c = i - a;
    int b = idx - a;
    int d = n-1-i-idx+a;
    sum += 2*p2m(n-1) + (MOD - p2m(b+d)) + (MOD - p2m(c+d))
      + (MOD - p2m(c+a)) + (MOD - p2m(a+b))
      + (p2m(a) + p2m(b) + p2m(c) + p2m(d))
      + (MOD - 1);
    sum %= MOD;
    bit.update(idx, 1);
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef pair<ll,ll> P;
const int N=111111;
vector<ll> v[N],v2[N];
ll d[N],ord[N],low[N],c[N],u[N];
set<P> s;

void dfs(int x,int p,int &c,vector<P> &B){
  ord[x]=low[x]=c++;
  for(int i=0;i<v[x].size();i++){
    int y=v[x][i];
    if(y==p) continue;
    if(ord[y]==-1){
      dfs(y,x,c,B);
      low[x]=min(low[x],low[y]);
    } else low[x]=min(low[x],ord[y]);
    if(ord[x]<low[y]) B.push_back(P(x,y));
  }
}

void bridge(int n,vector<P> &B){
  B.clear();
  int c=0;
  fill(ord,ord+n,-1);
  for(int i=0;i<n;i++)if(ord[i]==-1)dfs(i,-1,c,B);
}

int p[N],r[N];
void init(){for(int i=0;i<N;i++)p[i]=i,r[i]=0;}
int find(int x){return (p[x]==x)?x:(p[x]=find(p[x]));}
void unite(int x,int y) {
  x=find(x),y=find(y);
  if(x==y)return;
  if(r[x]<r[y])p[x]=y;
  else{p[y]=x;if(r[x]==r[y])r[x]++;}
}
bool same(int x,int y){return find(x)==find(y);}

P dfs(ll x,ll r) {
  u[x]=1;
  P p=P(0,0);
  for(int i=0; i<v2[x].size(); i++) {
    ll y=v2[x][i];
    if(y==r) continue;
    P q=dfs(y,x);
    p.F+=q.S;
    p.S+=max(q.F,q.S);
  }
  p.F+=d[x];
  return p;
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  init();
  ll n,m;
  cin >> n >> m;
  for(ll i=0; i<m; i++) {
    ll x,y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for(int i=0; i<n; i++) {
    sort(v[i].begin(),v[i].end());
    v[i].erase(unique(v[i].begin(),v[i].end()),v[i].end());
  }
  vector<P> g;
  bridge(n,g);
  for(int i=0; i<g.size(); i++) {
    if(g[i].F>g[i].S) swap(g[i].F,g[i].S);
    s.insert(g[i]);
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<v[i].size(); j++) {
      int x=i,y=v[i][j];
      if(x>y) swap(x,y);
      if(s.count(P(x,y))) continue;
      unite(x,y);
    }
  }
  for(int i=0; i<n; i++) d[find(i)]++;
  for(int i=0; i<g.size(); i++) {
    int x=find(g[i].F),y=find(g[i].S);
    v2[x].push_back(y);
    v2[y].push_back(x);
  }
  for(int i=0; i<n; i++) {
    sort(v2[i].begin(),v2[i].end());
    v2[i].erase(unique(v2[i].begin(),v2[i].end()),v2[i].end());
  }
  int ans=0;
  for(int i=0; i<n; i++) {
    if(!u[i]) {
      P q=dfs(i,-1);
      ans+=max(q.F,q.S);
    }
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int a,b;
    cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979

int main()
{
	int n, point, question;
	cin >> n >> point >> question;
	vector<int> p(n, point -  question);

	rep(i, question)
	{
		int x;
		cin >> x;
		p[x-1]++;
	}

	rep(i, n)
	{
		if (p[i] > 0) cout << "Yes" << endl;
		else          cout << "No"  << endl;
	}
	return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define INF 1 << 30
#define mod 1000000007
#define ll long long
#define pb push_back
#define pp pop_back
#define Loop(i,s,e) for(ll (i) = (s); (i) <= (e); ++(i))
#define desLoop(i,s,e) for(ll (i) = (s); (i) >= (e); --(i))
using namespace std;

typedef struct{int x,y;}point;

void Swap(ll*a,int x,int y){ll t=a[x];a[x]=a[y];a[y]=t;}
void Qsort(ll*n,int l,int r){if(l>=r)return;int i=l-1,j=r+1;ll m=n[(i+j)/2];
    while(1){while(n[++i]<m);while(n[--j]>m);if(i>=j)break;Swap(n,i,j);}
	Qsort(n,l,i-1);Qsort(n,j+1,r);}

ll min4(ll a,ll b,ll c,ll d){return min(min(a,b),min(c,d));}
ll max4(ll a,ll b,ll c,ll d){return max(max(a,b),max(c,d));}



int main()
{
	int tot, a, b;
	while ( cin >> tot >> a >> b ) {
		cout << min( a, b) << ' ' << max ( a+b-tot, 0) << '\n';
	}
	return 0;
}











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

static const int N = 100;
static const int INF = 1e9;

int h , w;
int sy, sx, gy, gx;
int d[N][N];
bool used[N][N];
vector<string> S;

int bfs(int sh, int sw){
    queue<pair<int, int> > Q;
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) used[i][j] = false;
    for(int i = 0; i < h; i++) for(int j = 0; j < h; j++) d[i][j] = INF;

    used[sh][sw] = true;
    d[sh][sw] = 0;
    Q.push(make_pair(sh, sw));//全てはスタート地点をqueueに突っ込んでからは閉まる
    while(!Q.empty()){
        pair<int,int> u = Q.front();Q.pop();
        int th = u.first, tw = u.second;
        used[th][tw] = true;
        if(th + 1 < h && !used[th+1][tw] && S[th+1][tw] == '.'){
            Q.push(make_pair(th+1,tw));
            used[th+1][tw] = true;
            d[th+1][tw] = d[th][tw] + 1;
        }
        if(th - 1 >= 0 && !used[th - 1][tw] && S[th-1][tw] == '.'){
            Q.push(make_pair(th-1,tw));
            used[th - 1][tw] = true;
            d[u.first - 1][tw] = d[th][tw] + 1;
        }
        if(tw + 1 < w && !used[th][tw+1] && S[th][tw+1] == '.'){
            Q.push(make_pair(th,tw+1));
            used[th][tw+1] = true;
            d[u.first][tw+1] = d[th][tw] + 1;
        }
        if(tw - 1 >= 0 && !used[th][tw-1] && S[th][tw-1] == '.'){
            Q.push(make_pair(th,tw-1));
            used[th][tw-1] = true;
            d[u.first][tw-1] = d[th][tw] + 1;
        }
    }
    int ans = 0;
    rep(i, 0, h) rep(j, 0, w) if(d[i][j] != INF) ans = max(ans, d[i][j]);
    return ans;
}
int main(){
    cin >> h >> w;
    S.resize(h);
    for(int i = 0; i < h; i++) cin >> S[i];

    int ans = 0;
    
    rep(i, 0, h) rep(j, 0, w) if(S[i][j] == '.') ans = max(bfs(i,j), ans);

    cout << ans << endl;

}


Measured memory_bytes: 256
import sys

n, m, l = [ int( val ) for val in sys.stdin.readline().split( " " ) ]

matrixA = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( n ) ]
matrixB = [ [ int( val ) for val in sys.stdin.readline().split( " " ) ] for row in range( m ) ]	
c = 0

output = []
for i in range( n ):
	for j in range( l ):
		c = 0
		for k in range( m ):
			c += ( matrixA[i][k] * matrixB[k][j] )
		output.append( "{:d}".format( c ) )
		output.append( " " )
	output.pop()
	output.append( "\n" )

output.pop()
print( "".join( output ) )

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll w, h, x, y;
    cin >> w >> h >> x >> y;

    cout << fixed << setprecision(15) << (double)w*h/2 << " ";
    if(x*2 == w && y*2 == h) cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		
		while (true) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int ans[] = new int[20];
			int id = 0;
			while (n != 0) {
				ans[id++] = n % 8;
				n /= 8;
			}
			for (int i = 0; i < id; i++) {
				if (4 <= ans[i]) {
					ans[i]++;
				}
				if (6 <= ans[i]) {
					ans[i]++;
				}
			}
			for (int i = id - 1; 0 <= i; i--) {
				System.out.print(ans[i]);
			}
			System.out.println();
		}
	}

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

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

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x;

            var word = Console.ReadLine().Split(' ');

            int n = int.Parse(word[0]);
            int a = int.Parse(word[1]);
            int b = int.Parse(word[2]);

            if (n * a > b)
                x = b;
            else
                x = a * n;
            
            Console.WriteLine(x);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N];
		int min = Integer.MAX_VALUE;
		int max = Integer.MIN_VALUE;
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			max = Math.max(max, a[i]);
			min = Math.min(min, a[i]);
		}
		
		int ans = Integer.MAX_VALUE;
		for(int i = min; i <= max; i++) {
			int temp = 0;
			for(int j = 0; j < N; j++) {
				temp += Math.pow(i - a[j], 2);
			}
			ans = Math.min(ans, temp);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  while (cin >> N) {
    int k;
    for (int i = 1; i <= N; i++) {
      if (N - i <= 1ll * (i - 1) * i / 2) {
        k = i;
        break;
      }
    }
    vector<int> ans = {k};
    int rem = N - k;
    for (int i = k - 1; i >= 1; i--) {
      if (rem >= i) {
        ans.push_back(i);
        rem -= i;
      }
    }
    for (int x : ans) cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 384
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

s = STR()
print(s[0] + str(len(s) - 2) + s[-1])

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

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

    int LSD = N % 10;
    int MSD = N / 100;

    if (LSD == MSD) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

signed main(void)
{
	int n, k;
	set<int> st;

	cin >> n >> k;
	rep(i, k)
	{
		int d;
		cin >> d;
		rep(j, d)
		{
			int a;
			cin >> a;
			st.insert(a);
		}
	}
	int ans = n - st.size();
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3604
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <ctime>
#include <set>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second

using namespace std;

const int N = 210;

bool isnotprime[10000010];
int prime[10000010], cnt;
void get_prime()
{
	isnotprime[1] = true;
	for (int i = 2; i <= 10000000; i ++) {
		if (!isnotprime[i]) prime[++ cnt] = i;
		for (int j = 1; j <= cnt && i * prime[j] <= 10000000; j ++) {
			isnotprime[i * prime[j]] = true;
			if (!(i % prime[j])) break;
		}
	}
}

int vv[10000010], p[N], d0[N], d1[N], lnk[N], cd0, cd1;
bool vis[N];
bool dfs(int x)
{
	Rep(i, cd1) if (!isnotprime[abs(d0[x] - d1[i])] && !vis[i]) {
	//	printf("!%d\n", abs(d0[x] - d1[i]));
		vis[i] = true;
		if (lnk[i] == -1 || dfs(lnk[i])){ lnk[i] = x; return true;} 
	}
	return false;
}

int main()
{
	get_prime();
	
	int T = 1;
	//scanf("%d", &T);
	while (T --){
		int n;
		scanf("%d", &n);
		cd0 = cd1 = 0;
		Rep(i, n) {
			scanf("%d", &p[i]);
			if (vv[p[i]] != T + 1) vv[p[i]] = T + 1;
		}
		Rep(i, n) {
			if (vv[p[i]] != vv[p[i] - 1]) {
				if (p[i] & 1) d1[++ cd1] = p[i];
				else d0[++ cd0] = p[i];
			}
			if (vv[p[i]] != vv[p[i] + 1]) {
				if (p[i] & 1) d0[++ cd0] = p[i] + 1;
				else d1[++ cd1] = p[i] + 1;
			}
		}
	//	printf("%d %d\n", cd0, cd1);
	//	Rep(i, cd0) printf("_%d ", d0[i]); printf("\n");
	//	Rep(i, cd1) printf("_%d ", d1[i]); printf("\n");
		
		int ans = 0;
		memset(lnk, -1, sizeof(lnk));
		Rep(i, cd0) {
			memset(vis, false, sizeof(vis));
			if (dfs(i)) ans ++;
		}
		ans += ((cd0 - ans) / 2) * 2 + ((cd1 - ans) / 2) * 2;
		if ((cd0 - ans) & 1) ans += 3;
		printf("%d\n", ans);
	}
	
	return 0;
}
/*
3
2
2 3
3
1 2 4
5
101 102 103 104 105
*/

Measured memory_bytes: 51200
package main
 
import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	"math"
)
 
var sc = bufio.NewScanner(os.Stdin)
var ReadString func() string
 
func init() {
	ReadString = newReadString()
}
 
/*------ scan ------*/
 
func newReadString() func() string {
	sc.Buffer(make([]byte, 1024), 2048)
	sc.Split(bufio.ScanWords)
	return func() string {
		if !sc.Scan() {
			panic("scanできなかった")
		}
		return sc.Text()
	}
}
 
func ReadLine() string {
	if !sc.Scan() {
		panic("line をscanできなかった")
	}
	return sc.Text()
}
 
func ReadInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		fmt.Println("parseInt失敗")
		panic(err.Error())
	}
	return int64(i)
}
 
func ReadInt() int {
	i := ReadInt64()
	return int(i)
}
 
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
 
func ReadInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt64()
	}
	return arr
}
 
/*------ number util ------*/
 
func GetIntAbs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
 
func Atoi(a string) int {
	i, err := strconv.Atoi(a)
	if err != nil {
		panic(err.Error())
	}
	return i
}
 
func FindMin(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	min := arr[0]
	for _, v := range arr {
		if v < min {
			min = v
		}
	}
	return min
}
 
func FindMax(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	max := arr[0]
	for _, v := range arr {
		if v > max {
			max = v
		}
	}
	return max
}
 
 
func main() {
	n := ReadInt()
	d := ReadInt()
	x := make([][]int, n)
	var cnt int
	for i := 0; i < n; i++ {
		xd := ReadIntSlice(d)
		x[i] = xd
	}
 
	for i := 0; i + 1 < n; i++ {
      for inner := i + 1; inner < n; inner++ {
 
		// diff求める
		curDiff := 0
		for j := 0; j < d; j++ {
          diff := GetIntAbs(x[i][j] - x[inner][j])
			curDiff += diff * diff
		}
		rs := math.Sqrt(float64(curDiff))
        intRs := int(rs)
		if float64(intRs) == math.Ceil(rs) && i < inner {
			cnt += 1
		}
      }
	}
	fmt.Println(cnt)
}

Measured memory_bytes: 640
H, W = map(int, input().split())
S = ['' for h in range(H)]
L = [[0 for w in range(W + 2)] for h in range(H + 2)]
R = [[0 for w in range(W + 2)] for h in range(H + 2)]
D = [[0 for w in range(W + 2)] for h in range(H + 2)]
U = [[0 for w in range(W + 2)] for h in range(H + 2)] 
ans = 0
for i in range(H):
  S[i] = input()
  for j in range(W):
    if S[i][j] == '.':
      L[i + 1][j + 1] = L[i + 1][j] + 1
    if S[i][W - 1 - j] == '.':
      R[i + 1][W - j] = R[i + 1][W - j + 1] + 1
for j in range(W):
  for i in range(H):
    if S[i][j] == '.':
      U[i + 1][j + 1] = U[i][j + 1] + 1
    if S[H - 1 - i][j] == '.':
      D[H - i][j + 1] = D[H + 1 - i][j + 1] + 1
for i in range(1, H + 1):
  for j in range(1, W + 1):
    ans = max(L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3, ans)
print(ans)

Measured memory_bytes: 181640
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
char s[200000];
int main(){
	cin >> s;
	int n = strlen(s);

	bool a = (n % 2 == 0);
	bool b = (s[0] == s[n - 1]);

	if(a ^ b) {
		cout << "Second" << endl;
	}else {
		cout << "First" << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main(){
  char s[20], t[20];
  scanf("%s\n%s", s, t);
  int len = strlen(s);
  t[len] = '\0';
  int a = strcmp(s, t);
  if(a == 0) puts("Yes");
  else puts("No");

  return 0;
}

Measured memory_bytes: 1636
def resolve():
    '''
    code here
    '''
    from decimal import Decimal
    a, b, c = [int(item) for item in input().split()]
    
    x = c - a - b
    y = 2 * Decimal(a*b).sqrt()

    if y < x:
        print('Yes')
    else:
        print('No')




if __name__ == "__main__":
    resolve()


Measured memory_bytes: 5204
n = int(input())
a = list(map(int,input().split()))
memo = {}
def f(a,b):
    if b==0:
        return a
    else:
        return f(b,a%b)
a = sorted(a)
ans = float('inf')
for i in range(len(a)-1):
    ans = min(ans,f(a[i],a[i+1]))
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define pii pair<int, int>
#define int long long
using namespace std;

int N, A, B;
int AA[55];
long double fact[55];
long long C[50][50];
void pre() {
  fact[0] = 1;
  for(int i = 1; i <= 50; i++) {
    fact[i] = fact[i - 1] * i;
  }
}

long double combin(int A, int B) {
  return fact[B] / fact[A] / fact[B - A];
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin >> N >> A >> B;
  pre();
  for(int i = 1; i <= N; i++) {
    cin >> AA[i];
  }
  sort(AA + 1, AA + N + 1, greater<int>());
  long double sum = 0;
  int last = -1, cntlast = 0;
  for(int i = 1; i <= A; i++) {
    sum += AA[i];
    if(AA[i] != last) {
      last = AA[i];
      cntlast = 1;
    }else cntlast++;
  }
  int cntlastA = cntlast;
  for(int i = A + 1; i <= N; i++) {
    if(AA[i] == last) {
      cntlast++;
    }
  }
  cout << fixed;
  cout << setprecision(6) << sum / A << "\n";
  if(cntlastA == A) {
    long double ans = 0;
    for(int i = A; i <= min(cntlast, B); i++) {
      ans += combin(i, cntlast);
    }
    cout << setprecision(0) << ans << '\n';
  }else {
    cout << setprecision(0) << combin(cntlastA, cntlast) << "\n";
  }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int n; cin >> n;
    if(n == 1) break;

    vi ans;
    for(int i = 2; i*i <= n;i++) {
      if((i % 7 == 1 || i % 7 == 6) && n % i == 0) {
        bool prime = true;
        for(int j = 2; j*j <= i;j++) {
          if((j%7==1 || j%7==6) && i % j == 0) {
            prime = false;
            break;
          }
        }
        if(prime) {
          ans.pb(i);
        }

        if(i == n/i) continue;
        prime = true;
        for(int j = 2; j*j <= n/i;j++) {
          if((j%7==1 || j%7==6) && (n/i)%j == 0) {
            prime = false;
            break;
          }
        }
        if(prime) {
          ans.pb(n/i);
        }
      }
    }
    if(SZ(ans) == 0) {
      cout << n << ": " << n << endl;
      continue;
    }
    sort(ALL(ans));
    cout << n << ":";
    REP(i, SZ(ans)) {
      cout << " " << ans[i];
    }
    cout << endl;
  }
}



Measured memory_bytes: 3136
/*  
     author : masaow    
     g++ : 17.3.20  
*/        
#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x)               cout << x << "\n" ; 
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set ; 
const int SIZE = 1e5+7 ;  
const int MOD = 1e9 +7 ; 
const int INF = 2e9+7 ;
/*  
    time : 07 : 31    
    date : 09...02...2020
*/ 
 
int a[307] ; 
int tests(){
  int N  ;
  cin >>N ; 
  int i ; 
  forn(i,0,N)
    cin >> a[i] ; 
  bool ok = true ; 
  forn(i,0,N)
    if(!(a[i]&1))
    ok &= ( a[i]%3 == 0 || a[i]%5 == 0 ) ;
  cout <<  ( ok ? "APPROVED\n" : "DENIED\n" ) ; 
      
  return 0 ; 
}
int main(){
    I__O ;  
    int cases = 1 ; 
    // cin >> cases;  
    while(cases--) 
      tests(); 
  return 0 ;
}
// web dev simplified
// LearnCode.Academy
/*
 g++ subminnnt.cpp -Wall -Wextra -pedantic
 -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal
 -Wconversion -Wlogical-op -Wshift-overflow=2
 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG
 -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address 
 -fsanitize=undefined -fno-sanitize-recover -fstack-protec    
*/         
         
  

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  double a,s;
  while(cin>>a){
    s=a;
    for(int i=0;i<4;i++){
      a*=2;
      s+=a;
      a/=3.0;
      s+=a;
    }
    s+=a*2;
    printf("%lf\n",s);
  }
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000007;

int main(){
  int N;
  cin >> N;
  int A[N+1], B[N+1];
  A[0] = -1;
  for(int i=1;i<=N;i++){
    cin >> A[i];
    B[i] = A[i];
  }
  sort(A, A+N+1);
  for(int i=1;i<=N;i++){
    if(B[i] <= A[N/2]) cout << A[N/2+1] << endl;
    else cout << A[N/2] << endl;
  }
}

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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    int a,b;
    cin >> a >> b;
    cout << a*(a-1)/2+b*(b-1)/2 << endl;

    return 0;
}

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

#define KIND_COUNT 4
#define TOTAL_COUNT 13

int main(void) {
  int n = 0;
  char kind = 0;
  int card = 0;
  
  bool cards[KIND_COUNT][TOTAL_COUNT] = {false};
  
  std::map<char, int> nameKinds;
  std::map<int, char> valueKinds;  

  nameKinds.insert(std::map<char, int>::value_type('S', 0));
  nameKinds.insert(std::map<char, int>::value_type('H', 1));
  nameKinds.insert(std::map<char, int>::value_type('C', 2));
  nameKinds.insert(std::map<char, int>::value_type('D', 3));

  valueKinds.insert(std::map<int, char>::value_type(0, 'S'));
  valueKinds.insert(std::map<int, char>::value_type(1, 'H'));
  valueKinds.insert(std::map<int, char>::value_type(2, 'C'));
  valueKinds.insert(std::map<int, char>::value_type(3, 'D'));    

  std::cin >> n;

  for (int i = 0; i < n; i++) {
    std::cin >> kind >> card;
    
    cards[nameKinds[kind]][card - 1] = true;
  }

  for (int i = 0; i < KIND_COUNT; i++) {
    for (int j = 0; j < TOTAL_COUNT; j++) {
      if (!cards[i][j]) {
	
	std::cout << valueKinds[i] << " " << (j + 1) << std::endl;
      }
    }
  }

  return 0;
}

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

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

  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] == cnt + 1) {
      cnt++;
    }
  }

  if (cnt == 0) {
    cout << -1 << endl;
  } else {
    cout << N - cnt << endl;
  }
}

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


int main(){
    int n, sum = 0;
    cin >> n;
    vector<int> arr(n);

    for(int i = 0; i < n; ++i) {
        cin >> arr.at(i);
        sum += arr.at(i);
    }

    if (sum % 10)
        cout << sum << endl;
    else {
        sort(arr.begin(), arr.end());
        auto it = find_if(arr.begin(), arr.end(), [sum](int i){
                return (sum - i) % 10 != 0;
            });
        if (it == arr.end()) {
            cout << 0 << endl;
        } else {
            cout << (sum - *it) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
lima = 0
tujuh = 0
a = [int(tmp) for  tmp in input().split()]
for i in range(3) :
  if a[i] == 5 :
    lima += 1
  elif a[i] == 7 :
    tujuh += 1
if lima==2 and tujuh == 1 :
  print("YES")
else :
  print('NO')

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

int main()
{

    int n;
    cin>>n;

    int a[2*n];

    for(int i=0;i<2*n;i++)
        cin>>a[i];
    vector<int>v(a,a+2*n);
    sort(v.begin(),v.end());
  
    int ans=0;
    for(int i=0;i<2*n;i+=2)
        ans+=min(v[i],v[i+1]);
    cout<<ans<<endl;




}


Measured memory_bytes: 256
using DataStructures
const double = Float64
const int = Int64

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  N = readint()[1]
  S = ["AC", "WA", "TLE", "RE"]
  d = Dict{String,int}()
  for moji in S
    get!(d,moji,0)
  end
  for _ in 1:N
    s = readline()
    #get!(d,s,0)
    d[s]+=1
  end

  for moji in S
    println(moji," x ",d[moji])
  end


end

main()

Measured memory_bytes: 194940
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
int main() {
	int n;
	cin >> n;
	string s[105];
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	int m;
	cin >> m;
	string t[105];
	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}
	ll count = 0,ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (s[i] == s[j]) {
				count++;
			}
		}
		for (int k = 0; k < m; k++) {
			if (s[i] == t[k]) {
				count--;
			}
		}
		ans = max(ans, count);
		
		count = 0;
	}
	cout << ans << endl;
	return 0;
}


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


int main(){
	int N;cin >> N;
	rep(i,101){
		if(N-i*1000<=0){
			cout << 1000*i-N << endl;
			return 0;
		}
	}
	return 0;

}












Measured memory_bytes: 3592
// 2011/02/06 Tazoe

#include <iostream>
using namespace std;

void DFS(char farm[102][102], int H, int W, char fruit, int h, int w)
{
	if(farm[h][w]!=fruit)
		return;

	farm[h][w] = '/';

	DFS(farm, H, W, fruit, h  , w+1);
	DFS(farm, H, W, fruit, h+1, w  );
	DFS(farm, H, W, fruit, h  , w-1);
	DFS(farm, H, W, fruit, h-1, w  );
}

int main()
{
	while(true){
		int H, W;
		cin >> H >> W;
		if(H==0&&W==0)
			break;

		char farm[102][102];
		for(int h=0; h<H+2; h++)
			for(int w=0; w<W+2; w++)
				farm[h][w] = '-';

		for(int h=1; h<=H; h++)
			for(int w=1; w<=W; w++)
				cin >> farm[h][w];

		int cnt = 0;
		for(int h=1; h<=H; h++)
			for(int w=1; w<=W; w++)
				if(farm[h][w]!='/'){
					cnt++;
					DFS(farm, H, W, farm[h][w], h, w);
				}

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
using namespace std;
struct MyStruct{
	int n;
	int w;
};
int main() {
	vector<MyStruct>l;
	MyStruct t;
	int num, walk1, walk2, n, mnum, mwalk;
	while (cin >> n){
		if (n == 0)break;
		cin >> num >> walk1 >> walk2;
		walk1 += walk2;
		mnum = num;
		mwalk = walk1;
		for (int i = 0; i < n - 1; i++) {
			cin >> num >> walk1 >> walk2;
			walk1 += walk2;
			if (walk1 >= mwalk){
				mnum = num;
				mwalk = walk1;
			}
		}
		t.n = mnum;
		t.w = mwalk;
		l.push_back(t);
	}
	for (MyStruct i : l) {
		cout << i.n << ' ' << i.w << endl;
	}
	char qq;
	cin >> qq;
}

Measured memory_bytes: 3024
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007
#define DEBUG 0


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}




int dis[10][10];





int main()
{

	int h, w;
	cin >> h >> w;

	for (int i = 0; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			cin >> dis[i][j];
		}
	}












	int count[10] = { 0 };
	int wk;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> wk;
			if(wk != -1)count[wk]++;
		}
	}



	//ワーシャルフロイド
	for (int k = 0; k <= 9; k++) { //経由頂点
		for (int i = 0; i <= 9; i++) { //始点
			for (int j = 0; j <= 9; j++) { //終点
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
			}
		}
	}
	
	long long int ans = 0;
	for (int i = 0; i <= 9; i++) {
		ans += count[i] * dis[i][1];
	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 256
import sys
x=int(input())

def prime(n):
    if n==1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            return False
    return True

for j in range(x,2*x):
    if prime(j)==True:
        print(j)
        sys.exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int q;
    cin >> q;
    int a, x;
    set<int> s;
    while(q--){
        cin >> a >> x;
        if(a==0){
            s.insert(x);
            cout << s.size() << "\n";
        }else{
            cout << s.count(x) << "\n";
        }
    }
    
    return 0;
}


Measured memory_bytes: 12376
h,w=map(int,input().split())
a=[list(input())for i in range(h)]
s=[[0]*(w+1) for i in range(h+1)]
mod=10**9+7
s[1][1]=1
for i in range(h):
    for j in range(w):
        if a[i][j]==".":
            s[i+1][j+1]+=(s[i][j+1]+s[i+1][j])%mod
print(s[-1][-1])

Measured memory_bytes: 51504
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<math.h>
#include<iomanip>
#include<bitset>
#include<deque>
using namespace std;
typedef long long ll;
int main(){
    int n;
    scanf("%d",&n);
    int x=n%10;
    int y=(n-x)/10;
	if(x==9||y==9){
    	cout<<"Yes"<<endl;
	}
    else cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  int S, W;
  cin >> S >> W;
  if (W >= S) {
    cout << "unsafe" << endl;

  } else {
    cout << "safe" << endl;
  }
}

Measured memory_bytes: 3640
import numpy as np


def main():
    n = int(input())
    As = list(map(int, input().split()))
    cumsum = np.cumsum(As)
    ans = float("inf")
    for i in range(n-1):
        ans = min(ans, abs(cumsum[n-1]-2*cumsum[i]))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 49024
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, x;
    cin >>n >>x;
    vector<int> l(n);
    for(int i = 0; i < n; i++)
        cin >>l[i];
    vector<int> d;
    d.push_back(0);
    for(int i = 1; i <= n; i++)
        d.push_back(d[i-1] + l[i-1]);
    int i = 0, ans = 0;
    while(i <= n && d[i] <= x){
        ans++;
        i++;
    }
    cout <<ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int firstAnt = 0;
		int lastAnt = 0;
		for(int i = 0;i<5;i++) {
			int tmp = Integer.parseInt(sc.nextLine());
			if(i == 0) {
				firstAnt = tmp;
			}else if(i == 4) {
				lastAnt = tmp;
			}
		}
		int allowedDistant = Integer.parseInt(sc.nextLine());
		String result = "";
		if((lastAnt - firstAnt) <= allowedDistant) {
			result = "Yay!"; 
		}else {
			result = ":(";
		}

		
		
		System.out.println(result);

		
		
		
	}
}
	
	

Measured memory_bytes: 21972
n = int(input())
d = list(map(int,input().split()))
if d[0] != 0:
  print(0)
  exit()
c = [0 for _ in range(n)]
for i in range(1,n):
  if d[i] == 0:
    print(0)
    exit()
  else:
    c[d[i]] += 1
res = 1
for i in range(n-1,1,-1):
  if c[i] != 0:
    res = (res*(c[i-1]**c[i]))%(998244353)
print(res)

Measured memory_bytes: 13908
package main

import (
        "bufio"
        "fmt"
        "os"
)

var rdr = bufio.NewReader(os.Stdin)

func readLine() string {
        var buf []byte
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func lowerBound(a []int, x int) int {
        n := len(a)
        ok := n
        ng := -1
        for ok-ng > 1 {
                mid := (ok + ng) / 2
                if a[mid] >= x {
                        ok = mid
                } else {
                        ng = mid
                }
        }
        return ok
}

func main() {
        var s string
        var t string

        s = readLine()
        t = readLine()

        idxs := make([][]int, 256)

        for i := 0; i < len(s); i++ {
                idxs[s[i]] = append(idxs[s[i]], i)
        }

        n := int64(len(s))
        cur := int64(0)
        ng := false

        for i := 0; i < len(t); i++ {
                is := idxs[t[i]]
                if is == nil || len(is) == 0 {
                        ng = true
                        break
                }
                base := (cur / n) * n

                nidx := lowerBound(is, int(cur%n))
                if nidx == len(is) {
                        cur = base + int64(is[0]) + n + 1
                } else {
                        cur = base + int64(is[nidx]) + 1
                }
        }
        if ng {
                fmt.Println(-1)
        } else {
                fmt.Println(cur)
        }
}


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;

#define MAX_V 300
int d[MAX_V][MAX_V];
int V, M, R;
void warshall_floyd() {
	rep(k, 0, V) rep(i, 0, V) rep(j, 0, V) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

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

  cin >> V >> M >> R;
  rep(i, 0, V) rep(j, 0, V) d[i][j] = INF;

  int r[R];
  rep(i, 0, R) {
    cin >> r[i];
    --r[i];
  }
  rep(i, 0, M) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    d[a][b] = c;
    d[b][a] = c;
  }
  warshall_floyd();

  int array[R];
  rep(i, 0, R) array[i] = i;
  int rsl = INF;
  do {
    int tmp = 0;
    rep(i, 0, R - 1) {
      tmp += d[r[array[i]]][r[array[i + 1]]];
    }
    chmin(rsl, tmp);
  } while (next_permutation(array, array + R));
  cout << rsl << endl;
}



Measured memory_bytes: 512
#include <vector>

class ISorter
{
public:
    virtual bool Sort(std::vector<int>&) = 0;
};

#include <array>


class MySorter
{
private:
    ISorter *sorter;
public:
    MySorter(ISorter *sorter);
    ~MySorter();
    bool Sort(std::vector<int> array);
};


#include <vector>

class InsertionSort : public ISorter
{
public:
    bool Sort(std::vector<int>&);
    InsertionSort();
    ~InsertionSort();
};

// InsertionSort.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <memory>


void printArray(const std::vector<int> &array);
std::vector<int> readArray(void);

int main()
{
    int n = 0;
    std::string input;
    std::getline(std::cin, input);
    n = std::stoi(input);

    std::vector<int> array = readArray();

    std::unique_ptr<InsertionSort> algorithm = std::make_unique<InsertionSort>();
    std::unique_ptr<MySorter> sorter = std::make_unique<MySorter>(algorithm.get());

    sorter->Sort(array);

    return 0;
}


void printArray(const std::vector<int> &array)
{
    for (unsigned int k = 0; k < array.size(); k++) {
        std::cout << array[k];
        if (k != array.size() - 1) {
            std::cout << " ";
        }
    }
    std::cout << std::endl;
}

std::vector<int> readArray(void)
{
    std::string input;
    std::vector<int> array;

    std::getline(std::cin, input);
    std::stringstream ss(input);

    std::string buf;
    while (ss >> buf) {
        array.push_back(std::stoi(buf));
    }

    return array;
}


#include <memory>

MySorter::MySorter(ISorter *sorter)
{
    this->sorter = sorter;
}

MySorter::~MySorter()
{
}

bool MySorter::Sort(std::vector<int> array)
{
    return sorter->Sort(array);
}

#include <iostream>

InsertionSort::InsertionSort()
{
}

InsertionSort::~InsertionSort()
{
}

bool InsertionSort::Sort(std::vector<int> &array)
{
    int n = array.size();

    for (int i = 0, j = 0; i < n; i++) {
        auto v = array[i];
        j = i - 1;
        while (j >= 0 && array[j] > v) {
            array[j + 1] = array[j];
            j--;
        }
        array[j + 1] = v;

        for (unsigned int k = 0; k < array.size(); k++) {
            std::cout << array[k];
            if (k != array.size() - 1) {
                std::cout << " ";
            }
        }
        std::cout << std::endl;
    }

    return true;
}


Measured memory_bytes: 3156
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) cin >> d.at(i);
    
    sort(d.begin(), d.end());
    
    cout << d.at(n / 2) - d.at(n / 2 - 1) << endl;
    
    return 0;
}


Measured memory_bytes: 640