akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc54
{
    class Program
    {
        static void Main(string[] args){
            bool res = false;
            var inp = ScanInt;
            int N = inp[0];
            int M = inp[1];
            string[] A = new string[N];
            string[] B = new string[M];
            for (int i = 0; i < N; i++)
            {
                A[i] = Console.ReadLine();
            }
            for (int i = 0; i < M; i++)
            {
                B[i] = Console.ReadLine();
            }  
            for (int i = 0; i < N - M + 1; i++)
            {
                for (int j = 0; j < N - M + 1; j++)
                {
                   // Console.WriteLine("@");
                    if(!res)
                    res = check(A, B, i, j);
                }
            }
            if (res)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
        static bool check(string[] a, string[] b, int i, int j)
        {
            for(int i1 = 0; i1 < b[0].Length; i1++)
            {
                for(int j1 = 0; j1 < b[0].Length; j1++)
                {
                   // Console.WriteLine((i + i1) +" "+ (j + j1));
                    if (a[j + j1][i + i1] != b[j1][i1])
                    {
                        return false;
                    }
                }
            }
            return true;
        }
        static int[] ScanInt {
            get {
                return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            }
        }
        static string[] Scan {
            get {
                return Console.ReadLine().Split(' ');
            }
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,x,y,z;
cin>>a>>b>>c;
x=a;
y=b;
z=c;
b=x;
a=z;
c=y;
cout<<a<<' '<<b<<' '<<c;
return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
string s[55];
ll t[55];
int main(){
  ll n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>s[i]>>t[i];
  string x;
  cin>>x;
  ll ans=0;
  bool f=false;
  for(int i=0;i<n;i++){
    if(f) ans+=t[i];
    if(s[i]==x) f=true;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 888
#include<stdio.h>

int main(){
  int i, j, N, v, A[1000];

  scanf("%d",&N);
  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
  }
  for(i=0; i<N; i++){
    v = A[i];
    j = i - 1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1]=v;
    for(j=0; j<N; j++){
      if(j<N-1)printf("%d ",A[j]);
      else printf("%d\n",A[j]);
    }
  }
  return 0;
}
      

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

int main(){
    int n,A[100];
    cin >> n;
    for( int i = 0; i< n; i++ ) cin >> A[i];
    
    for( int i = n-1; i >= 0; i--) {
        if( i != n-1 ) cout << " ";
        cout << A[i];
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3020
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

void pr(ll ans){
    cout1(ans)
    exit(0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b,c,sum;
    cin>>a>>b>>c;
    sum=a+b+c;
    
    if(a%2||b%2||c%2) pr(0);
    if((a==b)&&(b==c)) pr(-1);
    ll cnt=0;
    while(a%2==0&&b%2==0&&c%2==0){
        a=(sum-a)/2;
        b=(sum-b)/2;
        c=(sum-c)/2;
        cnt++;
    }
    pr(cnt);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int cnt[200010],a[200010];
long long sum=0;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		cnt[a[i]]++;
	}
	for(int i=1;i<=n+1;i++)
		sum=sum+1ll*cnt[i]*(cnt[i]-1)/2;
	for(int i=1;i<=n;i++)
	{
		long long ans=sum;
		int x=a[i];
		if(cnt[x]!=0)
			ans=ans-1ll*cnt[x]*(cnt[x]-1)/2+1ll*(cnt[x]-1)*(cnt[x]-2)/2;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N;
ll L[4000];

void input() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> L[i];
}

void solve() {
    input();
    vector<ll> v(N);
    for(int i = 0; i < N; i++) v[i] = L[i+1];
    sort(v.begin(), v.end());
    ll ans = 0;
    for(ll mid = N - 2; mid >= 0; mid--) {
        for(ll low = mid - 1; low >= 0; low--) {
            auto itr = lower_bound(v.begin(), v.end(), v[mid] + v[low]);
            ll ng = distance(itr, v.end());
            ans += (N - 1 - mid) - ng;
            //cerr << v[mid] + v[low] << " " << ng << " " << (N-1-mid)-ng << endl;
        }
    }
    cout << ans << endl;
    return;
}

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


Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)

typedef long long ll;


using namespace std;


int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a<b and b<c){cout<<"Yes"<<endl;}
    else {cout<<"No"<<endl;}

    return 0;
};

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N; cin >> N;
    ll K; cin >> K;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<vector<int>> A_2(N,vector<int>(41));
    rep(i,N){
        int j = 0;
        while(A[i] > 0){
            A_2[i][j] = A[i]%2;
            A[i] /= 2;
            j++;
        }
    }
    vector<int> num(41);
    for(int i = 40; i >= 0; i--){
        rep(j,N){
            if(A_2[j][i] == 1) num[i]++;
        }
    }
    ll ans = 0;
    ll nowX = 0;
    for(int i = 40; i >= 0; i--){
        if(num[i] >= N-num[i]){
            ans += num[i]*(ll)pow(2,i);
        }
        else{
            if(nowX+(ll)pow(2,i) > K){
                ans += num[i]*(ll)pow(2,i);
            }
            else{
                ans += (N-num[i])*(ll)pow(2,i);
                nowX += (ll)pow(2,i);
            }
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 20608
/* � Ashiq Uddin Pranto
   Department of Computer Science and Engineering
   BATCH 27
   University Of Rajshahi,Bangladesh
*/
#include<bits/stdc++.h>

#define ll long long
#define ld long double
#define FOR(x,y) for(ll i=x;i<=y;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define matrix(x) vector<vector<x>>
#define vss vector<string>
#define PI (2*acos(0.0))
#define sqr(x) ((x)*(x))
#define sf(a)   scanf("%d",&a)
#define sfl(a)  scanf("%lld",&a)
#define sff(a,b)    scanf("%d %d",&a,&b)
#define sffl(a,b)   scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define ms(a,b) memset(a, b, sizeof(a))
#define ff  first
#define ss  second
#define lcm(a, b)   ((a)*((b)/__gcd(a,b)))
#define all(a)  a.begin(),a.end()
#define readfile freopen("input.txt","r",stdin);
#define writefile freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define gap " "
#define mx 104
#define inf (ll)1e9
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define EMPTY_VALUE -1
#define mod 1000000007
#define MOD(a,b) (a%b + b)%b

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main()
{
    //fastio
    ll x;
    sfl(x);
    vll a(x+2,0);
    ll ans = 0;
    for(ll i=1;i<=x;i++)
    {
        for(ll j=0;j<=x;j+=i) a[j]++;
    }
    for(ll i=1;i<=x;i++)
    {
        a[i]*=i;
        ans+=a[i];
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 81340
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>

using std::vector;
#define rep(i,n) for(int i=0;i<(n);++i)

int main() {
  int n, m = 0;
  std::cin >> n;
  vector<vector<bool>> edges(n, vector<bool>(n));
  vector<vector<int>> graph(n);

  rep(i, n) {
    std::string s;
    std::cin >> s;
    rep(j, n) {
      edges[i][j] = s[j] == '1';
      if (edges[i][j]) {
        graph[i].push_back(j);
        ++m;
        // sstd::cerr << i << " " << j << std::endl;
      }
    }
  }

  int ans=-1;
  rep(i, n) {
    std::queue<std::pair<int,int>> que;
    std::vector<int> dist(n, -1);
    que.push({i,-1});
    dist[i] = 0;
    bool ok=true;
    while(not que.empty()) {
      std::pair<int,int> pr = que.front(); que.pop();
      int now = pr.first, bk = pr.second;
      for (int next: graph[now]) {
        if (dist[next] == -1) {
          dist[next] = dist[now] + 1;
          que.push({next,now});
        } else if(
          dist[next] == dist[now] ||
          dist[next] != dist[now] + 1 && !edges[now][next]
        ) {
          ok = false;
        }
      }
    }
    int r=*std::max_element(dist.begin(), dist.end()) + 1;
//    if (ok) std::cerr << i << " " << r << std::endl;
    if(ok) ans=std::max(ans,r);
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void){
	int n;
	int i;

	scanf("%d",&n);
	
	for(i=1; i<=n; i++){if(i%3==0 || i%10==3 || i%100/10==3 || i%1000/100==3 || i%10000/1000==3)printf(" %d",i);}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(3 * n);
    for(ll i=0;i<3 * n;++i){
        cin>>a[i];
    }
    sort(a.begin(), a.end());

    ll ans = 0;
    for(ll i=1;i<2*n;i+=2){
        ans += a[3*n-i-1];
    }
    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define CVector CPoint
#define INF 0x3f3f3f3f
#define MAXN 1e5
const LL mod=1e9+7;
const double PI=acos(-1.0);
const double EPS=1e-10;
inline int readint(){int sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-')f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}if(f) return -sum;return sum;}
inline LL readLL(){LL sum=0;char c=getchar();bool f=0;while(c<'0'||c>'9'){if(c=='-') f=1;c=getchar();}while(c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}if(f) return -sum;return sum;}


const int maxn=1e5+5;
LL inv[maxn],p[maxn];
int s[maxn];
void init(int n,LL mod){
    inv[1]=inv[0]=1;
    p[0]=p[1]=1;
    for(int i=2;i<=n;i++){
        inv[i]=(mod-mod/i)*inv[mod%i]%mod;
        p[i]=p[i-1]*i%mod;
    }
    for(int i=2;i<=n;i++){
        inv[i]=inv[i-1]*inv[i]%mod;
    }
}

LL ch(int t,int i){
    if(t<i) return 0LL;
    LL s=p[t]*inv[i]%mod*inv[t-i]%mod;
    return s;
}
int main(){ios_base::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;
    init(n+2,mod);
    int ff,ss;
    for(int i=1;i<=n+1;i++){
        int a;cin>>a;
        if(!s[a]) s[a]=i;
        else{
            ff=s[a];
            ss=i;
        }
    }
    int t=ff+n-ss;
    for(int i=1;i<=n+1;i++){
        LL ans=p[n+1]*inv[i]%mod*inv[n+1-i]%mod;
        ans-=ch(t,i-1);
        ans=(ans%mod+mod)%mod;
        cout<<ans<<endl;
    }
    return 0;
}

//cout.setf(ios::fixed);
//cout<<fixed<<setprecision(10)<<s<<endl;


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

int main(){
	string s;
	cin>>s;
	int q;
	cin>>q;
	bool rev=false;
	vector<char>front,back;
	char c;
	for(int i=0,t,f;i<q;++i){
		cin>>t;
		if(t==1){if(rev)rev=false;else rev=true;}
		else if(t==2){
			cin>>f>>c;
			if(f==1){
				if(rev)back.push_back(c);
				else front.push_back(c);
			}else{
				if(rev)front.push_back(c);
				else back.push_back(c);
			}
		}
	}
	if(rev){
		for(int i=back.size()-1;i>=0;--i)cout<<back.at(i);
		for(int i=s.size()-1;i>=0;--i)cout<<s.at(i);
		for(int i=0;i<front.size();++i)cout<<front.at(i);
	}else{
		for(int i=front.size()-1;i>=0;--i)cout<<front.at(i);
		for(int i=0;i<s.size();++i)cout<<s.at(i);
		for(int i=0;i<back.size();++i)cout<<back.at(i);
	}
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int a,b,c;

  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);

  if(a+b == c||a+c == b||b+c == a){
    printf("Yes");
  }else{
    printf("No");
  }

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  while (1) {
    string s = to_string(n);
    if (s[0] == s[1] && s[1] == s[2]) {
      cout << n << endl;
      return 0;
    }
    n++;
  }
  return 0;
}


Measured memory_bytes: 256
N = int(input())
def judge(x):
    if 1<= x <= 9:
        return True
    else:
        return False
ans = 0
for i in range(1,10):
    if N % i == 0 and judge(N / i):
        ans += 1
        break
    else:
        continue
if ans == 0:
    print("No")
else:
    print("Yes")





Measured memory_bytes: 38384
N = int(input())
A = list(map(int, input().split()))

DP_odd = [0, 0, A[0]]
DP_even = [0, max(A[0], A[1])]

if N >= 3:
    DP_odd = [DP_even[0], max(DP_odd[1] + A[2], DP_even[1]), DP_odd[2] + A[2]]

for i in range(3, N):
    if (i + 1) % 2 == 1:    
        DP_odd = [max(DP_odd[0] + A[i], DP_even[0]), max(DP_odd[1] + A[i], DP_even[1]), DP_odd[2] + A[i]]
    else:
        DP_even = [max(DP_even[0] + A[i], DP_odd[1]), max(DP_even[1] + A[i], DP_odd[2])]

if N % 2 == 1:
    ans = DP_odd[1]
else:
    ans = DP_even[1]

print(ans)

Measured memory_bytes: 31704
from copy import copy, deepcopy
from collections import Counter
from math import sqrt, floor, factorial
from itertools import permutations, combinations, combinations_with_replacement
from operator import mul
from functools import reduce
import bisect

MOD = 10**9 + 7
INF = float('inf')

N = int(input())

A = {2, 4, 5, 7, 9}

if N % 10 in A:
    print("hon")
elif N % 10 == 3:
    print("bon")
else:
    print("pon")


Measured memory_bytes: 9732
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#define PI 3.1415926535897932
using namespace std;

string data[3000];
int c;

bool search(string);
void input(string);
void swap(char *,char *);

int main(){
	string str;
	string str1,str2; //1gariba-su
	int m;
	cin >> m;
	while(m--){
		c=0;
		cin >> str;
		for(int i=1;i<str.size();i++){	//1bunkatu
			str1.assign(str,0,i);
			str2.assign(str,i,str.size()-i);
			if(search(str1+str2)) input(str1+str2); //12??????
			if(search(str2+str1)) input(str2+str1);	//21??????
			for(int j=0;j<(str1.size())/2;j++) swap(&str1[j],&str1[str1.size()-j-1]);//1?????¢
			if(search(str1+str2)) input(str1+str2); //12??????
			if(search(str2+str1)) input(str2+str1); //21??????
			for(int j=0;j<(str2.size())/2;j++) swap(&str2[j],&str2[str2.size()-j-1]);//2?????¢
			if(search(str1+str2)) input(str1+str2); //12??????
			if(search(str2+str1)) input(str2+str1); //21??????
			for(int j=0;j<(str1.size())/2;j++) swap(&str1[j],&str1[str1.size()-j-1]);//1?????¢
			if(search(str1+str2)) input(str1+str2); //12??????
			if(search(str2+str1)) input(str2+str1); //21??????
		}
		cout << c << endl;
	}
	return 0;
}

bool search(string str){
	for(int i=0;i<c;i++){
		if(str==data[i]) return false;	//??????????????°
	}
	return true;	//??????????????°
}

void input(string str){
	data[c]=str;
	c++;
}

void swap(char *a,char *b){
	char w;
	w=*a;
	*a=*b;
	*b=w;
}

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

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

vector<vector<int>> Graph;

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

Graph.resize(N);
  rep(i,M){
    int a,b;
    cin >> a >> b;
    a--,b--;
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }

  vector<pair<ll,int>>dp(N,make_pair(INF,0));

  priority_queue<tuple<ll,int,int> ,  vector<tuple<ll,int,int>>, greater<tuple<ll,int,int>>> que;
  que.push(make_tuple(0,0,-1));

  while(!que.empty()){
    auto p = que.top();que.pop();
    ll cost = get<0>(p);
    int v = get<1>(p);
    int ov = get<2>(p);
    if(dp[v].first <= cost) continue;
    dp[v].first = cost;
    dp[v].second = ov;

    for(auto e: Graph[v]){
      int nv = e;

      if(dp[nv].first > cost+1){

        que.push(make_tuple(cost+1,nv,v));
      }
    }
  }

  bool flg = true;
  rep(i,N){
    if(dp[i].first == INF) flg = false;
  }
  if(!flg){ cout << "No" << endl; return 0;}

  cout << "Yes" <<endl;

  for(int i = 1; i<N; i++){
    cout << dp[i].second+1 <<endl;
  }
  return 0;
}


Measured memory_bytes: 13232
s = gets.strip.split("").map(&:to_i)

s1 = (s[0].to_s+s[1].to_s).to_i
s2 = (s[2].to_s+s[3].to_s).to_i

if 1 <= s1 && s1 <= 12 && 1 <= s2 && s2 <= 12
  puts "AMBIGUOUS"
elsif 1 <= s1 && s1 <= 12
  puts "MMYY"
elsif 1 <= s2 && s2 <= 12
  puts "YYMM"
else
  puts "NA"
end

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

int main(void){
   int i,n,A,Z;
   char str[200001];

   scanf("%s",str);
   n=strlen(str);

   for(i=0;i<n;i++)
      if(str[i]=='A'){A=i;break;}
   for(i=n-1;i>=0;i--)
      if(str[i]=='Z'){Z=i;break;}

   printf("%d\n",Z-A+1);
   return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
	public class Main{
		public static void main(String args[]) {
			Scanner scan=new Scanner(System.in) ;
			int K=scan.nextInt();
			int A=scan.nextInt();
			int B=scan.nextInt();
			int num=0;
			int i=A/K;
			int j=i*K;
			for(int k=j;k<=B;k=k+K) {
				if(k>=A&&k<=B) {
					num=1;
					break;
				}
				else {}
			}
		if(num==0) {	
			System.out.println("NG");
		}
		else {System.out.println("OK");
		}
		}
	}


Measured memory_bytes: 35644
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


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


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };




//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}
/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return (x / tmp) * y;
}


/******************************************************************************************/


int main() {

	string s;
	cin >> s;

	if ((s[0] == s[1] && s[2] == s[3]) || (s[0] == s[2] && s[1] == s[3]) || (s[0] == s[3] && s[1] == s[2])) {
		if (s[0] == s[1] && s[1] == s[2] && s[2] == s[3]) {
			cout << "No" << endl;
		}
		else
		{
			cout << "Yes" << endl;
		}
	}
	else
	{
		cout << "No" << endl;
	}


	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int h = scan.nextInt();
		int c =scan.nextInt();
		long  l = gcd(w,h);
		long k = (w/l) * (h/l);
		System.out.println(k*c);
	}
	private static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}
}



Measured memory_bytes: 26320
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
using namespace std;

void A() {
	string s; cin >> s;
	if (s == "ABC") {
		cout << "ARC" << endl;
	}
	else {
		cout << "ABC" << endl;
	}
}

void B() {
	int N, K; cin >> N >> K;
	vector<int> snuke(N);

	for (int i = 0; i < K; i++) {
		int d; cin >> d;

		for (int j = 0; j < d; j++) {
			int A; cin >> A; A--;
			snuke[A]++;
		}
	}

	int cnt = 0;
	for (int k = 0; k < N; k++) {
		if (snuke[k] == 0) cnt++;
	}

	cout << cnt << endl;
}
int main() {
	B();
}


Measured memory_bytes: 3568
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

int main(){
	long long K;
	cin >> K;
	if (K % 2 == 0) {
		cout << -1 << endl;
		return 0;
	}

	long long X = 1;

	for (int i = 1; i <= 1000000; i++) {
		if (K % 2 == 0 || K % 5 == 0) {
			cout << -1 << endl;
			return 0;
		}
		else if (K % 7 == 0) {
			X = (10 * X) % (9 * K / 7);
			if (X == 1) {
				cout << i << endl;
				return 0;
			}
		}
		else {
			X = (10 * X) % (9 * K);
			if (X == 1) {
				cout << i << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 3548
n, k = gets.chomp.split(' ').map(&:to_i)
sums = Array.new(n + 1, 0)
n.times { |i| sums[i + 1] = sums[i] + i + 1 }
count = 0
mod = (1e9 + 7).to_i
(k..n).each do |i|
  count += sums[n] - sums[n - i] - sums[i - 1] + 1
  count %= mod
end
puts (count + 1) % mod

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);

  ll max_A = 0;
  rep(i, N){
    cin >> A[i];
    chmax(max_A, A[i]);
  }

  ll gcd_A = A[0];

  rep(i, N){
    gcd_A = gcd(gcd_A, A[i]);
  }

  bool ans = true;
  if(K > max_A){
    ans = false;
  }else{
    if (gcd_A == 1)
    {
      ans = true;
    }else{

      if(gcd(gcd_A, K) == 1){
        ans = false;
      }else{
        ans = true;
      }
    }
  }

  if(ans){
    cout << "POSSIBLE" << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }


  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD				1000000007
#define MOD1			998244353
#define EPS				1e-9
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)
int in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int tam = 100010;
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	//freopen("qwe.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n;
	cin>>n;
	pair<pair<int,int>, int> ar[n];
	fore(i, 0 , n) cin>> ar[i].f.f>>ar[i].f.s>>ar[i].s;
	bool bo;
	int x, y, h;
	int po;
	fore(i, 0, 101)
		fore(j, 0, 101)
		{
			bo = true;
			x = i, y = j;
			po = 0;
			while(po < n && ar[po].s == 0)
			{
				po++;
			}
			if(po == n)
			{
				fore(i, 0, 101)
					fore(j, 0, 101)
					{
						fore(k, 0, n)
						{
							if(i != ar[k].f.f || j != ar[k].f.s)
							{
								cout<<i<<' '<<j<<' '<<1<<'\n';
								return 0;
							}
						}
					}
			}
			h = abs(x - ar[po].f.f) + abs(y - ar[po].f.s) + ar[po].s;
			fore(k, 0, n)
			{
				if(ar[k].s == 0)
				{
					if(abs(x - ar[k].f.f) + abs(y - ar[k].f.s) < h)
					{
						bo = false;
						break;
					}
				}
				else if(abs(x - ar[k].f.f) + abs(y - ar[k].f.s) + ar[k].s != h)
				{
					bo = false; break;
				}
			}
			if(bo && h > 0)
			{
				cout<<x<<' '<<y<<' '<<h<<'\n';
				return 0;
			}
		}
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 256
#include<stdio.h>

int main() {
int a,b,c;
int k;
int count=0;
  scanf("%d %d %d", &a, &b, &c);
  scanf("%d", &k);

  while(a>=b) {
    b*=2;
    count++;
  }
  while(b>=c) {
    c*=2;
    count++;
  }

  if (count<=k) printf("Yes");
  else printf("No");

  return 0;
}

Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define LL long long
namespace io {
  template <typename T> inline void read(T &x) {
    bool flag = false;  char c = getchar();
    while ((c < '0' || c > '9') && c != '-')  c = getchar();
    c == '-' ? flag = true, x = 0 : x = c - '0';
    c = getchar();
    while (c >= '0' && c <= '9')  x = (x << 3) + (x << 1) + c - '0', c = getchar();
    if (flag)  x = -x;
  }
  template <typename T> inline void write(T x) {
    char st[10010];
    int cnt = 0;
    if (x < 0)  x = -x, putchar('-');
    if (x == 0)  putchar('0');
    while (x) { st[++cnt] = x % 10 + 48;  x /= 10; }
    while (cnt) { putchar(st[cnt--]); }
  }
}
using namespace io;
string s;
int main() {
    cin >> s;
    int n = s.length();
    bool b[5] = {0};
    for (int i = 0; i < n; ++i) {
        switch (s[i]) {
            case 'N':
                b[1] = true;
                break;
            case 'S':
                b[2] = true;
                break;
            case 'E':
                b[3] = true;
                break;
            case 'W':
                b[4] = true;
                break;
            default:
                break;
        }
    }
    puts((b[1] == b[2] && b[3] == b[4] ? "Yes" : "No"));
	return 0;
}












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

int main()
{
    long long N;
    cin >> N;
    int moji_num = 0;
    long long kumi=0;
    for (int i=1; i<15; i++)
    {
        moji_num++;
        if (N<=kumi+pow(26,i)) break;
        kumi+=pow(26,i);
    }
    //cout << moji_num << endl;
    N -= kumi;
    N--;
    string name="";
    for (int i=0; i<moji_num; i++)
    {
        //cout << N << endl;
        long long q = N/26;
        int r = N%26;

        char moji = 'a';
        for (int j=0; j<r; j++) moji++;

        name = moji + name;

        N = q;
    }
    cout << name << endl;
}

Measured memory_bytes: 4092
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define C                  31
#define mod              1000000007
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  150
#define tmod             998244353
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<ll> &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
//bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n);

int main()
{
fast;
ll q=1,t;
//cin >> q;
while(q--)
{
    ll n,m,k,i,j,l,r,c=1,g,counter=0,u,v,d,e,p,x,y,flag=1;
    //n=m=i=j=l=r=a=t=b=c=u=v=w=p=x=y=0;
    cin >> n; 
    ll ans = (n/500)*1000;
    n %=500;
    ans += (n/5)*5;
    cout << ans;
    
}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = 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 += m0;
    return x;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}

*/

Measured memory_bytes: 256
def main
  n = ARGF.gets.to_i

  nums = ARGF.gets.split.map(&:to_i)

  cnt = n
  exor = 0
  suc_j = 0
  0.upto(n-2) do |i|
    if i+1 <= suc_j
      cnt += suc_j - i
      exor ^= nums[i-1]
    else
      suc_j = i
      exor = nums[i]
    end
    (suc_j+1).upto(n-1) do |j|
      mul = exor & nums[j]
      break if mul != 0

      exor ^= nums[j]   # or でも結果は同じはず
      cnt += 1
      suc_j = j
    end

  end
  puts cnt
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 19332
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;

int main()
{
    int n;
    std::cin >> n;

    for (int i = 0; i < n; i++) {
        char c;
        std::cin >> c;

        if (c == 'Y') {
            std::cout << "Four" << std::endl;
            return 0;
        }
    }

    std::cout << "Three" << std::endl;
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,l;
    cin >> n;
    vector<int> x(n),d[n];
    for (int i = 0;i < n;++i) cin >> x[i];
    cin >> l;
    {
        int j = 1;
        for (int i = 0;i < n;++i) {
            while (j < n-1 && x[j+1]-x[i] <= l) j++;
            if (i != n-1) d[i].push_back(j);
        }
    }
    for (int i = 0;i < 20;++i) {
        for (int j = 0;j < n;++j) {
            if (d[j].size() == i+1 && d[d[j][i]].size() == i+1) d[j].push_back(d[d[j][i]][i]);
            else break;
        }
    }
    int q;
    cin >> q;
    for (int i = 0;i < q;++i) {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        if (a > b) swap(a,b);
        int ans = 0;
        while (a < b) {
            for (int j = d[a].size()-1;j >= 0;--j) if (d[a][j] <= b || j == 0) {
                ans += 1<<j;
                a = d[a][j];
                break;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main(){

    double l;

    cin >> l;

    double a = l / 3;
    double b = (l - a) / 2;
    double c = l - a - b;
    
    printf("%.12f\n", a * b * c);

    return 0;
} 


Measured memory_bytes: 3736
//package com.zhangyong.algorithm;

import java.io.*;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {

    FastScanner in;
    PrintWriter out;

    class FastScanner {

        BufferedReader br;
        StringTokenizer st;

        private FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        private FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

    }

    class cmp implements Comparator<String> {

        @Override
        public int compare(String o1, String o2) {
            return o1.compareTo(o2);
        }
    }

    private void solve() {

        int n, l;
        n = in.nextInt();
        l = in.nextInt();
        String[] str = new String[n];
        for (int i = 0; i < str.length; i++) {
            str[i] = in.next();
        }
        Arrays.sort(str, new cmp());
        for (int i = 0; i < str.length; i++) {
            out.print(str[i]);
        }
    }

    private void run() {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

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


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trii(x) cerr<<#x<<": ("<<x.F<<","<<x.S<<")\n";
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define triiset(s) cerr<<#s<<": ";for(auto &i:s) trii(i);
#define epsilon 0.000000001L
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define modulo 998244353ll

int main()
{
    fast();
    ll a,b;
    cin>>a>>b;
    for(ll i=1;i<=3;i++)
    {
        if(i!=a && i!=b)
            cout<<i<<nl;
    }
}


Measured memory_bytes: 256
def selectionSort(a, n):
    c = 0
    for i in range(n):
        minj = i
        for j in range(i, n):
            if a[j] < a[minj]:
                minj = j
        a[i], a[minj] = a[minj], a[i]
        if minj != i:
            c += 1

    return a, c

if __name__ == "__main__":
    n = int(input())
    a_l = [int(a) for a in input().split()]

    as_l, c = selectionSort(a_l, n)
    print(' '.join(map(str, as_l)))
    print(c)

Measured memory_bytes: 7768
#include <stdio.h>


int main(){

    int x;
    int a, b, c;

    scanf("%d\n%d\n%d\n", &a, &b, &c);
    scanf("%d", &x);
    int ans = 0;

    for (int i = 0; i <= a; i++){
        for (int j = 0; j <= b; j++){
            for (int k = 0; k <= c; k++){
                if(x == 500 * i + 100 * j + 50 * k ) ans++;
            }
        }
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
/**
 *    author:  FromDihPout
 *    created: 2020-05-26
**/

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

const int INF = 1e9;
const vector<pair<int,int>> adj = {{1,0}, {-1,0}, {0,1}, {0,-1}};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    set<pair<int,int>> visited;
    for (int i = 0; i < h; i++) {
        cin >> grid[i];
    }
    
    int max_dist = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (grid[i][j] == '#') continue;
            vector<vector<int>> dp(h, vector<int> (w, INF));
            dp[i][j] = 0;
            visited.clear();
            queue<pair<int,int>> next;
            next.push({i, j});
            
            while (!next.empty()) {
                pair<int,int> coord = next.front();
                next.pop();
                max_dist = max(max_dist, dp[coord.first][coord.second]);
                if (visited.count(coord)) continue;
                visited.insert({coord.first, coord.second});
                
                for (auto a : adj) {
                    int x = coord.first + a.first;
                    int y = coord.second + a.second;
                    if (x >= 0 && x < h && y >= 0 && y < w && grid[x][y] == '.') {
                        dp[x][y] = min(dp[x][y], dp[coord.first][coord.second] + 1);
                        next.push({x,y});
                    }
                }
            }
        }
    }
    
    cout << max_dist << '\n';
}

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

int main(){
    using namespace std;

    unsigned long N;
    cin >> N;

    vector<unsigned long> A(N), B(N);
    for(auto&& i : A)cin >> i;
    for(auto&& i : B)cin >> i;
    unsigned long t{static_cast<unsigned long>(max_element(begin(A), end(A)) - begin(A))};
    rotate(begin(A), begin(A) + t, end(A));
    rotate(begin(B), begin(B) + t, end(B));
    A.push_back(A[0]);
    B.push_back(B[0]);

    vector<unsigned long> C(N + 1);
    C[0] = 10000000000000;
    C[1] = 10000000000000;

    for(unsigned long i{2}; i <= N; ++i)C[i] = 2 * C[i - 1] - 2 * B[i - 1] - C[i - 2];

    for(unsigned long i{0}; i <= N; ++i)A[i] += C[i] -= C.back();

    vector<unsigned long> convex_hull{0, 1};
    const auto& is_convex = [&A](unsigned long i, unsigned long j, unsigned long k) -> bool {
        return j * A[k] + k * A[i] + i * A[j] < j * A[i] + k * A[j] + i * A[k];
    };
    for(unsigned long i{2}; i < N + 1; ++i){
        while(convex_hull.size() >= 2 && !is_convex(convex_hull.end()[-2], convex_hull.end()[-1], i))convex_hull.pop_back();
        convex_hull.push_back(i);
    }
    unsigned long ans{0};
    for(unsigned long i{0}; i + 1 < convex_hull.size(); ++i)ans += (convex_hull[i + 1] - convex_hull[i] + 1) * A[convex_hull[i]] + (convex_hull[i + 1] - convex_hull[i] - 1) * A[convex_hull[i + 1]];

    printf("%.12Lf\n", (ans - 2 * accumulate(C.begin(), C.end(), 0UL)) / (2.0L * N));

    return 0;
}

Measured memory_bytes: 11496
import java.util.*;
import java.io.*;

public class Main {
	final static int MOD = 1000000007;
	final static int intMax = 1000000000;
	final static int intMin = -1000000000;
	final static int[] dx = { 0, 0, -1, 1 };
	final static int[] dy = { -1, 1, 0, 0 };

	static int T;

	static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[360]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}
	
	public static void main(String[] args) throws Exception {
		Reader in = new Reader();
		int N = in.nextInt();
		int W = in.nextInt();
		int[] w = new int[N];
		int[] v = new int[N];
		for(int i = 0; i < N; ++i) {
			w[i] = in.nextInt();
			v[i] = in.nextInt();
		}
		long[] dp = new long[W + 1];
		for(int i = 0; i < N; ++i) {
			for(int j = W - w[i]; j >= 0; --j) {
				dp[j + w[i]] = Math.max(dp[j + w[i]], dp[j] + v[i]);
				if(dp[j + w[i]] == 100 )System.out.println(i + " " + j);
			}
		}
		long mx = 0;
		for(int i = 0; i <= W; ++i) {
			mx = Math.max(mx, dp[i]);
		}
		System.out.println(mx);
		in.close();
	}
}

Measured memory_bytes: 34152