akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cctype>
using namespace std;
const int N=105,S=N*N<<1,inf=1e9;
int tot,s,t,sum,ans;
int first[S],next[S*10],en[S*10],w[S*10];
int in[N][N],out[N][N],r[N],c[N];
int dis[S],gap[S],cur[S];
char st[N][N];
inline int read()
{
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) w|=ch=='-',ch=getchar();
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
inline int min(int x,int y)
{
	return x<y?x:y;
}
inline void ins(int x,int y,int z)
{
	next[++tot]=first[x];
	first[x]=tot;
	en[tot]=y;
	w[tot]=z;
}
inline void insert(int x,int y,int z)
{
	ins(x,y,z),ins(y,x,0);
}
int sap(int x,int y)
{
	if(x==t) return y;
	int use=0;
	for(int i=cur[x];i;i=next[i])
		if(w[i] && dis[x]==dis[en[i]]+1)
		{
			cur[x]=i;
			int p=sap(en[i],min(w[i],y-use));
			w[i]-=p,w[i^1]+=p,use+=p;
			if(use==y || dis[s]>sum) return use;
		}
	cur[x]=first[x];
	if(!--gap[dis[x]]) dis[s]=sum+1;
	gap[++dis[x]]++;
	return use;
}
int main()
{
	int n=read(),m=read();
	s=++tot,t=++tot;
	for(int i=1;i<=n;i++)
	{
		scanf("%s",st[i]+1);
		for(int j=1;j<=m;j++)
			if(st[i][j]=='o')
			{
				in[i][j]=++tot;
				out[i][j]=++tot;
			}
	}
	for(int i=1;i<=n;i++) r[i]=++tot;
	for(int i=1;i<=m;i++) c[i]=++tot;
	gap[0]=sum=tot;
	for(int i=tot=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(st[i][j]=='o')
			{
				insert(in[i][j],out[i][j],1);
				insert(r[i],in[i][j],inf);
				insert(c[j],in[i][j],inf);
				insert(out[i][j],r[i],inf);
				insert(out[i][j],c[j],inf);
			}else
			if(st[i][j]=='S')
			{
				insert(s,r[i],inf);
				insert(s,c[j],inf);
			}else
			if(st[i][j]=='T')
			{
				insert(r[i],t,inf);
				insert(c[j],t,inf);
			}
	for(int i=1;i<=sum;i++) cur[i]=first[i];
	while(dis[s]<=sum) ans+=sap(s,inf);
	printf("%d",ans>=n*m?-1:ans);
	return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n >= 2 && n <= 100) {
			int[] score = new int[n+1];
			int a, b, c, d; // team a, team b, score a, score b;
			for(int i=0; i<n*(n-1)/2; i++) {
				a = sc.nextInt();
				b = sc.nextInt();
				c = sc.nextInt();
				d = sc.nextInt();
				if(c > d) {
					score[a] += 3;
				} else if(c < d) {
					score[b] += 3;
				} else {
					score[a]++;
					score[b]++;
				}
			}
			
			/* ソートした配列を別に用意、
			 * 順に比較して一致したものにランクづけ
			*/
			int[] sort = new int[n];
			int[] rank = new int[n+1];
			
			for(int i=1; i<=n; i++) {
				sort[i-1] = score[i];
			}
			Arrays.sort(sort);
			int x = 1; // 順位をあらわす
			int cnt;
			
			for(int i=n-1; i>=0;) {
				cnt = 0; // 増分値指定の変数
				for(int j=1; j<=n; j++) {
					if(sort[i] == score[j]) {
						rank[j] = x;
						cnt++;
					}
				}
				x += cnt; // 次の順位を導く
				i -= cnt; // 重複しないよう、同じ内容の要素をスキップ
			}

			for(int i=1; i<rank.length; i++) {
				System.out.println(rank[i]);
			}
		}
	}
}

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

using namespace std;

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

  unsigned A[N];
  uint64_t S = 0;
  
  for (int n=0; n<N; ++n) {
    cin >> A[n];
    S += A[n];
  }

  uint64_t M[N];

  M[0] = S;
  for (int n=1; n<N; n+=2) {
    M[0] -= 2*A[n];
  }

  for (int n=1; n<N; ++n) {
    M[n] = 2*A[n-1] - M[n-1];
  }  

  for (int n=0; n<N; ++n)
    cout << M[n] << ' ';

  cout << endl;

  return 0;
}


