akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<tuple>
#include<ctime>
#include<functional>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p; 
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
    int N,t=1,cnt=0;
    cin>>N;
    for(int i=1;t<=N/2;i++){
        t*=2;
        cnt++;
    }
    p(t);
}

Measured memory_bytes: 256
import itertools

n=int(input())
li=[]

for i in range(n):
    li.append(input()[0])

tm=list(itertools.combinations(["M","A","R","C","H"],3))
ans=0

for j1,j2,j3 in tm:
    ans+=li.count(j1)*li.count(j2)*li.count(j3)

print(ans)


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

int h, w, cost[10][10], ans = 0;
int a[200][200], dist[10][10];
bool used[10];

void dijkstra(int s) {
	for (int i = 0; i < 10; i++)dist[s][i] = INT32_MAX;
	for (int i = 0; i < 10; i++)used[i] = false;

	dist[s][s] = 0;
	while (true) {
		int v = -1;
		for (int i = 0; i < 10; i++)if (!used[i] && (v == -1 || dist[s][v] > dist[s][i]))v = i;

		if (v == -1)break;
		used[v] = true;

		for (int i = 0; i < 10; i++) {
			dist[s][i] = min(dist[s][i], cost[v][i] + dist[s][v]);
		}
	}
}

int main() {
	cin >> h >> w;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> cost[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < 10; i++) {
		dijkstra(i);
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] != -1) {
				//cout << a[i][j] << "のコストは" << dist[a[i][j]][1] << "である" << endl;
				ans += dist[a[i][j]][1];
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1016
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))

ll N, W;
ll w[110], v[110];
ll dp[110][100100];

ll ans = 0;

ll V = 100010;

int main()
{
	cin >> N >> W;
	for (ll i = 0; i < N; i++)
	{
		cin >> w[i] >> v[i];
	}

	//dp[i][j]にはi個品物を選んだ時に総和の価値がjのときの最小の重さを記録する
	//0個選んだ時は価値0のときだけ0、あとINF
	dp[0][0] = 0;
	for (ll j = 1; j <= V; j++)
	{
		dp[0][j] = INF;
	}

	for (ll i = 1; i <= N; i++)
	{
		for (ll j = 0; j <= V; j++)
		{
			if (j - v[i - 1] >= 0)
			{
				dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i - 1]] + w[i - 1]);
			}
			else
			{
				dp[i][j] = dp[i - 1][j];
			}
		}
	}


	for (ll j = 0; j <= V; j++)
	{
		if (dp[N][j] <= W)
		{
			ans = max(ans, j);
		}
	}


	cout << ans << endl;
}

Measured memory_bytes: 80128
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
typedef long long ll;
using namespace std;

void solve(){
  int n, s; cin >> n;
  vector<vector<char> > c(2, vector<char>(n));
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < n; j++){
      cin >> c[i][j];
    }
  }

  ll ans, mod = 1000000007;
  bool yoko;
  if(n > 1 && c[0][0] == c[0][1]){
    ans = 3 * 2;
    s = 2;
    yoko = true;
  }
  else{
    ans = 3;
    s = 1;
    yoko = false;
  }

  //n = 12;
  for(int i = s; i < n; i++){
    if(i < n - 1 && c[0][i] == c[0][i + 1]){
      if(yoko == false) ans = (ans * 2) % mod;
      else ans = (ans * 3) % mod;
      //cout << c[0][i] << c[0][i + 1] << " " << ans << " ";
      i++;
      yoko = true;
    }
    else{
      if(yoko == false) ans = (ans * 2) % mod;
      //cout << c[0][i] << c[1][i] << " " << ans << " ";
      yoko = false;
    }
  }
  cout << ans << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  _n,_m=LI()

  ans=1
  ans2=1
  if abs(_n-_m)>1:
    return 0
    exit()
  else:
    n=_n
    m=_m
    while True:
      if n==0 or m==0:
        break
      ans*=n
      n-=1
      ans%=mod
      ans*=m
      m-=1
      ans%=mod
    n=_n
    m=_m
    while True:
      if n==0 or m==0:
        break
      ans2*=n
      n-=1
      ans2%=mod
      ans2*=m
      m-=1
      ans2%=mod
    if abs(_n-_m)==1:
      return ans%mod
    return (ans+ans2)%mod

print(main())


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

