akhauriyash/Code-Regression huggingface dataset:
N,K,Q=map(int,input().split())

A = [0] * Q
for i in range(Q):
    A[i]=int(input())

#print(A)
    
P = [K-Q] * N

for j in A:
    P[j-1]+=1

#print(P)

for k in P:
    if k >0:
        print("Yes")
    else:
        print("No")
    


Measured memory_bytes: 50944
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll,ll> 
#define mll map<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0; i<n; i++)
#define All(x,v) for(auto x:v)
#define arrin(a,n) ll a[n]; rep(i,n) cin>>a[i]
#define vi vector<int>
#define nl "\n"
#define print(arr) All(x,arr) cout<<x<<" "; cout<<nl
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ing(m,ad) rep(i,m){ int u,v; cin>>u>>v; u--;v--; ad[u].pb(v); ad[v].pb(u);}
#define vdsort(v) sort(v.begin(),v.end(),greater<int>())
#define F first
#define S second
#define mod 1000000007
const int MAXN=100001;
int spf[MAXN];
int gcd(int x, int y){ return y?gcd(y,x%y):x; }

void precal(){  
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)  spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) spf[i] = 2; 
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j)  spf[j] = i; 
    } 
} 
vector<int> getFactorization(int x){
    vector<int> ret; 
    while (x != 1) { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}

ll exp(ll n, ll m){
    ll a = 1;
    while (m){
        if (m & 1) a = (a * n % mod) % mod;
        m /= 2;
        n = (n*n) % mod;
    }
    return a;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,t=1;
    // cin>>t;
    while(t--){
        cin>>n;
        cout<<8-(n-400)/200<<nl;
    }
    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int n = s.length();
    bool flag = false;
    for (int i = 0; i < n;i++){
        if(s==t)
            flag = true;
        s = s.back() + s.substr(0, n - 1);
    }
    if (flag)
        cout << "Yes" << endl;
        else
            cout << "No" << endl;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main ()
{
    int N; cin >> N;
    vector < int > a(N);
    map < int, int > cnt;

    for (int i = 0; i < N; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    if (cnt.size() == 1 && cnt.begin()->first == 0) {
        cout << "Yes" << endl;
        return 0;
    }

    if (cnt.size() > 3) {
        cout << "No" << endl;
        return 0;
    }

    vector < pair < int,int > > cnd;
    for (auto &x : cnt) {
        cnd.push_back(make_pair(x.first, x.second));
    }

    if (cnd.size() == 2) {
        if (cnd[0].second * 2 == cnd[1].second) {
            if ((cnd[1].first ^ cnd[1].first) != cnd[0].first) {
                cout << "No" << endl;
                return 0;
            }
            if ((cnd[1].first ^ cnd[0].first) != cnd[1].first) {
                cout << "No" << endl;
                return 0;
            }
        } else if (cnd[0].second == cnd[1].second * 2) {
            if ((cnd[0].first ^ cnd[0].first) != cnd[1].first) {
                cout << "No" << endl;
                return 0;
            }
            if ((cnd[1].first ^ cnd[0].first) != cnd[0].first) {
                cout << "No" << endl;
                return 0;
            }
        } else {
            cout << "No" << endl;
            return 0;
        }
    } else {
        if (!(cnd[0].second == cnd[1].second && cnd[1].second == cnd[2].second)) {
            cout << "No" << endl;
            return 0;
        }
        vector < int > ord = {cnd[0].first, cnd[1].first, cnd[2].first};
        sort(ord.begin(), ord.end());
        bool flag = false;
        do {
            if ((ord[0] ^ ord[2]) == ord[1] && (ord[1] ^ ord[0]) == ord[2]) {
                flag = true;
            }
        } while (next_permutation(ord.begin(), ord.end()));
        if (!flag) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 4224
def bubble_sort
  flag = true
  while flag do
    flag = false
    (@N-1).downto 1 do |j|
      if @A[j] < @A[j-1]
        @A[j], @A[j-1] = @A[j-1], @A[j]
        flag = true
        @count += 1
      end
    end
  end
end


@count = 0
@N = gets.to_i
@A = gets.split(" ").map{|x| x.to_i}

bubble_sort

@A.each_with_index do |x, i|
  print x
  print i == @N-1 ? "\n" : " "
end
puts @count



Measured memory_bytes: 8868
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    ll n,ans=0;cin >> n;
    for(int i=0;i<=n;i++){
        if(i%3!=0 and i%5!=0)ans+=i;
    }
    cout << ans << endl;
}


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

#define pb push_back
#define F first
#define S second
#define mp make_pair
#define vsort(x) sort(x.begin(), x.end())
#define out(x) cout << x << "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR(a, b, c) for(int a = b; a < c; a++)
typedef long long int ll;

int main(){
    IOS;
    ll n,i,k,j;
    cin>>n>>k;
    vector<ll>a(n+1),dp(n+1);
    for(i=1;i<=n;i++){
        cin>>a[i];
    }
    dp[1] = 0;
    for(i=2;i<=n;i++){
        dp[i] = INT_MAX;
        for(j=1;j<=k && (i-j)>=1;j++)
        dp[i] = min((dp[i-j] + abs(a[i]-a[i-j])),dp[i]);
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int uchiha=1e3+5;
char arr[uchiha][uchiha];
char arr1[uchiha][uchiha];
int main()
{
int n,m,c1=0;
cin>>n>>m;
for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
    cin>>arr[i][j];
for(int i=0;i<m;i++)
    for(int j=0;j<m;j++)
    cin>>arr1[i][j];
for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
    c1=0;
for(int k=0;k<m;k++){
    for(int l=0;l<m;l++){
    if(arr1[k][l]==arr[i+k][j+l]){
    c1++;
}
    }
    }
    if(c1==m*m){
        cout<<"Yes";
    return 0;}

}}
 cout<<"No";
}

Measured memory_bytes: 384
#include<stdio.h>
/*
int main(){
	int n,k[100]={0};
	int a,b,c;
	int i;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==b*b+a*a){k[i]=1;}
	}
	for(i=0;i<n;i++){
		if(k[i]==1){printf("YES\n");}
		else{printf("NO\n");}
	}
	return 0;
}
*/

int main()
{
	int i;
	int n;
	int a, b, c;
	scanf("%d",&n);
	
	for(i = 0; i <n; i++){
		scanf("%d%d%d",&a,&b,&c);
		if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==b*b+a*a){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	
	return 0;
}

		 

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)
#define mp(a, b) make_pair((a),(b))
#define bs(n) ((ull)1<<((ull)n))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr double pi = asin(1) * 2;
constexpr ll mod = 1000000007;
constexpr double eps = 0.000000001;

ll h, w, k;

vector<string> s;


int main() {
    cin >> h >> w >> k;
    s.resize(h);
    for (auto &e:s)cin >> e;
    ll r = INT32_MAX / 2;
    vector<ll> u;
    for (ull i = 0; i < bs(h - 1); i++) {
        ll v = 0;
        u.clear();
        u.push_back(0);
        for (ll j = 0; j < h - 1; j++) {
            if (i & bs(j))u.push_back(j+1);
        }
        u.push_back(h);

        ll c[10] = {0};
        for (ll j = 0; j < w; j++) {
            ll d[10] = {0};
            for (ll t = 0; t < u.size() - 1; t++) {
                for (ll f = u[t]; f < u[t + 1]; f++) {
                    if (s[f][j] == '1')d[t]++;
                }
            }

            bool f = false;
            for (ll t = 0; t < u.size() - 1; t++) {
                if (d[t] > k)v = INT32_MAX / 2;
                if (c[t] + d[t] > k)f = true;
            }
            if (f) {
                for (ll t = 0; t < u.size() - 1; t++) {
                    c[t] = d[t];
                }
                v++;
            } else {
                for (ll t = 0; t < u.size() - 1; t++) {
                    c[t] += d[t];
                }
            }
        }

        v += u.size() - 2;
        r = min(r, v);
    }
    cout << r << endl;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if ((m | n) == 0)
				break;
			Edge[] es = new Edge[m];
			UnionFind uf = new UnionFind(n);
			for (int i = 0; i < m; i++) {
				int s = sc.nextInt();
				int e = sc.nextInt();
				int d = sc.nextInt();
				es[i] = new Edge(s, e, d);
			}
			Arrays.sort(es, new Comparator<Edge>() {
				public int compare(Edge a, Edge b) {
					return a.d - b.d;
				}
			});
			int sum = 0;
			for (int i = 0; i < m; i++) {
				int a = es[i].s;
				int b = es[i].e;
				int d = es[i].d;
				if (!uf.same(a, b)) {
					uf.unite(a, b);
					sum += d;
				}
			}
			System.out.println(sum);
		}
	}
}

class Edge {
	public int s;
	public int e;
	public int d;

	Edge(int s, int e, int d) {
		this.s = s;
		this.e = e;
		this.d = d;
	}
}

class UnionFind {
	public int par[];
	public int rank[];

	UnionFind(int n) {
		par = new int[n];
		rank = new int[n];
		for (int i = 0; i < n; i++) {
			par[i] = i;
		}
	}

	public int find(int x) {
		if (par[x] == x)
			return x;
		else
			return par[x] = find(par[x]);
	}

	public void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)
			return;

		if (rank[x] < rank[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if (rank[x] == rank[y])
				rank[x]++;
		}
	}

	public boolean same(int x, int y) {
		return find(x) == find(y);
	}
}

Measured memory_bytes: 12000
// new day,new strength,new thougts
#include<bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define F first
#define S second
#define sz(c) int((c).size())
#define REP(i,n)  for(int i=0;i<int(n);i++)
#define REPD(i,n) for(int i=int(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=int(a);i<=int(b);i++)
#define FORD(i,a,b) for(int i=int(a);i>=int(b);i--)
#define all(s) (s).begin(),(s).end()
#define bit(num,i) ((num>>i)&1)

using namespace std;
typedef pair<int,int> pii;

const int maxn=4e5+10;

#pragma GCC Optimize("Ofast")
#pragma GCC Optimize("O1")
#pragma GCC Optimize("O2")
#pragma GCC Optimize("O3")
#pragma GCC Optimize("O4")
#pragma GCC Optimize("O5")

int n,a[maxn];
pii p[maxn];

void Merge(pii &c,int i){
    if(c.F==i || c.S==i || i==-1)return;
    if(c.F==-1){
	c.F=i;
	return;
    }
    if(c.S==-1){
	c.S=i;
	return;
    }
    if(a[c.F]<a[c.S])swap(c.F,c.S);
    if(a[c.F]<a[i]){
	c.S=c.F;
	c.F=i;
	return;
    }
    if(a[c.S]<a[i]){
	c.S=i;
	return;
    }
}

void handle(int ind){
    Merge(p[ind],ind);
    REP(i,n){
	if(!bit(ind,i)){
	    Merge(p[ind|(1<<i)],p[ind].F);
	    Merge(p[ind|(1<<i)],p[ind].S);
	}
    }
}

int main(){
    pii neg=MP(-1,-1);
    fill(p,p+maxn,neg);
    scanf("%d",&n);
    REP(i,(1<<n)){
	scanf("%d",&a[i]);
	handle(i);
    }
    int ans=0;
    FOR(i,1,(1<<n)-1){
	ans=max(ans,a[p[i].F]+a[p[i].S]);
	printf("%d\n",ans);
    }
}


Measured memory_bytes: 7168
import Data.List (group)

main :: IO ()
main = do
  _ <- read <$> getLine :: IO Int
  s1 <- group <$> getLine :: IO [String]
  s2 <- group <$> getLine :: IO [String]
  let s = zipWith (\x y-> if x==y then 1 else 2) s1 s2
  let f x (l, a) | l == 0 && x == 1 = (x, a*3`mod`1000000007)
                 | l == 0 && x == 2 = (x, a*6`mod`1000000007)
                 | l == 1 && x == 1 = (x, a*2`mod`1000000007)
                 | l == 1 && x == 2 = (x, a*2`mod`1000000007)
                 | l == 2 && x == 1 = (x, a)
                 | l == 2 && x == 2 = (x, a*3`mod`1000000007)
                 | otherwise = undefined
  print $ snd $ foldr f (0, 1) (reverse s)


Measured memory_bytes: 508
N = int(input())
L = list(map(int,input().split()))

L.sort()
from bisect import bisect_left
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        x = L[i]+L[j]
        idx = bisect_left(L,x)
        ans += idx - j - 1
print(ans)

Measured memory_bytes: 44460
#include<set>  
#include<map>  
#include<stack>  
#include<cmath>  
#include<cstdio>  
#include<queue>  
#include<vector>  
#include<climits>  
#include<cstring> 
#include<iostream> 
#include<algorithm> 
using namespace std; 
#define LL long long
#define MAXN 100000
const long long H=1000000000000000ll,INF=1000000000000000ll;
LL read(){ 
    LL f=1,x=0; 
    char c=getchar(); 
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} 
    return f*x;
}
struct edge{
	int v;LL w;
	edge(){}
	edge(int V,LL W){v=V,w=W;}
};
int n,m,s,t;
LL disy[MAXN+5],disd[MAXN+5];
bool vis[MAXN+5];
queue<int>Q;
vector<edge> G[2][MAXN+5];
void SPFA(int C,int S){
	memset(vis,0,sizeof(vis));
	if(!C) memset(disy,0x3f3f3f,sizeof(disy)),disy[S]=0;
	else memset(disd,0x3f3f3f,sizeof(disd)),disd[S]=0;
	vis[S]=1,Q.push(S);
	while(!Q.empty()){
		int u=Q.front();
		Q.pop(),vis[u]=0;
		int siz=G[C][u].size();
		for(int i=0;i<siz;i++){
			int v=G[C][u][i].v;
			LL w=G[C][u][i].w;
			if(!C&&disy[v]>disy[u]+w){
				disy[v]=disy[u]+w;
				if(!vis[v])
					vis[v]=1,Q.push(v);
			}
			else if(C&&disd[v]>disd[u]+w){
				disd[v]=disd[u]+w;
				if(!vis[v])
					vis[v]=1,Q.push(v);
			}
		}
	}
	return ;
}
LL ans[MAXN+5];
int main(){
	n=read(),m=read(),s=read(),t=read();
	for(int i=1;i<=m;i++){
		int u=read(),v=read(),w1=read(),w2=read();
		G[0][u].push_back(edge(v,w1));
		G[0][v].push_back(edge(u,w1));
		G[1][u].push_back(edge(v,w2));
		G[1][v].push_back(edge(u,w2));
	}
	SPFA(0,s);
	SPFA(1,t);
	ans[n+1]=INF;
	for(int i=n;i>=1;i--)
		ans[i]=min(ans[i+1],disy[i]+disd[i]);
	for(int i=1;i<=n;i++)
		printf("%lld\n",H-ans[i]);
    return 0;
}


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