Measured memory_bytes: 2432
import sys
import math
#a,b= map(int,input().split())
#li= [int(x) for x in input().split()]
a=int(input())
S=input()
x=0
if a%2==1:
  print("No\n")
  sys.exit()
for i in range((len(S)//2)):
  if S[i]!= S[i+len(S)//2]:
    print("No\n")
    sys.exit()
print("Yes\n")



Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{
	int n;
	int maxn = 1e5;
	int a[maxn],b[maxn];
	int count = 0,sum = 0;
	int i;
	scanf("%d",&n);
	for(i = 1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum += a[i];
		if(i % 2 != 0) count += a[i];
	}
	b[1] = (count*2) - sum;
	for(i = 1;i<n;i++)
		b[i+1] = (a[i]*2) - b[i];
	for(i = 1;i<=n;i++)
	{
		if(i == 1) printf("%d",b[i]);
		else printf(" %d",b[i]);
	}
	
	return 0;
}

Measured memory_bytes: 2048
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k,l;
  int a[36000],n;
  a[0]=6;
  j=1;
  for(i=1;1+7*i<300000;i++){
    l=(int)sqrt(1+7*i)+1;
    for(k=0;1+7*k<l;k++){
      if(k&&(1+7*i)%(1+7*k)==0)
	break;
      if((1+7*i)%(6+7*k)==0)
	break;
    }
    if(1+7*k>=l){
      a[j]=1+7*i;
      j++;
    }
    l=(int)sqrt(6+7*i)+1;
    for(k=0;1+7*k<l;k++){
      if(k&&(6+7*i)%(1+7*k)==0)
	break;
      if((6+7*i)%(6+7*k)==0)
	break;
    }
    if(1+7*k>=l){
      a[j]=6+7*i;
      j++;
    }
  }
  a[j]=300001;
  while(cin>>n&&n!=1){
    cout<<n<<":";
    for(i=0;a[i]<=n;i++){
      if(n%a[i]==0)
	cout<<" "<<a[i];
    }
    cout<<endl;
  }
  return 0;
}

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

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

int main() {
  int n,m;
	cin >> n >> m;
  int x[m],y[m],z[m];
  rep(i,m){
    cin >> x[i] >> y[i] >> z[i];
    x[i]--;
    y[i]--;
  }
  UnionFind Uni(n);
  rep(i,m)Uni.connect(x[i], y[i]);
  map<int,int> ans_map;
  rep(i,n)ans_map[Uni.root(i)]++;
  cout << ans_map.size() << endl;
}


Measured memory_bytes: 6400
/******************************\
*  Everyone has a different way of thinking, so God Created us
Hope You Respect My Way..,Thank You ):  *
*                            *
*   Created by : Murad   *
\******************************/
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define MP make_pair
#define ff first
#define ss second
#define INF 2147483647
#define _INF -2147483647
#define pq priority_queue
#define MM multimap
#define PB push_back
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
LL MMIN(LL a, LL b)
{
	if (a <= b)
		return a;
	else
		return b;
}
LL MMAX(LL a, LL b) {
	if (a >= b)
		return a;
	else
		return b;
}
int main()
{
	El3zba;
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	double ans = (a[0] + a[1]) / 2.0;
	for (int i = 2; i < n; i++)
		ans = (ans + a[i]) / 2.0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n, ll m = mod) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	while (b) {
		ll r = a % b; a = b; b = r;
	}
	return a;
}

modint calc(int n, int k) {
	modint res = 1;
	rep1(i, k) {
		res *= (n + 1 - i);
		res = res / (modint)i;
	}
	return res;
}
void solve() {
	int n;
	cin >> n;
	int a, b; cin >> a >> b;
	modint ans = mod_pow(2, n);
	ans -= calc(n, a);
	ans -= calc(n, b);
	ans -= 1;
	cout << ans << "\n";
}





signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	init_f();
	//init();
	//expr();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}


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

int main() {
  int a,sum = 0;
  cin >> a;
  int jwe[a],wor[a];
  for(int i = 0;i<a;i++){
    cin >> jwe[i];
  }
  for(int i = 0;i<a;i++){
    cin >> wor[i];
  }
  for(int i = 0;i<a;i++){
    sum += max(jwe[i]-wor[i],0);
  }
  cout << sum;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n;
    cin >> n;
    int v[n];
    fore(i,0,n) cin >> v[i];
    cout << *max_element(v, v+n) - *min_element(v, v+n) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define rrep()
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int h,w;
    cin>>h>>w;
    int v[10][10];
    rep(i,0,10)rep(j,0,10)cin>>v[i][j];
    
    rep(i,0,10){
        rep(j,0,10){
            rep(k,0,10){
                v[j][k]=min(v[j][k],v[j][i]+v[i][k]);
            }
        }
    }
    ll ans=0;
    rep(i,0,h)rep(j,0,w){
        int x;
        cin>>x;
        if(x!=-1)ans+=v[x][1];
    
    }
    cout<<ans<<endl;
    
    return 0;
}


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

int main()
{
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1)
	{
	    c=c-b;
	    if(a<=0 || c<=0)
	    {
		    if(a<=0)
		    {
			    cout<<"No";
		    }
		    else
		    {
			    cout<<"Yes";
	 	    } 
	 	    return 0;
	    }
	    else
	      a=a-d;
    }
	return 0;
}

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