int main(void) {

	int a[2]={1,-1},b[2]={1,-1},c[3]={1,-1},inte[4],q,w,e,r,ans,che=0;
	char moj[4];
	for(int i=0;i<4;i++){
		cin>>moj[i];
		inte[i]=moj[i]-'0';
	}
	// sort(inte,inte+4);
	q=inte[0];
	w=inte[1];
	e=inte[2];
	r=inte[3];
	for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
			for(int k=0;k<2;k++){
				ans=q+w*a[i]+e*b[j]+r*c[k];
				if(ans==7){
					che=1;
					for(int v=0;v<4;v++){
						cout <<inte[v];
						if(v==3){
							cout<<"=7"<<endl;break;
						}
						if(a[i]==1&&v==0){
							cout<<"+";
						}
						if(a[i]==-1&&v==0){
							cout<<"-";
						}
						if(b[j]==1&&v==1){
							cout<<"+";
						}
						if(b[j]==-1&&v==1){
							cout<<"-";
						}
						if(c[k]==1&&v==2){
							cout<<"+";
						}
						if(c[k]==-1&&v==2){
							cout<<"-";
						}
					}
					
				}
				if(che==1){
					break;
				}
			}
			if(che==1){
				break;
			}
		}
		if(che==1){
			break;
		}
	}
	return 0;
}


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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

int k, n;
int m;
vector<int> ar;
vector<int> br;

int main(void){
    cin >> k >> n;
    rep(i, n){
        int a;
        cin >> a;
        ar.push_back(a);
    }
    ar.push_back(ar[0]+k);
    
    rep(i, n){
        br.push_back(ar[i+1]-ar[i]);
    }
    m = *max_element(br.begin(), br.end());
    cout << k-m << endl;
    return 0;
}


Measured memory_bytes: 2548
import math

N = int(input())

def enum(N,A):
    if(N % A == 0):
        B = N // A
        return (A,B)
    else:
        return 'NULL'

def F(tupleX):
    t = max(tupleX)
    return int(math.log10(t) + 1)

X = []
hu = int(math.sqrt(N)) + 1
for n in range(1,hu):
    X.append(enum(N,n))

Y = []
for x in X:
    if (x == 'NULL'):
        continue
    else:
        y = F(x)
        Y.append(y)

print(min(Y))

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a,b,c;
  cin>>n;
  int dp[n][3];
  cin>>a>>b>>c;
  dp[0][0]=a;
  dp[0][1]=b;
  dp[0][2]=c;
  for(int i=1;i<n;i++)
  {
      cin>>a>>b>>c;
      dp[i][0] =a+ max(dp[i-1][1],dp[i-1][2]);
      dp[i][1] = b+ max(dp[i-1][0],dp[i-1][2]);
      dp[i][2] = c+ max(dp[i-1][0],dp[i-1][1]);
      
  }
  int ans = max(dp[n-1][0],dp[n-1][1]);
  cout<<max(ans, dp[n-1][2])<<endl;
}

Measured memory_bytes: 1408
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

typedef long long ll;
const int O=1e5;

int fa[2*O+5];
ll cnt1[2*O+5],cnt2[2*O+5];

int find(int x) {
	if(fa[x]==x)return x;
	return fa[x]=find(fa[x]);
}

int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	for(int i=0;i<=2*O;i++)
		fa[i]=i;
	int N;
	scanf("%d",&N);
	for(int i=1;i<=N;i++) {
		int x,y;
		scanf("%d %d",&x,&y);
		fa[find(x)]=fa[find(y+O)];
	}
	for(int i=1;i<=O;i++)
		cnt1[find(i)]++;
	for(int i=O+1;i<=O*2;i++)
		cnt2[find(i)]++;
	ll ans=0;
	for(int i=1;i<=O*2;i++)
		ans+=cnt1[i]*cnt2[i];
	printf("%lld\n",ans-N);
	return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<climits>
#include<set>
#define ll long long
using namespace std;
int main() {
	ll n, x;
	cin >> n >> x;
	vector<ll>l(n),d(n+1);
	for (ll i = 0; i < n; i++) {
		cin >> l[i];
	}
	d[0] = 0;
	ll count = 1;
	for (ll i = 1; i <= n; i++) {
		d[i] = d[i - 1] + l[i - 1];
		if (d[i] <= x) {
			count++;
		}
	}
	cout << count << endl;

}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class Program{
    public static void Main(){
        string[] str = Console.ReadLine().Split(' ');
        int n = int.Parse(str[0]);
        int q = int.Parse(str[1]);
        var lists = new List<int>[n];
        for(int i=0; i<n; i++){
            lists[i] = new List<int>();
        }
        for(int i=0; i<q; i++){
            int[] line = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            switch(line[0]){
                case 0:
                    lists[line[1]].Add(line[2]);
                    break;
                case 1:
                    string ans = lists[line[1]].Count == 0 ? "" : string.Join(" ",lists[line[1]]);
                    Console.WriteLine(ans);
                    break;
                case 2:
                    lists[line[1]] = new List<int>();
                    break;
                default:
                    break;
            }
        }
    }
}