int A[500001];
int H;

void maxHeapify(int i){
    int l = i*2;
    int r = i*2+1;
    int largest;
    
    if(l <= H && A[l] > A[i])   largest = l;
    else                        largest = i;
    if(r <= H && A[r] > A[largest]) largest = r;
    
    if(largest != i){
        swap(A[largest], A[i]);
        maxHeapify(largest);
    }
}

int main(){
    cin >> H;
    for(int i = 1; i <= H; i++) cin >> A[i];
    
    for(int i = H/2; i >= 1; i--){
        maxHeapify(i);
    }
    
    for(int i = 1; i <= H; i++){
        cout << " " << A[i];
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 5044
from collections import deque

def resolve():
    S = deque(input())
    Q = int(input())
    query = [ input().split() for _ in range(Q)]

    sw = True
    for q in query:
        if q[0] == "2":
            if q[1] == "1":
                if sw:
                    S.appendleft(q[2])
                else:
                    S.append(q[2])
            else:
                if sw:
                    S.append(q[2])
                else:
                    S.appendleft(q[2])
        else:
            sw = not sw
    
    if not sw:
        S.reverse()
    print("".join(S))

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 44532
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N, K, y, ans{1 << 30};
  cin >> N >> K;
  if (!--K) {
    while (cin >> y) ans = min(ans, abs(y));
  } else {
    vector<int> x(K, 1 << 30);
    for (; N; --N) {
      cin >> y;
      auto a = x[N % K];
      if (a < 0 && y > 0)
        ans = min(ans, y - a + min(-a, y));
      else
        ans = min(ans, max(abs(a), abs(y)));
      x[N % K] = y;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <map>
using namespace std;

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

    vector<long long> a(N);

    long long cntK = 0;
    long long cnt2 = 0;
    long long cnt4 = 0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        if(a[i] % 2 != 0){
            cntK++;
        }else if((a[i]%2)==0 && (a[i]%4) != 0){
            cnt2++;
        }else if((a[i]%2) == 0 && a[i]%4 == 0){
            cnt4++;
        }
    }
    long long am = cntK;
    if(cnt2 >= 1){
        am = cntK + 1;
    }

    if(am > cnt4 + 1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
#define V 10
#define INF (1<<30)-1
struct edge{int from,to,cost;};
int main(){
  int d[V];
  int n;
  while(cin>>n){
    if(n==0) break;
    edge es[2*n];
    int a,b,c;
    int ans = INF,ansi;
    for(int i=0;i<2*n;i+=2){
      cin >> a >> b >> c;
      es[i].from = es[i+1].to = a;
      es[i+1].from = es[i].to = b;
      es[i].cost = es[i+1].cost = c;
    }
    for(int j=0;j<V;j++){
      for(int i=0;i<V;i++) d[i] = INF; 
      d[j] = 0;
      while(true){
	bool updata = false;
	for(int i=0;i<2*n;i++){
	  edge e = es[i];
	  if(d[e.from]!=INF&&d[e.to]>d[e.from]+e.cost){
	    d[e.to] = d[e.from] + e.cost;
	    updata = true;
	  }
	}
	if(!updata) break;
      }    
      int s = 0;
      for(int i=0;i<V;i++){
	if(d[i]!=INF){
	  s += d[i];
	}
      }
      if(s<ans&&s!=0){ans = s,ansi =j;};
    }
    cout << ansi << ' ' << ans << endl;
  }
  return 0;
}
 

Measured memory_bytes: 1156
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int a2 = a, b2 = b, c2 = c;


	int i = 0;
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		int a1 = b / 2 + c / 2, b1 = a / 2 + c / 2, c1 = a / 2 + b / 2;
		a = a1;
		b = b1;
		c = c1;
		if ((a == a2&&b == b2&&c == c2) || (a == b&&b == c)) {
			i = -1;
			break;
		}
		i++;
	}
	cout << i << endl;



	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt(), k = sc.nextInt();
        UnionFind uf = new UnionFind(n);
        for (int i = 1; i <= k; i++) {
            //uf.debug();

            int num = sc.nextInt();
            if (num == 1) {
                int a = sc.nextInt() - 1;
                int b = sc.nextInt() - 1;
                int ba = uf.get_bukatu(a);
                int bb = uf.get_bukatu(b);
                if(ba == -1) {
                    uf.unite(a, b);
                    uf.setBukatu(a, bb);
                } else if(bb == -1) {
                    uf.unite(a, b);
                    uf.setBukatu(b, ba);
                } else {
                    if(ba == bb) {
                        uf.unite(a, b);
                    } else {
                        System.out.println(i);
                        return;
                    }
                }
            } else {
                int c = sc.nextInt() - 1;
                int x = sc.nextInt() - 1;
                int b = uf.get_bukatu(c);
                if(b == -1) {
                    uf.setBukatu(c, x);
                } else {
                    if(b != x) {
                        System.out.println(i);
                        return;
                    }
                }
            }
        }
        System.out.println(0);
    }
}

class UnionFind {
    int[] data;
    int[] bukatu;

    public UnionFind(int size) {
        data = new int[size];
        Arrays.fill(data, -1);
        bukatu = new int[size];
        Arrays.fill(bukatu,-1);
    }

    public boolean unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(data[x] > data[y]) {
            int temp = x;
            x = y;
            y = temp;
        }
        data[x] += data[y];
        data[y] = x;
        return true;
    }

    public int find(int k) {
        if(data[k] < 0) return k;
        return (data[k] = find(data[k]));
    }

    public int size(int k) {
        return -data[find(k)];
    }

    public void setBukatu(int c, int number) {
        bukatu[find(c)] = number;
    }

    public int get_bukatu(int x) {
        return bukatu[find(x)];
    }

    public void debug() {
        System.err.println(Arrays.toString(data));
        System.err.println(Arrays.toString(bukatu));
    }
}