using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;


ll mo=1000000007;
ll comb(ll N_, ll C_) {
    const int NUM_=310000;
    static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
    if (fact[0]==0) {
        inv[1]=fact[0]=factr[0]=1;
        for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
        for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
    }
    if(C_<0 || C_>N_) return 0;
    return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
int32_t main() {
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    oneforall
    
    ini(n);
    ins(morty);
    ini(n1);
    FOR(i,0,n1){
        ini(x);
        int d = 0;
        int m = 0;
        int dm = 0;
        int tmp = 0;
        int i1 = 0;
        FOR(i,0,n){
            if(morty[i] == 'D')d++;
            else if(morty[i] == 'M'){
                m++;
                dm+=d;
            }
            else if(morty[i] == 'C'){
                tmp+=dm;
            }
            if(i>=x-1){
                if(morty[i1] == 'D'){
                    dm-=m;
                    d--;
                }
                else if(morty[i1] == 'M')m--;
                i1++;
            }
        }
        out(tmp);
    }
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 1948
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    if p[i]-1 == i:
        p[i], p[i+1] = p[i+1],p[i]
        ans += 1
for i in range(n-1, 0, -1):
    if p[i]-1 == i:
        p[i], p[i-1] = p[i-1], p[i]
        ans+=1
print(ans)


Measured memory_bytes: 52332
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

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

using namespace std;

typedef long long ll;

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

  int n, k;
  cin >> n >> k;
  
  int h, ans = 0;
  rep(i, n) {
    cin >> h;
    if (h >= k) { ans++; }
  }

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


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

from collections import Counter

def main():
  s = input().strip()
  cnt = Counter(s)
  if len(cnt) == 1:
    print(0)
  else:
    print(2*min(cnt.values()))
  pass

if __name__=='__main__':
  main()

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

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

int main(void) {
	int n;
	int a[200000];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	qsort(a, n, sizeof(int), asc);
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

const int MAX_N = 1e5;
int dp[MAX_N + 10][4][4];

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

    vec<int> a(N), b(N), c(N);
    rep(i, N) cin >> a[i] >> b[i] >> c[i];

    vec<vec<int>> dp(N + 10, vec<int>(4, -1e9));
    dp[1][1] = a[0];
    dp[1][2] = b[0];
    dp[1][3] = c[0];

    int ans = max({a[0], b[0], c[0]});
    for (int i = 2; i <= N; ++i)
        rep(o, 4) {
            if (!(o == 1)) dp[i][1] = max(dp[i][1], dp[i - 1][o] + a[i - 1]);
            if (!(o == 2)) dp[i][2] = max(dp[i][2], dp[i - 1][o] + b[i - 1]);
            if (!(o == 3)) dp[i][3] = max(dp[i][3], dp[i - 1][o] + c[i - 1]);

            if (i == N) ans = max({ans, dp[N][1], dp[N][2], dp[N][3]});
        }
    cout << ans << endl;
}


Measured memory_bytes: 9832
/*　　　　　　　{:i:i:|i:i:/l/l--　 　 　--l/li:i:i|i:i:i:i}
　　　　　　 　 {:rx|:i:i ィi芥ミ 　 　 .ィi芥ミｉ:ｉ|ﾍ:i:i:}
.　　　 　 　 　 ｛ﾏ|ｉ:  {::’:} 　 　 　{:‘::} :ｉ:i:|〉｝:/
　　 　 　 　 　 乂|:i:| ｀¨¨¨¨´ 　 　　｀¨¨¨´  :i:ｉ:|ｼ/
　 　 　 　 　 　 ﾉ:|:i|　　　　　　′　　　 　   |:i:i:|ﾂ
　　　　　　　　/:/|:i:| ､　　　 　_ _ 　　　　  |:i:i:|
　 　 　　 　 /:/ .|:i:|/ ＼　　　 　 　     ｨ〔|:i:/
　　 　 　  　 〈;/ く刈＿ 个 　   -   　＜}　./|/_〉
　　     　　 r-っ'~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ|___
　　 　     /／ニつ　　　　　　 ､　　　　　　　ノﾆﾆ　＼
.　　　     |　　ニ⊃ 　./　/　 ──   /　/　　..⊆ﾆﾆ　　:|
.　　　     |　　丁´　 /|￣|￣  ─‐ /|￣|￣ 　 .￣|丁 　|
.　　　     |　　ﾉ.  　 |￣|￣  ─‐  |￣|￣ 　 　.|八 　|
.　　　     |　　||. 　 |￣|￣ |￣| |￣|￣ 　   .|　|
.　 　 　   |  　||   　￣￣￣　￣ 　￣￣￣　　  .|　|  |
.　 　 　  　    ||＿＿＿＿＿＿＿＿＿＿＿＿______|__　　 ',
　 　      ,′　 | ７ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ}  ,′
.　　     {　　　|/　}ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ{/ 　 　
*///讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐。
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>

using namespace std;

#define rep(a) _rep(0,int(a))
#define repj(a) for(int j=0;j<int(a);j++)
#define repk(a) for(int k=0;k<int(a);k++)
#define _rep(a,b) for(int i=int(a);i<int(b);i++)
#define ll long long
#define fst first
#define snd second
#define pf(b) printf("%.12f\n",(double)b)
#define _GLIBCXX_DEBUG
const double pai = 3.1415926535897;
#define _cos(n) cos(n*pai/180)
#define l_b lower_bound
#define u_b upper_bound
#define b_s binary_search

//factorial(練習)　階乗
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}
int sa(int n, int m) {      //差！
	if (n < m)return m - n;
	else return n - m;
}
int keta(int num) {
	int n = 0;
	if (num==0) {
		return 1;
	}
	while (num != 0) {
		num /= 10;
		n++;
	}
	return n ;
}

int n;
signed main() {
	cin >> n;
	if (n % 2 == 0)cout << n << endl;
	else cout << n * 2 << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

// for each x, count
// a***b
// b=0 -> 0
// a=b -> 1
// a>b -> 1

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll r;
  cin >> r;
  if (r < 1200)
    cout << "ABC" << endl;
  else if (r < 2800)
    cout << "ARC" << endl;
  else
    cout << "AGC" << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <array>

using namespace std;

int main() {
    string s;
    cin >> s;
    auto n = s.length();
    string r = "";
    for (int i = 0; i < n; i++) {
        r.append("x");
    }
    
    cout << r << "\n";
    
    return 0;
}


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

int K;
int N = 8;
vector<pair<int, int > > V;
int row[8], col[8], dpos[15], dneg[15];
bool X[8][8];

void rec(int i){
    if(i==N) {
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                if(X[i][j]){
                    if(row[i] != j) return;
                }
            }
        }
        
        
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                cout << ((row[i] == j) ?  "Q": ".");
            }
            
            cout << endl;
        }
        
        return;
        
    }
    
    for(int j = 0; j < N; j++){
        if(col[j] == 1 || dpos[i+j] == 1 || dneg[i - j + N - 1] == 1) continue;
        /* i, j　に設置する */
        row[i] = j;
        col[j] = dpos[i+j] = dneg[i-j + N-1] = 1;
        rec(i+1);
        row[i] = col[j] = dpos[i+j] = dneg[i-j + N - 1] = -1; 
    }
    
}