Measured memory_bytes: 44116
//22
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int n,m;
  cin>>n>>m;
  int d[21][21];
  fill_n(d[0],21*21,1<<29);
  for(int i=0;i<m;i++){
    int a[4];
    for(int i=0;i<4;i++){
      cin>>a[i];
      cin.ignore();
    }
    d[a[0]][a[1]]=a[2];
    d[a[1]][a[0]]=a[3];
  }
  for(int i=1;i<=20;i++){
    for(int j=1;j<=20;j++){
      for(int k=1;k<=20;k++){
	d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
      }
    }
  }
  int s,t,p,c;
  (((cin>>s).ignore()>>t).ignore()>>p).ignore()>>c;
  cout<<p-c-d[s][t]-d[t][s]<<endl;
  return 0;
}

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

LL x, y;
void work()
{
	scanf("%lld%lld", &x, &y);
	if(abs(x - y) <= 1) printf("Brown\n");
	else printf("Alice\n"); 
}

int main()
{
	//freopen("in.in", "r", stdin);
	work();
	//fclose(stdin);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    string s; cin >> s;
    string ans1 = "SS", ans2 = "SW", ans3 = "WS", ans4 = "WW";
    char c1 = (s[0]=='o') ? 'S' : 'W', c2 = (s[0]=='o') ? 'W' : 'S';
    char c3 = (s[0]=='o') ? 'W' : 'S', c4 = (s[0]=='o') ? 'S' : 'W';
    vector<string> v;
    v.push_back(ans1);v.push_back(ans2);v.push_back(ans3);v.push_back(ans4);
    vector<char> w;
    w.push_back(c1);w.push_back(c2);w.push_back(c3);w.push_back(c4);
    int x = -1;
    for (string k : v){
        x++;
        for (int i = 2; i < n; i++)
        {
            if (k[i-1] == 'S'){
                if (k[i-2] == 'S'){
                    if (s[i-1] == 'o'){
                        k.push_back('S');
                    }
                    else{
                        k.push_back('W');
                    }
                }
                else{
                    if (s[i-1] == 'o'){
                        k.push_back('W');
                    }
                    else{
                        k.push_back('S');
                    }
                }
            }
            else{
                if (k[i-2] == 'S'){
                    if (s[i-1] == 'o'){
                        k.push_back('W');
                    }
                    else{
                        k.push_back('S');
                    }
                }
                else{
                    if (s[i-1] == 'o'){
                        k.push_back('S');
                    }
                    else{
                        k.push_back('W');
                    }
                }
            }
        }
        if (s[n-1] == 'o'){
            if (k[n-1] == 'S'){
                if (k[n-2] != k[0])continue;
            }
            else {
                if (k[n-2] == k[0])continue;
            }
        }
        else {
            if (k[n-1] == 'S'){
                if (k[n-2] == k[0])continue;
            }
            else {
                if (k[n-2] != k[0])continue;
            }
        }
        if (k[n-1] == w[x]){
            cout << k << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}
    

Measured memory_bytes: 776
n = int(input())
# distance_matrix = [[0] * n for i in range(n)]
cordinates = [[0] * 2 for i in range(n)]
for i in range(n):
  cordinates[i][0], cordinates[i][1] = map(int, input().split())

sum = 0
for i in range(n):
  for j in range(n):
    #distance_matrix[i][j] = ((cordinates[i][0] - cordinates[j][0])**2 + (cordinates[i][1] - cordinates[j][1])**2)**0.5
    sum += (n-1)*(((cordinates[i][0] - cordinates[j][0])**2 + (cordinates[i][1] - cordinates[j][1])**2)**0.5)

print(sum / (n*(n-1)))

Measured memory_bytes: 3064
def main():
    N, T = map(int, input().split())

    ans = float('inf')

    for _ in range(N):
        c, t = map(int, input().split())
        if t <= T:
            if ans > c:
                ans = c

    if ans == float('inf'):
        print('TLE')
    else:
        print(ans)

main()

Measured memory_bytes: 38384
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}



int main(void) {

	int sum = 0;
	int mini = 10;

	for (int i = 0; i < 5; i++) {
		int a;
		cin >> a;
		sum += ceil(a / 10.0) * 10;
		if (a % 10 != 0)
			CHMIN(mini, a % 10);
	}

	COUT(sum - 10 + mini);

	return 0;
}


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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

typedef long long ll;
const int MOD = 1000000007;
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int k, s; cin >> k >> s;
	int ans = 0;
	REPU(x, 0, k + 1) REPU(y, 0, k + 1) {
		int z = s - x - y;
		if (z >= 0 && z <= k) ans++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char buf[100];
    fgets(buf, sizeof(buf), stdin);

    
    char str[10];
    sscanf(buf, "%s", str);
    if(!strcmp(str,"ABC")){
        printf("ARC");
    }else{
        printf("ABC");
    }
}


Measured memory_bytes: 1768
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i]--;
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (A[A[i]] == i) ans++;
    }
    assert(ans%2 == 0);
    cout << ans/2 << endl;
    return 0;
}