Measured memory_bytes: 165704
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using ll = long long; 
using namespace std;
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; }

int main() {
	int n;
	ll k;
	cin >> n >> k;
	vector<int>a(n);
	rep(i,n) {
		cin >> a[i];
	}
	vector<int>s;
	vector<int>ord(n+1,-1);
	int c = 1;
	int l = 0;
	{
		int v = 1;
		while(ord[v] == -1) {
			ord[v] = s.size();
			s.push_back(v);
			v = a[v-1];
		}
		c = s.size() - ord[v];
		l = ord[v];
	}
	
	if(k < l) cout << s[k] << endl; 
	else {
		k -= l;
		k %= c;
		cout << s[l+k] << endl;
	}
}

Measured memory_bytes: 5888
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        final String S = sc.next();
        String[] ts = {"eraser", "erase", "dreamer", "dream"};
        System.out.println(judgeSEqualT(S, ts));
        sc.close();
    }

    public static String judgeSEqualT(String target, String[] strs) {
        for (String str : strs) {
            target = target.replace(str, "");
            if (target.length() == 0) {
                return "YES";
            } else {
                continue;
            }
        }
        return "NO";
    }
}

Measured memory_bytes: 30704
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
  ll n, m;
  while(cin>>n>>m){
    ll ans;
    if(n==1&&m==1)
      ans=1;
    else if(n==1){
      ans=max(0ll, m-2);
    }
    else if(m==1){
      ans=max(0ll, n-2);
    }
    else{
      ans=(n-2)*(m-2);
    }
    cout<<ans<<endl;
  }
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e9+7;
const int mod= 1e9 + 7;

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

	ll a,ans=0,b=10;
	cin >> a;

	while (a/b > 0) {
		ans += a / b;
		b *= 5;
	}

	if(a%2==0)cout << ans << endl;
	else cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B,C,D;
  cin>>A>>B>>C>>D;
  
  if( (A+B)>(C+D) ){
    cout<<"Left"<<endl;
  }
  else if( (A+B)==(C+D) ){
    cout<<"Balanced"<<endl;
  }
  else if( (A+B)<(C+D) ){
    cout<<"Right"<<endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    if(k % 2){
        ans = n / k;
        ans = ans * ans * ans;
    }else{
        int c1 = n / (k / 2);
        int c2 = n / k;
        c1 -= c2;
        ans = c1 * c1 * c1 + c2 * c2 * c2;
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
	char s[4];
	bool a[3] = { 0 };
	int cnt=0;
	cin >> s;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'a'&&a[0] == 0) {
			cnt++;
			a[0] = 1;
		}
		if (s[i] == 'b'&&a[1] == 0) {
			cnt++;
			a[1] = 1;
		}
			if (s[i] == 'c'&&a[2] == 0) {
				cnt++;
				a[2] = 1;
			}
	}

	if (cnt == 3) 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;