int main(void){
    cin >> K;
    int r, c;
    for(int i = 0; i < K; i++) {
        cin >> r >> c;
        V.push_back(make_pair(r, c));
    }
    
    
    for(int i = 0; i < 8; i++) row[i] = -1, col[i] = -1;
    for(int i = 0; i < 2*N-1; i++) dpos[i] = -1, dneg[i] = -1;
    for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) X[i][j] = false;
    for(int i = 0; i < K; i++){
        X[V[i].first][V[i].second] = true;
    }
    
    rec(0);
    return 0;
}



Measured memory_bytes: 3112
N,Y = map(int, input().split())

for _i in range(Y // 10000 + 1):
    for _j in range((Y - 10000 *_i) // 5000+1):
        z = (Y - 10000 * _i - 5000 * _j)//1000
        if sum((_i, _j, z)) == N:
            print(_i, _j, z)
            exit()
else:
    print(-1,-1,-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, n , m) for(int i = n; i <= m; i++)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
const int mod = 1000000007; 
long long inv[200000],fact[200000],ifact[200000];
long long comb(ll n, ll k){
	if(n<k)return 0;
	else if (n<0||k<0) return 0;
	else return fact[n] * ifact[k] % mod * ifact[n-k] % mod;
}
 
 
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	/*inv[1] = fact[0] = fact[1] = ifact[0] = ifact[1] = 1; for (int i=2;i<200000;i++){ inv[i] = (mod - mod / i) * inv[mod % i] % mod; fact[i] = fact[i-1] * i % mod;ifact[i] = ifact[i-1] * inv[i] % mod;
	}*/ //nCr
	int N,D;
	cin>>N>>D;
	int X[N][D];
	rep(i,N){
		rep(j,D){
			cin>>X[i][j];
		}
	}
	int ans=0;
	rep(i,N){
		rep(j,N){
		    if(i==j)continue;
			int sum=0;
			rep(k,D){
				sum+=(X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
			}
			int a=(int)sqrt((double)sum);
			if(a*a==sum)ans++;
		}
	}
	cout<<ans/2<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val (N, M) = readInts()
  println(if (N == M) "Yes" else "No")
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


long double logn(int base, int tv)
{
  return log(tv) / log(base);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  long double n, k;
  cin >> n >> k;
  long double res = 0;

  for (int i = 1; i <= n; i++) {
    int tmp = i;
    long double p = 1;
    while(tmp < k){
      tmp *= 2;
      p *= 0.5;
    }
    res += p;
  }
  res /= n;
  printf("%.10Lf\n",res);


}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<iomanip>


using namespace std;


int main()

{
	long long x, y,z;
	cin >> x >> y;
	if (x >= 10)
	{
		cout << y << endl;
	}
	else
	{
		z = 100 * (10 - x);
		z += y;
		cout << z << endl;
	}




}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 1024
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define phi (1.0+sqrt(5))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[4]={0,1,0,-1};
const int dy[4]={-1,0,1,0};

string s;
string grid[MAX];
int h,w,n;
int d[MAX][MAX][4];
int sy,sx,gx,gy;
int a[1000001];
int mem[1000001][4];

class State{
  public:
    int y,x,d,c;
    State(int y,int x,int d,int c):y(y),x(x),d(d),c(c){}
    bool operator<(State s)const{
      return s.c<c;
    }
};

bool in(int y,int x){
  if(x<0 || y<0 || w<=x || h<=y)return false;
  return true;
}

string solve(){
  fill(a,a+n,0);
  FOR(i,1,n+1){
    if(s[i-1]=='R')a[i]=a[i-1]+1;
    else a[i]=a[i-1]+3;
    a[i]%=4;
  }
  int A=-1,B=-1,C=-1,D=-1;
  RFOR(i,n+1,0){
    mem[i][0]=A;
    mem[i][1]=B;
    mem[i][2]=C;
    mem[i][3]=D;
    if(a[i]==0)A=i;
    if(a[i]==1)B=i;
    if(a[i]==2)C=i;
    if(a[i]==3)D=i;
  }

  FOR(i,0,MAX)FOR(j,0,MAX)FOR(k,0,4)d[i][j][k]=inf;
  priority_queue<State> pq;
  FOR(i,0,h){
    FOR(j,0,w){
      if(grid[i][j]=='S'){ sy=i;sx=j; }
      if(grid[i][j]=='G'){ gy=i;gx=j; }
    }
  }
  d[sy][sx][0]=0;
  pq.push(State(sy,sx,0,0));

  while(pq.size()){
    State u = pq.top();
    pq.pop();

    if(u.y==gy && u.x==gx)return "Yes";
    if(d[u.y][u.x][u.d]<u.c)continue;

    int ny=u.y+dy[u.d],nx=u.x+dx[u.d],nd=u.d;
    if(in(ny,nx) && grid[ny][nx]!='#'){
      if(u.c<d[ny][nx][nd]){
        d[ny][nx][nd]=u.c;
        pq.push(State(ny,nx,nd,u.c));
      }
    }
    if(n<u.c)continue;
    FOR(i,0,4){
      if(mem[u.c][i]==-1)continue;
      int cost=mem[u.c][i];
      if(cost<d[u.y][u.x][i]){
        d[u.y][u.x][i]=cost;
        pq.push(State(u.y,u.x,i,cost));
      }
    }
  }
  return "No";
}

int main()
{
  while(cin>>h>>w>>n && h){
    cin>>s;
    FOR(i,0,h)cin>>grid[i];
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 24492
// Lets go to the next level 
// AIM CM at CF *__* asap 
// Hit A,B,C and D faster and reach Candidate Master
// Remember you were also a novice when you started, 
// hence never be rude to anyone who wants to learn something
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure.  


#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
// Big two primes 
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long 
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e6+5); 


signed main(){
  fio;
    string s;
    cin>>s;

    int start = 0,e = s.length()-1;
    int hugs = 0;
    while(start <= e){
        if(s[start] != s[e]){
            hugs++;
        }
        start++;
        e--;
    }

    cout<<hugs<<endl;

  rr;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if((a - b - c)>= 0) System.out.println(0);
        else System.out.println(c - (a - b));


            
    }
}

Measured memory_bytes: 23764
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int n, k;
int main()
{
	scanf("%d", &k);
	if (k == 1)
	{
		printf("1\n1\n");
		return 0;
	}
	n = (k + 3) / 4 * 2;
	printf("%d\n", n);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; ++j)
		{
			int t = (i + j) % n + 1 + (i & 1) * n;
			if (t > k)t -= n;
			printf("%d%c", t, j == n - 1 ? 10 : 32);
		}
	}
}

Measured memory_bytes: 1152
#include<cstdio>
#include<cstring>
#include<algorithm>

const int N = 1e5 + 9;

int n, cnt1, cnt2, cnt3;

int main () {
	scanf ("%d", &n);
	for (int i = 1, a; i <= n; ++i) {
		scanf ("%d", &a);
		if (!(a & 3)) ++cnt1;
		else if (!(a & 1)) ++cnt2;
		else ++cnt3;
	}
	bool o;
	if (cnt2) {
		o = cnt1 >= cnt3;
	} else {
		o = cnt1 + 1 >= cnt3;
	}
	puts (o ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 128
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int N;
    cin >> N;
    vector<int> B(N-1, 0);
    for (int i = 0; i < N-1; i++)
        cin >> B[i];

    int ans = B[0] + B[N-2];
    for (int i = 1; i < N-1; i++) {
        int m = min(B[i], B[i-1]);
        ans += m;
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 300003
#define MOD 1000000007
#define INF 1000000000000000

int main(){
  int X;
  cin>>X;
  vector<bool> buy(X+1,false);
  buy.at(0)=true;

  for(int i=0;i<6;i++){
    for(int j=0;j+100+i<=X;j++){
      buy.at(j+100+i)=buy.at(j)|buy.at(j+100+i);
    }
  }

  if(buy.at(X)){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String x = sc.next();
        String y = sc.next();

        HashMap<String, Integer> hex = new HashMap<String, Integer>();
        hex.put("A", 10);
        hex.put("B", 11);
        hex.put("C", 12);
        hex.put("D", 13);
        hex.put("E", 14);
        hex.put("F", 15);

        if (hex.get(x) > hex.get(y)) {
            System.out.println(">");
        } else if (hex.get(x) == hex.get(y)) {
            System.out.println("=");
        } else {
            System.out.println("<");
        }
    }
}


Measured memory_bytes: 23764
import fractions
def GCD(a):
    gcd = a[0]
    N = len(a)
    for i in range(1, N):
        gcd = fractions.gcd(gcd, a[i])
    return gcd

N, X = map(int, input().split())
x = list(map(int, input().split()))

if len(x) == 1:
    print(abs(x[0] - X))
    exit()

x.append(X)
x.sort()

ans = float("inf")
d = []
for i in range(N):
    d.append(x[i+1] - x[i])

ans = GCD(d)
print(ans)

Measured memory_bytes: 16276
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

using namespace std;

const int MAX = 210000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void combination_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long combination(int n, int k) {
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//重複組合せ
long long rep_comb(int n, int r) { return combination(n + r - 1, r); }

vector<pair<long long, long long> > prime_factorize(long long n) {
  vector<pair<long long, long long> > res;
  for(long long p = 2; p * p <= n; ++p) {
    if(n % p != 0) continue;
    int num = 0;
    while(n % p == 0) {
      ++num;
      n /= p;
    }
    res.push_back(make_pair(p, num));
  }
  if(n != 1) res.push_back(make_pair(n, 1));
  return res;
}

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

  auto vec = prime_factorize(M);
  combination_init();

  ll ans = 1;
  for(auto p : vec) {
    ans = ans * rep_comb(N, p.second) % MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 5120
#include <stdio.h>
#define rep(i,l,n) for(i=l;i<n;i++)

int main(void){
	int i,a[3]={0},h;

	rep(i,0,10){
		scanf("%d",&h);
		if(h>a[0]){
			a[2]=a[1]; a[1]=a[0]; a[0]=h;
		}else if(h>a[1]){
			a[2]=a[1]; a[1]=h;
		}else if(h>a[2]){
			a[2]=h;
		}
	}
	rep(i,0,3){
		printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        int a,b,d,r;
        double f;
    	//?¨??????\??????????????????????????§????????????
		Scanner scanner = new Scanner(System.in);

		a = scanner.nextInt();
    	b = scanner.nextInt();

    	d = a/b;
    	r = a%b;
    	//?????°????¨?????????????int???????????£??????
    	f = (double)a/b;

    	System.out.printf("%d %d %5f",d,r,f);
    	scanner.close();
    }
}

Measured memory_bytes: 26344
// package app;

import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        // final String x = sc.next();
        // final String y = sc.next();

        final String A = sc.next();
        final String B = sc.next();
        final String C = sc.next();
        // final int N = sc.nextInt();
        // final int D = sc.nextInt();
        // System.out.println();

        System.out.println(A.charAt(A.length() - 1) == B.charAt(0) && B.charAt(B.length() - 1) == C.charAt(0) ? "YES" : "NO");

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

Measured memory_bytes: 21844
S=input()
Q=int(input())

# deq=deque()
# for s in S:
#     deq.append(s)

rev=False
front=""
last=""
# ans+=S

for _ in range(Q):
    query=input().split()
    if query[0]=="1":
        rev = not rev
        # print(rev)
    else:
        if rev:
            query[1]=str(3-int(query[1]))
        if query[1]=="1":
            # deq.appendleft(query[2])
            front="".join([query[2],front])
        else:
            # deq.append(query[2])
            last="".join([last,query[2]])

# if rev:
#     deq.reverse()
# # ans=""
# for i in range(len(deq)):
#     ans+=deq[i]

if not rev:
    print(front+S+last)
else:
    print(last[::-1]+S[::-1]+front[::-1])

Measured memory_bytes: 4552
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n, k = load_list()
d = defaultdict(int)
for i in range(k):
    load()
    A = load_list()
    for a in A:
        d[a] += 1

cnt = 0
for i in range(1, n+1):
    if d[i] == 0:
        cnt += 1
print(cnt)


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

int main() {
    string s;
    int length;
    int ans = INT_MAX;
    
    cin >> s;
    length = s.length();
    
    for (int i = 0; i <= (length - 3); i++) {
        ans = min(ans, abs(753 - ((s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + s[i + 2] - '0')));
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
read = lambda: sys.stdin.readline().rstrip()
 
def main():
    INF = 10 ** 20
 
    n,k = map(int,input().split())
    h = tuple(map(int,read().split()))
    dp = [INF]*(n+1)
    dp[0] = 0
 
    for i in range(1, n):
        for j in range(1, k + 1):
            if i-j >= 0: dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]))
 
    print(dp[n-1])
if __name__ == "__main__":
    main()

Measured memory_bytes: 56672
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys


def get_ints():
    return map(int, sys.stdin.readline().strip().split())


def main():
    n, m = list(get_ints())

    ab = [(0, 0)] * m
    i_to_x = {}
    for i in range(m):
        a, b = map(int, input().split())
        ab[i] = (a-1, b-1)
        i_to_x[i] = a-1

    uf = UnionFind(n)

    for i in range(m):
        uf.union(ab[i][0], ab[i][1])

    print(uf.group_count() - 1)


class UnionFind:
    """Union-Find
    Note:
        https://note.nkmk.me/python-union-find/
    """
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
  
  int a, b, c;
  cin >> a >> b >> c;
  if ((a == 5 || a == 7) && (b== 5 || b == 7) && (c == 5 || c == 7) && a+b+c == 17) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}


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

int main(){
    string s;cin >> s;
    ll k; cin >> k;
    vector<ll> vec;
    ll n = s.size();
    ll tmp = 1;
    rep(i,n-1){
        if(s[i+1] == s[i])tmp++;
        else{
            vec.emplace_back(tmp);
            tmp = 1;
        }
    }
    vec.emplace_back(tmp);
    ll ret = 0;
    if(vec.size() == 1){
        if(n % 2 == 1 && k%2 == 1){
            ret = n/2 + (n*2)/2 * (k/2);
        }
        else{
            ret = ((n*2) * k) / 4;
        }
    }
    else{
        if(s[0] != s[n-1]){
            for(auto itr = vec.begin(); itr != vec.end(); itr++){
                ret += *itr /2;
            }
            ret *= k;
        }
        else{
            ll st = 0, ed = 0;
            ll cnt = 0;
            while(s[cnt] == s[0]){
                st++;cnt++;
            }
            cnt = n-1;
            while(s[cnt] == s[n-1]){
                ed++;cnt--;
            }
            
            for(int i = 1; i < vec.size()-1; i++){
                ret += vec[i]/2;
            }
            
            ret *= k;
            ret += (k-1) * ((st+ed) / 2);
            ret += st / 2 + ed / 2;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
// atcoder 
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end());

    int mem = (N-1)/2;
    int n, last;
    if (N%2 == 1) n = N;
    if (N%2 == 0) n = N-1;
    vector<int> ans(n);
    ans[mem] = A[0];
    for(int i=0; i<mem; i++){
        if (i%2 == 0){
            ans[mem+(i+1)] = A[N-1-i];
            ans[mem-(i+1)] = A[N-2-i];
            if(i==mem-1) last = N-3-i;
        }
        else{
            ans[mem+(i+1)] = A[i];
            ans[mem-(i+1)] = A[i+1];
            if(i==mem-1) last = i+2;
        }
    }
    long long answer1 = 0;
    for (int i=0; i<n-1; i++) answer1 += max(ans[i]-ans[i+1], ans[i+1]-ans[i]);
    if (N%2==0) answer1 += max(max(ans[0]-A[last], A[last]-ans[0]), max(ans[n-1]-A[last], A[last]-ans[n-1]));

    ans[mem] = A[N-1];
    for(int i=0; i<mem; i++){
        if (i%2 == 1){
            ans[mem+(i+1)] = A[N-i-1];
            ans[mem-(i+1)] = A[N-i-2];
            if(i==mem-1) last = N-i-3;
        }
        else{
            ans[mem+(i+1)] = A[i];
            ans[mem-(i+1)] = A[i+1];
            if(i==mem-1) last = i+2;
        }
    }
    long long answer2 = 0;
    for (int i=0; i<n-1; i++) answer2 += max(ans[i]-ans[i+1], ans[i+1]-ans[i]);
    if (N%2==0) answer2 += max(max(ans[0]-A[last], A[last]-ans[0]), max(ans[n-1]-A[last], A[last]-ans[n-1]));
    cout << max(answer1, answer2) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

int main() {
	ll N, D, X, Y, cnt = 0;
	cin >> N >> D;
	for (int i = 0;i < N;i++) {
		cin >> X >> Y;
		if (X * X + Y * Y <= D * D)cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>

using namespace std;

int main()
{
    int t, h, m, s;
    cin >> t;
    s = t % 60;
    t -= s;
    h = t / 3600;
    t -= h * 3600;
    m = t / 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3112
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())

    tf = [[] for _ in range(n)]
    for i in range(n):
        a = int(input())
        for j in range(a):
            x, y = map(int, input().split())
            tf[i].append((x-1, y))

    ans = 0
    for i in range(1 << n):
        tmp = format(i, 'b').count('1')
        for j in range(n):
            if (i>>j)&1:
                for x, y in tf[j]:
                    if (i>>x)&1 != y:
                        break
                else:
                    continue
                break
        else:
            ans = max(ans, tmp)
    print(ans)


            



if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll MOD = 1000000007;
const double PI = 3.141592653589793238463;
const ll N=2e5+9;
int main()
{
    FASTINOUT;
    map<int,int>m;
    int x,y,c=0,l=0;
    cin>>x;
    for (int i=0;i<x;i++){
        cin>>y;
        if (!m[y]){
            c++;
            m[y]=1;
        }
        else{
            l++;
        }
    }
    cout<<(l%2==0?c:c-1);
    return 0;
}


Measured memory_bytes: 4992