Measured memory_bytes: 640
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int x=max(a,b);
    x=max(x,c);  
    int sum=a+b+c;
    cout<<10*x+sum-x;
system("pause");
return 0;
}

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

int main() {
    double n, k;
    cin >> n >> k;

    double repnum = (n - k >= 0) ? k - 1 : n;

    double ans = 0.0;
    for (int i = (int)repnum; i > 0; i--) {
        double div = k / i;
        double log = log2(div);
        double minInt = ceil(log);
        ans += pow(2, -1 * minInt);
    }
    ans = (ans + n - repnum) / n;

    cout << setprecision(16) << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
#define mod2 20071027
//#define mod 1000074259
#define base 139
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case %lld: ", ++c)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
const ll N=300010;
ll a, b;
int main()
{
    in2(a,b);
    ll x=(a/b);
    if(a%b) x++;
    cout<<x<<endl;
    return 0;
}

/*

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1100000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)};
const int max_n = 1 << 20;

signed main() {
	int a,b;cin>>a>>b;
  cout << max((ll)0,a-2*b) << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  ll n, p;
  cin >> n >> p;

  int m = sqrt(p);
  vector<ll> d(m+2);
  rep(i,m+2) d[i]=0;

  ll j = 2;
  while(1){
    if(p%j == 0){
      p /= j;
      d[j]++;
      continue;
    }
    j++;
    if(j > m+1) break;
  }

  ll ans = 1;
  for(int i = 2; i <= m+1; i++) {
    ll k = d[i]/n;
    while(k>0) {
      ans *= i;
      k--;
    }
    //cout << i << " " << d[i] << endl;
  }
  if(1/n == 1) ans *= p;
  
  cout << ans << endl;
  
}


Measured memory_bytes: 10988
#include<bits/stdc++.h>
#define GO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
const int Max = 3e5 + 5;
const int Mod = 1e9 + 7;

int main()
{
	GO;
	int n;
	cin >> n;
	set<ll> st;
	for (int i = 0; i < n; i++)
	{
		ll x;
		cin >> x;
		st.insert(x);
	}
	cout << (st.size() == n ? "YES" : "NO") << endl;
	return 0;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	for (int i = 0; i <= n / 4; ++i) {
		if ((n - i * 4) % 7 == 0) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 256
#include <stdio.h>
int a[100][100],b[100];
int main(void){
    int m,n;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(int k=0;k<m;k++){
        scanf("%d",&b[k]);
    }
    for(int i=0;i<n;i++){
        int c=0;
        for(int j=0;j<m;j++){
            c+=a[i][j]*b[j];
        }
        printf("%d\n",c);
    }
    return 0;
}


Measured memory_bytes: 2768
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    i64 n, x;
    cin >> n >> x;
    i64 y = n - x;
    if (x < y) swap(x, y);
    i64 ans = 0;
    while (y > 0) {
        ans += y * (x / y);
        swap(x, y);
        y = y % x;
    }
    cout << 3 * ans << endl;
    return 0;
}


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

struct Graph {
    Graph(const int n)
    {
        edge.resize(n);
    }
    void addEdge(const int from, const int to)
    {
        edge[from].push_back(to);
        edge[to].push_back(from);
    }
    vector<vector<int>> edge;
};

int dfs(const Graph& g, const int s, vector<bool>& used, vector<bool>& compressed)
{
    used[s] = true;
    int removed = 0;
    int child = 0;
    for (const int to : g.edge[s]) {
        child++;
        if (used[to]) {
            continue;
        }
        removed += dfs(g, to, used, compressed);
    }
    if (s != 0 and removed + 1 == child) {
        compressed[s] = false;
        return 1;
    }
    return 0;
}

int weight_dfs(const Graph& g, const int s, const vector<int>& w, vector<bool>& visited)
{
    visited[s] = true;
    int weight = w[s];
    int maxi = 0;
    for (const int to : g.edge[s]) {
        if (visited[to]) {
            continue;
        }
        maxi = max(maxi, weight_dfs(g, to, w, visited));
    }
    return weight + maxi;
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> w(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i];
    }
    Graph g(N);
    vector<int> u(M);
    vector<int> v(M);
    for (int i = 0; i < M; i++) {
        int u_, v_;
        cin >> u_ >> v_;
        u_--;
        v_--;
        u[i] = u_;
        v[i] = v_;
        g.addEdge(u_, v_);
    }

    vector<bool> used(N, false);
    vector<bool> compressed(N, true);

    dfs(g, 0, used, compressed);
    int sum = 0;
    for (int i = 0; i < N; i++) {
        if (compressed[i]) {
            sum += w[i];
        }
    }
    w[0] = sum;
    Graph dec_g(N);
    for (int i = 0; i < M; i++) {
        int u_ = u[i];
        int v_ = v[i];
        if (compressed[u_]) {
            u_ = 0;
        }
        if (compressed[v_]) {
            v_ = 0;
        }
        if (u_ == 0 and v_ == 0) {
            continue;
        }
        dec_g.addEdge(u_, v_);
    }
    vector<bool> visited(N, false);
    cout << weight_dfs(dec_g, 0, w, visited) << endl;

    return 0;
}

Measured memory_bytes: 25732
#include<bits/stdc++.h>
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define sp fixed<<setprecision
#define sz sizeof
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
bool pr[1000007];
ll fpow(ll x,ll y){x=x%MOD;ll res=1;while(y){if(y&1)res=res*x;res%=MOD;y=y>>1;x=x*x;x%=MOD;}return res;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  ll h,w;
  cin>>h>>w;
  ll dp[h+1][w+1];
  char grid[h+1][w+1];
  for(int i=1;i<=h;i++)
  for(int j=1;j<=w;j++)
  cin>>grid[i][j];
  dp[1][1]=1;
  for(int i=2;i<=w;i++)
  {
    if(grid[1][i]=='#')
    dp[1][i]=0;
    else
    dp[1][i]=dp[1][i-1];
  }
  for(int i=2;i<=h;i++)
  {
    if(grid[i][1]=='#')
    dp[i][1]=0;
    else
    dp[i][1]=dp[i-1][1];
  }
  for(int i=2;i<=h;i++)
  for(int j=2;j<=w;j++)
  {
    if(grid[i][j]=='#')
    dp[i][j]=0;
    else
    {
      dp[i][j]=(dp[i-1][j]%MOD+dp[i][j-1]%MOD)%MOD;
    }
  }
  cout<<dp[h][w];

}


Measured memory_bytes: 9088
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long int h;
    cin >> h;
    
    long long int pow2 = 2;
    
    while(pow2 <= h){
        pow2*=2;
    }
    
    cout << pow2-1;
    return 0;
}


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

using namespace std;

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

const int INF = 1e9;


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

	int n;
	cin >> n;
	
	map<int,int> a;
	int tmp;
	for(int i=0;i<n;i++){
		cin >> tmp;
		if(a.find(tmp) != a.end()){
			a[tmp]++;
		}else a[tmp]=1;
	}
	int ans=0;
	for(auto i=a.begin();i!=a.end();i++){
		if(i->second % 2 == 1) ans++;
	}
	cout << ans << "\n";
				
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int gcd(int x, int y);

int main()
{
    int n;
    string s;
    cin >> n;
    while (getline(cin, s))
    {
        bool is_found = false;
        for(int alpha=1; alpha<=26; alpha++)
        {
            if(gcd(alpha, 26) !=1)
            {
                continue;
            }
            for(int beta=0; beta<26; beta++)
            {
                string ans = s;
                for(int i=0; i<ans.size(); i++)
                {
                    if(ans[i] >= 'a' && ans[i] <= 'z')
                    {
                        ans[i] = 'a' + (alpha * (ans[i] -'a') + beta) % 26;
                    }
                    else
                    {

                    }
                }
                if( ans.find("this") != std::string::npos
                 || ans.find("that") != std::string::npos)
                {
                    cout << ans << endl;
                    is_found = true;
                    break;
                }
            }
            if(is_found)
            {
                break;
            }
        }
    }
    return 0;
}

int gcd(int x, int y)
{
    if(x < y)
    {
        swap(x, y);
    }
    while(y > 0)
    {
        int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

Measured memory_bytes: 3056
#include<cstdio>

using namespace std;

int main() {
	long long x, ans = 0;
	scanf("%lld", &x);
	ans = x / 11;
	if(x % 11 == 0) {
		ans *= 2;
	} else if(x % 11 <= 6) {
		ans = ans * 2 + 1;
	} else if(x % 11 > 6) {
		ans = (ans + 1) * 2;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int A,B;cin>>A>>B;
  
  if(A<=8&&B<=8){
    cout<<"Yay!"<<endl;
  }
  else{
    cout<<":("<<endl;
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;


struct BipartiteMatching {
	int V;
	vector<vector<bool> > G;
	vector<int> match;
	vector<bool> used;

	BipartiteMatching(int v) {
		V = v;
		G = vector<vector<bool> >(v, vector<bool>(v));
		match = vector<int>(v);
		used = vector<bool>(v);
	}

	void add_edge(int v, int u) {
		G[v][u] = G[u][v] = true;
	}

	bool dfs(int v) {
		used[v] = true;
		for(int i = 0; i < V; i++) {
			if(!G[v][i]) continue;
			int u = i, w = match[u];
			if(w < 0 || (!used[w] && dfs(w))) {
				match[v] = u;
				match[u] = v;
				return true;
			}
		}
		return false;
	}

	int calc() {
		int res = 0;
		fill(match.begin(), match.end(), -1);
		for(int v = 0; v < V; v++) {
			if(match[v] < 0) {
				fill(used.begin(), used.end(), false);
				if(dfs(v)) {
					res++;
				}
			}
		}
		return res;
	}
};

typedef pair<int, int> Pii;

int h, w;
string C[100];
int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };

bool exist(int i, int j) {
	if(0 <= i && i < h && 0 <= j && j < w) return C[i][j] == '#';
	return false;
}

struct line {
	int x1, y1, x2, y2;
};

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

	while(cin >> h >> w, h) {
		for(int i = 0; i < h; i++) {
			cin >> C[i];
		}

		bool G[101][101][4] = { { 0 } };
		bool E[101][101] = { { 0 } };
		vector<Pii> p;
		for(int i = 0; i < h + 1; i++) {
			for(int j = 0; j < w + 1; j++) {
				G[i][j][0] = exist(i - 1, j) && exist(i, j);
				G[i][j][1] = exist(i, j - 1) && exist(i, j);
				G[i][j][2] = exist(i - 1, j - 1) && exist(i, j - 1);
				G[i][j][3] = exist(i - 1, j - 1) && exist(i - 1, j);
				if(exist(i, j) + exist(i - 1, j) + exist(i, j - 1) + exist(i - 1, j - 1) == 3) {
					E[i][j] = true;
					p.emplace_back(j, i);
				}
			}
		}

		vector<line> tate, yoko;
		for(int y = 0; y < h + 1; y++) {
			for(int x = 0; x < w + 1; x++) {
				if(!E[y][x]) continue;
				for(int k = 0; k < 2; k++) {
					int ny = y, nx = x;
					if(!G[ny][nx][k]) continue;
					do {
						ny += dy[k];
						nx += dx[k];
					} while(!E[ny][nx] && G[ny][nx][k]);
					if(E[ny][nx]) {
						if(k % 2 == 1) tate.push_back(line{ x, y, nx, ny });
						else yoko.push_back(line{ x, y, nx, ny });
					}
				}
			}
		}

		int N = tate.size(), M = yoko.size();
		BipartiteMatching bp(N + M);
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < M; j++) {
				line t = tate[i], y = yoko[j];
				if(t.y1 <= y.y1 && y.y1 <= t.y2 && y.x1 <= t.x1 && t.x1 <= y.x2) {
					bp.add_edge(i, N + j);
				}
			}
		}

		int match = bp.calc();
		cout << p.size() - (N + M - match) + 1 << endl;
	}
}

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

int main() {
	char s[100];
	scanf("%s", s);
	if (strlen(s) != 4) {
		printf("No");
		return 0;
	}
	if ((s[0] == s[1] && s[2] == s[0]) || (s[3] == s[1] && s[3] == s[2]))
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 128
n, w = [int(i) for i in input().split()]
dp = [0] * (w + 1)
for _ in range(n):
    u, v = [int(i) for i in input().split()]
    for i in reversed(range(w - u + 1)):
        dp[i + u] = max(dp[i + u], dp[i] + v)

print(max(dp))


Measured memory_bytes: 41740
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
X = []
for i in range(N):
  X.append(V[i]-C[i])
#print(X)
s = 0
for i in range(N):
  if X[i] > 0:
    s += X[i]
print(s)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, Q; cin >> N >> Q;
	string s; cin >> s;
	vector<int>vec(s.size(), 0);
	rep(i, 0, s.size() - 1) {
		if (s[i] == 'A' && s[i + 1] == 'C')vec[i + 1]++;
	}
	rep(i, 1, vec.size()) {
		vec[i] += vec[i - 1];
	}

	rep(i, 0, Q) {
		int l, r; cin >> l >> r;
		--l; --r;
		cout << vec[r] - vec[l] << "\n";
	}

	return 0;
}


Measured memory_bytes: 1488
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr){ sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll N;
    string S;
    cin >> N >> S;
    //unique(S);
    char pre = '_';
    auto ite = remove_if(S.begin(), S.end(), [&](char ch)
        {
            bool r = (pre == ch);
            pre = ch;
            return r;
        });
    S.erase(ite, S.end());
    cout << S.size();
    //
    return 0;
}

Measured memory_bytes: 3284
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

int main() {
    ll H, W;
    cin >> H >> W;

    if (H == 1 || W == 1) {
        cout << 1 << endl;
    } else {
        ll ans = (W*H+1)/2;
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
import sys
import itertools

v = list(range(10))

for line in sys.stdin:
    n = int(line)
    res = 0

    for i in itertools.product(v, repeat=4):
        sum = 0
        for y in i:
            sum += y
        
        if sum == n:
            res += 1

    print(res)

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

int main(){

    int n,cnt=1;
    cin >> n;

    int d[n];
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    sort(d,d+n);
    for(int i=1;i<n;i++){
        if(d[i-1] < d[i]) cnt++;
    }
  	cout << cnt;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a*b;
        int length =2*(a+b);
        System.out.println(area + " " + length);
    }
}


Measured memory_bytes: 26248
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e9;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

struct Point{
	int x,y;
};

bool vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

int main(){
    ll N,M,a,b;
    cin >> N >> M;
    vector<pair<ll,ll> > BA;
    rep(i,M){
        cin >> a >> b;
        BA.push_back(make_pair(b-1,a));
    }
    sort(BA.begin(), BA.end());
    ll bridge = -1;
    ll cnt=0;
    rep(i,M){
        if (BA[i].second<=bridge) continue;
        else{
            bridge = BA[i].first;
            cnt ++;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

#define int long long
const int N = 2002;
pair<int,int> arr[N];
int dp[N][N];

int solve(int i,int l,int r)
{
    if(l > r) return 0;

    int & ans = dp[l][r];
    if(ans != -1) return ans;

    ans = 0;

    // place at left
    ans = arr[i].first*abs(l - arr[i].second) + solve(i+1,l+1,r);

    // place at right
    ans = max(ans,arr[i].first*abs(r - arr[i].second) + solve(i+1,l,r-1));

    return ans;

}

int32_t main() {
    
    int n; cin>>n;
    memset(dp,-1,sizeof dp);

    for(int i = 0;i<n;i++)
    {
        cin>>arr[i].first;
        arr[i].second = i;
    }

    sort(arr,arr + n);
    reverse(arr,arr + n);

    cout<<solve(0,0,n-1);


}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

class UnionFind {
    private :
        std::vector<int> par;
        std::vector<int> sz;
    public :
        UnionFind(int n) {
            par.resize(n);
            for (int i=0; i<n; i++) par[i] = i;
            sz.assign(n, 1);
        }
        void unite(int x, int y) {
            const int x_par = find(x);
            const int y_par = find(y);
            if (x_par == y_par) return;

            if (sz[x_par] < sz[y_par]) {
                par[x_par] = y_par;
                sz[y_par] += sz[x_par];
            } else {
                par[y_par] = x_par;
                sz[x_par] += sz[y_par];
            }
        }
        int find(int x) {
            if (par[x] == x) return x;
            else return par[x] = find(par[x]);
        }
        bool same(int x, int y) { return find(x) == find(y); }
        int size(int x) { return sz[find(x)]; }
};

void dfs(int cur, int pre, const Graph &t, Graph &ans) {
    for (int nx : t[cur]) {
        if (nx != pre) dfs(nx, cur, t, ans);
    }
    if (pre != -1) {
        if ((int)ans[cur].size()%2 == 0) ans[pre].push_back(cur);
        else ans[cur].push_back(pre);
    }
}

void solve() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> es(M);
    for (int i=0; i<M; ++i) {
        int a, b;
        cin >> a >> b;
        es[i] = {a-1, b-1};
    }

    if (M%2 == 1) {
        cout << -1 << '\n';
        return;
    }

    UnionFind uf(N);
    Graph t(N), ans(N);
    for (auto p : es) {
        if (!uf.same(p.first, p.second)) {
            uf.unite(p.first, p.second);
            t[p.first].push_back(p.second);
            t[p.second].push_back(p.first);
        } else {
            ans[p.first].push_back(p.second);
        }
    }
    dfs(0, -1, t, ans);
    for (int i=0; i<N; ++i) {
        for (int j : ans[i]) {
            cout << i + 1 << ' ' << j + 1 << '\n';
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 19520
import java.util.*;
import java.math.*;

class Main{
    
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        
        System.out.print(((c <= b && c >= a)||(c >= b && c <= a) ? "Yes":"No"));
        
    }
}


Measured memory_bytes: 23252
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second

using namespace std;

const long long MOD = (long long)1e9 + 7;

int n, m, k, mk[50];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> k;
		for (int j = 0; j < k; j++) {
			int tmp;
			cin >> tmp;
			mk[tmp]++;
		}
	}
	int ans = 0;
	for (int i = 1; i <= m; i++) if (mk[i] == n) ans++;
	cout << ans << "\n";
	//system("pause");
	return 0;
}

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

int  main()
{
    int n,a;
    cin>>n;
    int freq[n+1];

    for(int i=0;i<n+1;i++)
        freq[i]=0;

    for(int i=0;i<n-1;i++)
    {
        cin>>a;
        freq[a]++;
    }

    for(int i=1;i<n+1;i++)
        cout<<freq[i]<<endl;
}


Measured memory_bytes: 4416
import itertools
k = int(input())
p = []
for i in range(1, k+1):
    p.append(i)
ans = 0
for v in itertools.combinations(p, 2):
    if v[0] % 2 == 0 and v[1] % 2 == 1 or v[1] % 2 == 0 and v[0] % 2 == 1:
        ans += 1
print(ans)


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1000000001
typedef long long ll;

int n;
// int a;

// ll dp[51][51][2510];
int a[114514];

// ll acc[114514];
// // char X[100][100];
// // int dp[1000000001];
// ll dp[114514];

int main(void){
    cin >> n;
    REP(i,0,n) {
        cin >> a[i];
        // if (i >= 1) acc[i] = a[i] + acc[i-1];
        // else acc[i] = a[i];
    }
    
    // REP(i,0,n) {
    //     cout << acc[i] << endl;
    // }
    
    ll ans1 = 0;
    ll ans2 = 0;
    
    ll s = 0;
    REP(i,0,n) {
        s += a[i];
        if (i % 2 && s >= 0) {
            ans1 += s + 1;
            s = -1;
        }
        else if (i % 2 == 0 && s <= 0) {
            ans1 += 1 - s;
            s = 1;
        }
    }
    
    s = 0;
    REP(i,0,n) {
        s += a[i];
        if (i % 2 == 0 && s >= 0) {
            ans2 += s + 1;
            s = -1;
        }
        else if (i % 2 &&  s <= 0) {
            ans2 += 1 - s;
            s = 1;
        }
    }
    
    cout << min(ans1,ans2) << endl;
 

}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {

    string s;
    long long int k;
    cin >> s >> k;

    long long int cnt = 0;
    long long int p = 0;

    for ( long long int i = 0; i < s.size() - 1; i++ ) {
        if ( s[i] == s[i+1] ) {
            p++;
        } else {
            cnt += ( p + 1 ) / 2;
            p = 0;
        }
    }
    if ( p == s.size() - 1 ) {
        cout << ( k * s.size() ) / 2 << endl;
        return 0;
    }
    cnt += ( p + 1 ) / 2;

    long long int cnt2 = 0;
    p = 0;
    s = s + s;
    for ( long long int i = 0; i < s.size() - 1; i++ ) {
        if ( s[i] == s[i+1] ) {
            p++;
        } else {
            cnt2 += ( p + 1 ) / 2;
            p = 0;
        }
    }
    cnt2 += ( p + 1 ) / 2;

    long long int cnt4 = 0;
    p = 0;
    s = s + s;
    for ( long long int i = 0; i < s.size() - 1; i++ ) {
        if ( s[i] == s[i+1] ) {
            p++;
        } else {
            cnt4 += ( p + 1 ) / 2;
            p = 0;
        }
    }
    cnt4 += ( p + 1 ) / 2;
    cnt4 -= cnt2;
    cnt4 /= 2;

    if ( k == 1 ) {
        cout << cnt << endl;
    } else if ( k == 2 ) {
        cout << cnt2 << endl;
    } else {
        cout << cnt4 * ( k - 2 ) + cnt2 << endl;
    }

    return 0;

}


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

using namespace std;

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  int height[N], a, b, cnt = N;
  bool bad[N] = {false};
  for (int i = 0; i < N; i++)
    cin >> height[i];
  for (int i = 0; i < M; i++){
    cin >> a >> b;
    if (height[a - 1] <= height[b - 1] && bad[a - 1] == false) {
      bad[a - 1] = true;
      N--;
    }
    if (height[a - 1] >= height[b - 1] && bad[b - 1] == false) {
      bad[b - 1] = true;
      N--;
    }
  }
  cout << N << '\n';
  return 0;
}


Measured memory_bytes: 4112
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int k,a,b,x;
		Scanner sc = new Scanner(System.in);
		
		k = Integer.parseInt(sc.next());
		a = Integer.parseInt(sc.next());
		b = Integer.parseInt(sc.next());
		
		sc.close();
		
		x = (b / k) * k;
		if(a <= x) {
			System.out.println("OK");
		}else {
			System.out.println("NG");
		}
	}
}

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

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

	ll n, D;
	cin >> n >> D;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	vector<ll> b = a;
	for (int i = 1; i < n; ++i)
		b[i] = min(b[i], b[i - 1] + D);
	for (int i = n - 2; i >= 0; --i)
		b[i] = min(b[i], b[i + 1] + D);

	const int src = min_element(a.begin(), a.end()) - a.begin();

	ll ans = 0;
	for (int i = src - 1; i >= 0; --i) {
		ans += a[i] + b[i + 1] + D;
	}

	for (int i = src + 1; i < n; ++i) {
		ans += a[i] + b[i - 1] + D;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3328