using ll = long long;

int main() {
    int d, n;
    cin >> d >> n;
    int div = pow(100, d);
    if(n >= 100) n += n/100;
    int ans = n * div;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//const double pi=acos(-1.0);
#define mod 1000000007
#define forn(i,k,n) for(ll i=k;i<n;i++)
#define fornr(i,k,k1) for(ll i=k;i>=k1;i--)
#define v(ll) vector<ll>
#define vl(a,n,ll,k) vector<ll> a(n,k)
#define vli(a,n) vector<ll> a(n)
#define init(a,n) vector<ll> a(n);forn(i,0,n)cin>>a[i]
#define vll(a,n,m,ll,k) vector<vector<ll>> a(n,vector<ll>(m,k))
#define mp(a,ll,ll1) map<ll,ll1> a
#define st(a,ll) set<ll> a
#define mpa make_pair
#define pr pair<ll,ll>
#define pb push_back
#define MAX 1000000
#define ed '\n'
#define fileTake ifstream cin("input.txt");ofstream cout("output.txt");
#define sortv(a) sort(a.begin(),a.end())
#define sorta(a,n) sort(a,a+n)
#define yeah "Yes"
#define nil "No"
#define All(x) x.begin(),x.end()
#define remDup(a) a.erase(unique(All(a)),a.end())
#define N 100
 
void swap(ll &x,ll &y) 
{ 
	x=x^y;
	y=x^y;
	x=x^y;
} 

template<typename T>
void print(T a){for(auto i=a.begin();i!=a.end();i++)cout<<*i<<" ";cout<<endl;}
bool isVowel(char c)
{
	if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')return true;
	return false;
}

void sync(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}

int main(){
	sync();
	ll n,d,x,y,ans=0;
	cin>>n>>d;
	d=d*d;
	while(n--)
	{
		cin>>x>>y;
		ll o=x*x+y*y;
		if(d>=o)
		ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<stack>
#include<stdio.h>
#include<stdlib.h>

using namespace std;
int main(){
    int n,i;
    char temp[20];
    stack<int> A;
    while(scanf("%s",&temp)!=EOF){
        int a=0,b=0;
        switch(temp[0]){
        case '+':
            a=A.top();
            A.pop();
            b=A.top();
            A.pop();
            A.push(b+a);
            break;
        case '-':
            a=A.top();
            A.pop();
            b=A.top();
            A.pop();
            A.push(b-a);
            break;
        case '*':
            a=A.top();
            A.pop();
            b=A.top();
            A.pop();
            A.push(b*a);
            break;
        case '/':
            a=A.top();
            A.pop();
            b=A.top();
            A.pop();
            A.push(b/a);
            break;
        default:
            A.push(atoi(temp));
            break;
        }
    }
    cout<<A.top()<<endl;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
using namespace std;

#define INF 1e9
#define PI 3.141592653589793238
#define N 1000000010
#define mod 1000000007
#define REP(inc, bgn, end) for(int inc=bgn; inc<end; inc++)
typedef long long ll;

int main() {
    int n;cin>>n;
    int count=0;

    for(int i=0; i<n; i++){
        if(count==3) break;
        int d1,d2;cin>>d1>>d2;
        if(d1==d2) count++;
        else count=0;
    }
    
    if(count==3) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main()
{
	char c;

	int a[26] = {0};
	for (;cin >> c;)
	{
		if ('a' <= c && c <= 'z')
		{
			a[c - 'a'] ++;
		}
		if ('A' <= c && c <= 'Z')
		{
			a[c - 'A'] ++;
		}
	}

	for (int i = 0; i < 26; i++)
	{
		cout << (char)('a' + i) << " : " << a[i] << endl;
	}
}


Measured memory_bytes: 3092
use v5.18;
use warnings;
use List::Util qw( min );
sub read_line { chomp(my $str = <STDIN>); $str }
sub splited_read_line { split / /, read_line }

my ($a_price, $b_price, $ab_price, $a_num, $b_num) = splited_read_line;

sub solve {
  if ( ($a_price + $b_price) / 2 < $ab_price ) {
    $a_price * $a_num + $b_price * $b_num;
  }
  else {
    my $sum              = $a_num + $b_num;
    my $diff_num         = abs $a_num - $b_num;
    my $ab_num           = $sum - $diff_num;
    my $over_donut_price = $a_num < $b_num ? $b_price : $a_price;
    my $price_base       = $ab_num * $ab_price;
    my $left_a_or_b      = $price_base + $over_donut_price * $diff_num;
    my $left_ab          = $price_base + $ab_price * $diff_num * 2;
    min $left_ab, $left_a_or_b;
  }
}

say solve();

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

#define ll long long

bool isprime(ll x)
{
	ll lim=sqrt(x);
	
	for(int i=2;i<=lim;i++)
	{
		if(x%i==0) return 0;
	}
	
	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	ll n;
	cin >> n;
	
	while(1)
	{
		if(isprime(n))
		{
			cout << n << endl;
			return 0;
		}
		n++;
	}
	
	return 0;
}


Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 3005;
#define endl '\n'
#define int ll
#define ld long double
#define all(x) (x).begin(),(x).end()
int basis[62];
int sz = 0;
void insert(int mask,int xrsum){
  for(int i = 61;i>=0;i--){
    if(((mask>>i)&1ll) == 0) continue;
    if(((xrsum>>i)&1) == 1) continue;
    if(!basis[i]){
      basis[i] = mask;
      sz++;
      return ;
    } 
    mask ^= basis[i];
  }
  for(int i = 61;i>=0;i--){
    if(((mask>>i)&1ll) == 0) continue;
    if(((xrsum>>i)&1) == 0) continue;
    if(!basis[i]){
      basis[i] = mask;
      sz++;
      return ;
    } 
    mask ^= basis[i];
  }
}
int32_t main()
{ 
  IOS
  
  int n;
  cin>> n;
  int a[n];
  int xrsum = 0;
  for(int i = 0;i<n;i++){
    cin>>a[i];
    xrsum^=a[i];
  }  
  for(int i =0;i<n;i++) insert(a[i],xrsum);
  int ans = 0;
  for(int i = 61;i>=0;i--){
    if(!basis[i]) continue;
    if((((xrsum>>i)&1) == 0) and (((ans>>i)&1) == 0)) {
      ans^=basis[i];
    }
  }
  for(int i = 61;i>=0;i--){
    if(!basis[i]) continue;
    if((((xrsum>>i)&1) == 1) and (((ans>>i)&1) == 0)) {
      ans^=basis[i];
    }
  }


  cout<<ans + (xrsum^ans)<<endl;


    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>
#define fr first
#define se second

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;




int main()
{
  finp;
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  

  if(k & 1)cout<<b-a;
  else cout<<a-b;

  
return 0;
}

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

using namespace std;


typedef long long ll;


int main()
{
    //freopen("", "r", stdin);freopen("", "w", stdout);
    int n, m, c;
    cin>>n>>m>>c;
    vector<int>b(m);
    for (int i=0; i<m; i++){
        cin>>b[i];
    }
    int ans=0;
    for (int i=0; i<n; i++){
        int sum=0;
        for (int j=0; j<m; j++){
            int x;
            cin>>x;
            sum+=x*b[j];
        }
        if (sum+c>0)ans++;
    }
    cout<<ans;
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
const ll INF=1e10;
ll d[201][201]; //存在しない場合はINF, d[i][i]=0
int V;

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(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int M, R;
    cin>>V>>M>>R;
    int r[R];
    vector<int> v;
    rep(i,0,R){
        cin>>r[i];
        r[i]--;
        v.push_back(r[i]);
    }
    sort(v.begin(), v.end());
    rep(i,0,201){
        rep(j,0,201){
            if(i==j) d[i][j]=0;
            else d[i][j]=INF;
        }
    }
    rep(i,0,M){
        int a, b, c;
        cin>>a>>b>>c;
        a--;
        b--;
        d[a][b]=c;
        d[b][a]=c;
    }
    warshall_floyd();
    ll ans=INF;
    do{
        ll c=0;
        rep(i,0,R-1){
            c+=d[v[i]][v[i+1]];
        }
        ans=min(ans,c);
    }while(next_permutation(v.begin(), v.end()));
    cout << ans<<"\n";
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

const int dx[2][6] = { {-1, 0, 1, 0, -1, -1}, {0, 1, 1, 1, 0, -1} };
const int dy[6] = {-1, -1, 0, 1, 1, 0};

int field[128][128], flag[128][128];

struct P{ int x, y, d; P(int x, int y, int d) : x(x), y(y), d(d) {} };

#define range(x, y) (0 <= x && x < m && 0 <= y && y < n)

int main()
{
    int m, n, s, t;
	while(cin >> m && m)
	{
		cin >> n >> s;

		memset(field, -1, sizeof field);
		
		rep(i, s)
		{
			int x, y;
			cin >> x >> y;
			
			queue<P> que;
			for(que.push(P(x - 1, y - 1, 0)); !que.empty(); que.pop())
			{
				P p = que.front();
				
				if(p.d < field[p.x][p.y] || field[p.x][p.y] == -1)
				{
					field[p.x][p.y] = p.d;
					
					rep(j, 6)
					{
						int nx = p.x + dx[p.y % 2][j], ny = p.y + dy[j];
						if(range(nx, ny)) que.push(P(nx, ny, p.d + 1));
					}
				}
			}
		}
		
		int t, res = 0;
		
		cin >> t;
		
		rep(i, t)
		{
			int x, y, sub = 0;
			cin >> x >> y;
			
			memset(flag, 0, sizeof flag);
			
			queue<P> que;
			for(que.push(P(x - 1, y - 1, 0)); !que.empty(); que.pop())
			{
				P p = que.front();
				
				if(p.d < field[p.x][p.y] && flag[p.x][p.y] == false)
				{
					flag[p.x][p.y] = true;
					
					sub++;
					
					rep(j, 6)
					{
						int nx = p.x + dx[p.y % 2][j], ny = p.y + dy[j];
						if(range(nx, ny)) que.push(P(nx, ny, p.d + 1));
					}
				}
			}
			
			chmax(res, sub);
		}
		
		cout << res << endl;
	}
}

Measured memory_bytes: 0
N = int(input())
A = [[int(a) for a in input().split()] for _ in range(N)]
for i in range(N):
    z = A[i][0] + A[i][1]
    w = A[i][0] - A[i][1]
    if i==0:
        M_z = m_z = z
        M_w = m_w = w
    if z > M_z: M_z = z
    if z < m_z: m_z = z
    if w > M_w: M_w = w
    if w < m_w: m_w = w
print(max(M_z-m_z,M_w-m_w))

Measured memory_bytes: 42152
N = int(input())
testimony = [[] for _ in range(N)]

for i in range(N):
    A = int(input())
    for j in range(A):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])

honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if (i >> j) & 1 == 1:  # j番目は正直と仮定
            for x, y in testimony[j]:
                if (i >> x) & 1 != y:  # j番目は正直だが矛盾を発見
                    flag = 1
                    break
    if flag == 0:  # 矛盾がある場合はflag == 1になる
        honest = max(honest, bin(i)[2:].count('1'))  # 1の数をカウントし最大となるものを選択
print(honest)

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

using namespace std;

int a;
int muns;

int main()
{
	cin >> a;
	for (int i = 1;i < a+1;i++)
	{
		muns += i;
	}
	cout << muns << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int A, B;

    scanf("%d %d", &A, &B);

    if ((A >= 10) || (B >= 10))
    {
        printf("%d\n", -1);
        return 0;
    }

    printf("%d\n", A * B);
    return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] values = new int[w];
        for(int i=0;i<values.length;i++){
            values[i] = i + 1;
        }
        for(int i=0;i<n;i++){
            String str = sc.next();
            String[] ab = str.split(",");
            int a = Integer.parseInt(ab[0])-1;
            int b = Integer.parseInt(ab[1])-1;
            int tmp=0;
            tmp = values[b];
            values[b] = values[a];
            values[a] = tmp;
        }
        for(int i=0;i<w;i++){
            System.out.println(values[i]);
        }
    }
}


Measured memory_bytes: 26156
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

const int maxn = 2e3 + 5;

char readch() {
    char ch = getchar();
    while (ch != '1' && ch != '0') ch = getchar();
    return ch;
}
int s[maxn][maxn], n, m;
int sn[maxn][maxn], sve[maxn][maxn], she[maxn][maxn];

inline int Sum(int s[][maxn], int x1, int y1, int x2, int y2) {
    return s[x2][y2] - s[x2][y1 - 1] - s[x1 - 1][y2] + s[x1 - 1][y1 - 1];
}

int main() {
    int T; scanf("%d%d%d", &n, &m, &T);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            char ch = readch();
            if (ch == '1') s[i][j] = 1;
            else s[i][j] = 0;
        }
    //calc sn, sve, she
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            sn[i][j] = sn[i-1][j] + sn[i][j-1] - sn[i-1][j-1] + s[i][j];
            sve[i][j] = sve[i-1][j] + sve[i][j-1] - sve[i-1][j-1] + (s[i][j] && s[i+1][j]);
            she[i][j] = she[i-1][j] + she[i][j-1] - she[i-1][j-1] + (s[i][j] && s[i][j+1]);
        }
    while (T--) {
        int x1, y1, x2, y2;
        scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
        printf("%d\n", Sum(sn, x1, y1, x2, y2) - Sum(sve, x1, y1, x2-1, y2) - Sum(she, x1, y1, x2, y2-1));
    }
    return 0;
}

Measured memory_bytes: 64640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n; cin >> n;
    vector<vector<int>> f(n,vector<int>(10,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            cin >> f[i][j];
        }
    }
    vector<vector<int>> p(n,vector<int>(11,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<11;j++){
            cin >> p[i][j];
        }
    }


    ll ans = -INF;
    for(int bit = 1;bit < (1<<10); bit++){
        vector<int> c(n,0);
        ll cur = 0;
        for(int i=0;i<n;i++){
            for(int j=0;j<10;j++){
                if(bit & (1<<j)  and  f[i][j] == 1){
                    c[i]++;
                }
            }
        }
        for(int i=0;i<n;i++) cur += p[i][c[i]];
        ans = max(ans,cur);
    }

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


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,ans,num;
  cin>>a>>b;
  ans=1;
  num=0;
  while(ans<b){
    ans*=2;
    num+=1;
    if (num==a)
      break;
  }
  if (num<a){
    for (int i=0;i<a-num;i++){
      ans+=b;
    }
  }
  cout<<ans<<endl;
}
    

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




typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

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

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

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;

struct Clock {
	int hour, minute, second;
	void set(int h, int m, int s) {
		hour = h; minute = m; second = s;
	}
	string to_str() {
		string h, m, s;
		h = to_string(hour);
		m= to_string(minute);
		s= to_string(second);
		if (h.size() < 2) h = "0" + h;
		if (m.size() < 2) m = "0" + m;
		if (s.size() < 2) s = "0" + s;
		return h + ":" + m + ":" + s;
	}
	void shift(int diff_second) {
		int h, m;
		h = diff_second / 3600;
		m = diff_second / 60;
		diff_second %= 60;
		second += diff_second;
		
	}
};


/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
int main() {
	string n;
	cin >> n;
	if (n[0] == '7')cout << "Yes";
	else if (n[1] == '7')cout << "Yes";
	else if (n[2] == '7')cout << "Yes";
	else cout << "No";
	return 0;
}










Measured memory_bytes: 3628