akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;scanf("%d",&N);
    char S[N];scanf("%s",S);
    int ans=0;
    for(int i=0;i<1000;i++){
        int now=0;
        for(int j=0;j<N;j++){
            if(now==0){
                if(S[j]-'0'==i/100)now++;
            }
            else if(now==1){
                if(S[j]-'0'==i/10%10)now++;
            }
            else if(now==2){
                if(S[j]-'0'==i%10)now++;
            }
            else break;
        }
        if(now==3)ans++;
    }
    printf("%d\n",ans);
    return 0;
}

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

int main(){
  int a[5];
  for (int i = 0; i < 5; i++){
    cin >> a[i];
    if (a[i]==0){
      cout << i+1 << endl;
      break;
    }
  }
  return 0;
}


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

/*If you are going to try,keep going until the end ,or don't even try to start*/

/* Remember, Hope is a good thing... May be the best of things... And No Good thing ever Dies !!!*/

using namespace std;

#define ll long long
#define nada "\n"
#define st string
#define S  second
#define F  first
#define pb push_back
#define MP make_pair
#define isnttriangle(a,b,c)  (a+b<c||a+c<b||b+c<a)
#define todegree(rad) rad*(180.0/pi)
#define rrp(i, a, b)  for(ll i = a; i >= b; i--)
#define repp(i,a,b)   for (int i = int(a); i <=int(b); i++)
#define rep(i, n)     for (int i = 0; i <n; i++)
#define rep1(i,n)     for (int i = 1; i <=n; i++)
#define allr(v)       ((v).rbegin()), ((v).rend())
#define all(v)        ((v).begin()),((v).end())
#define fx(n)         cout<<fixed<<setprecision(n);
#define sz(v)         ((int)(v).size())
#define Test          ll t;cin>>t;while(t--)
#define mod           1000000009LL


const double ME = 2.71828;
const int    N  = 3e5 + 20;
const int   inf = 0x3f3f3f3f;
const double pi = 3.141592653;




void LOSER()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

void file()
{
    freopen("records.in", "r", stdin);
    //freopen("text.out", "w", stdout);
}

ll gcd(ll a, ll b)
{
    //Eculidean Algorthim
    return (!b) ? a : gcd(b, a % b);
    //complixty=log(ab);
}

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

ll Fib_recur(ll n)
{
    vector<ll>v(n+5,0);
    //BaseCase
    v[1]=0;
    v[2]=1;
    repp(i,3,n)v[i]=v[i-1]+v[i-2];
    return v[n];
}

bool isprime(int n)
{
    for(int i = 2; i <= sqrt(n); i++)
    {
        if(n%i == 0)
            return false;
    }
    return true;
}

void Solve()
{
 int n,k,cnt=0;
 cin>>n>>k;
 vector<int>v(n);

 for(auto&i:v)cin>>i;
 sort(all(v));
 rep(i,k)
 {
     cnt+=v[i];
 }
 cout<<cnt;

}






int main()
{
    // fx(7)
    //file();
    LOSER();
    //Test

    Solve();







}


Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int H, W, N;
map<P, int> C;
long long T[10];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> H >> W >> N;
  rep(i, N) {
    int x, y;
    cin >> y >> x;
    for (int dx=-1; dx<=1; dx++) {
      for (int dy=-1; dy<=1; dy++) {
        int nx = x+dx, ny = y+dy;
        if (nx<=1 || nx>W-1 || ny<=1 || ny>H-1) continue;
        C[P(nx, ny)]++;
      }
    }
  }
  long long s = 0;
  for (auto &p : C) {
    T[p.second]++;
    s++;
  }
  T[0] = 1LL*(H-2)*(W-2) - s;
  rep(i, 10) cout << T[i] << "\n";
  return 0;
}


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

#define rep(i, x, y) for(int i = (x), _ = (y); i <= _; ++ i)
#define per(i, x, y) for(int i = (x), _ = (y); i >= _; -- i)
#define dprintf(...) fprintf(stderr, __VA_ARGS__)
#define disp(x) cout << #x << " = " << x << "; "

typedef long long LL;

template <class T> bool chkmin(T& a, T b) { return a > b ? a = b, true : false; }
template <class T> bool chkmax(T& a, T b) { return a < b ? a = b, true : false; }

template <class T> void read(T& a) {
	char c = getchar(); 
	T f = 1; 
	a = 0;
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) a = a * 10 + c - '0';
	a *= f;
}
/*}}}*/

const int maxN = 2e5 + 5;

char s[maxN];
LL fib[100];
int fail[maxN];
int lens, lent;
LL ansl[26], ansr[26]; 
int sums[26], sumt[26];
LL L, R;

void getans(LL Bnd, LL ans[])
{
	if(Bnd < lens)
	{
		rep(i, 1, Bnd) ans[s[i] - 'a']++;
		return;
	}
	rep(i, 0, 90)
	{
		if(fib[i] * lent + fib[i + 1] * lens > Bnd)
		{
			rep(j, 0, 25) ans[j] += fib[i - 1] * sumt[j] + fib[i] * sums[j];
			getans(Bnd - fib[i - 1] * lent - fib[i] * lens, ans);
			return;
		}
	}
}

int main()
{
#ifdef Leeson
	freopen("tmp.in", "r", stdin);
	freopen("tmp.out", "w", stdout);
#endif

	fib[0] = 0; fib[1] = 1;
	rep(i, 2, 90) fib[i] = fib[i - 1] + fib[i - 2];
	scanf("%s", s + 1);
	lens = strlen(s + 1) >> 1;
	fail[0] = fail[1] = 0;
	rep(i, 2, lens)
	{
		int tmp = fail[i - 1];
		while(tmp && s[tmp + 1] != s[i]) tmp = fail[tmp];
		fail[i] = s[tmp + 1] == s[i] ? tmp + 1 : 0;
	}
	lent = lens - fail[lens];
	rep(i, 1, lent) sumt[s[i] - 'a']++;
	rep(i, 1, lens) sums[s[i] - 'a']++;
	read(L), read(R);
	getans(R, ansr);
	getans(L-1, ansl);
	rep(i, 0, 25) printf("%lld ", ansr[i] - ansl[i]);

	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int N;
  cin >> N;
  int ans = 0;
  vector<int> hana(N+1);
  hana.at(0) = 0;
  for(int i = 1;i<N+1;i++){
    cin >> hana.at(i);
    if(hana.at(i-1) < hana.at(i)){
      ans = ans + hana.at(i) - hana.at(i-1);
    }
  }

  cout << ans << endl;
}

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

using namespace std;

const int maxn = 1e5 + 20;
long long int n, a[maxn][2], sum;

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i][0] >> a[i][1];
    for (int i = n - 1; i >= 0; i--)
    {
        a[i][0] += sum;
        sum += ((a[i][0] + a[i][1] - 1) / a[i][1]) * a[i][1] - a[i][0];
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef int64_t i64;

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

  int d = a-b;
  if(c <= d) cout << 0 << endl;
  else cout << (c-d) << endl;

  return 0;
}


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;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

ll N, M;
vector<ll> A;
vector<ll> sum;

int main() {
    cin >> N >> M;
    A.resize(N);
    rep(i, N) cin >> A[i];
    sum.resize(N + 1);
    sum[0] = 0;

    rep(i, N) {
        sum[i + 1] = (sum[i] + A[i]) % M;
    }

    // rep(i, N + 1) {
    //     cout << sum[i] << endl;
    // }
    map<ll, ll> mp;

    rep(i, N + 1) {
        mp[sum[i]]++;
    }

    ll ans = 0;
    for (auto m : mp) {
        // cout << m.first << " " << m.second << endl;
        ll tmp = m.second * (m.second - 1) / 2;
        ans += tmp;
    }

    cout << ans << endl;
}

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

int main() {
    int a, b, k; cin >> a >> b >> k;
	int k1 = k, i = a;
	for (i; k1-- && i <= b; ++i)
		cout << i << "\n";
	int s = b - k + 1;
	s = max(s, i);
	for (s; s <= b; ++s)
		cout << s << "\n";
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

void solve()
{
	int weight[10];
	int c = 1;
	for(int i = 0; i < 10; ++i)
	{
		weight[i] = c;
		c *= 2;
	}
	int w;
	while(cin >> w)
	{
		bool useWeight[10] = {false};
		int lastPoint = 0;
		for(int i = 9; i >= 0; --i)
		{
			if(w >= weight[i])
			{
				w -= weight[i];
				useWeight[i] = true;
				if(lastPoint < i)
				{
					lastPoint = i;
				}
			}
		}
		for(int i = 0; i < lastPoint; ++i)
		{
			if(useWeight[i])
			{
				cout << weight[i];
				cout << " ";
			}
		}
		cout << weight[lastPoint] << endl;
	}
}

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

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i;
		int[] new_dice = new int[6];
		DICE d = new DICE();
		try (Scanner sc = new Scanner(System.in)) {
			for(i = 0; i < 6; i++) {
				d.Dice(i, sc.nextInt());
			}
			
			String direction = sc.next();
			for(i = 0; i < direction.length(); i++) {
				new_dice = d.rotation(direction.substring(i, i + 1));
			}
			System.out.println(new_dice[0]);
		}
	}
}
class DICE{
	private int[] dice = new int[6];
	public void Dice(int i, int dice_spot){
		dice[i] = dice_spot;
	}
	public int[] rotation(String direction) {
		switch(direction) {
		case "E": dice = new int[] {dice[3],dice[1],dice[0],dice[5],dice[4],dice[2]};break;
		case "N": dice = new int[] {dice[1],dice[5],dice[2],dice[3],dice[0],dice[4]};break;
		case "S": dice = new int[] {dice[4],dice[0],dice[2],dice[3],dice[5],dice[1]};break;
		case "W": dice = new int[] {dice[2],dice[1],dice[5],dice[0],dice[4],dice[3]};break;
		default : dice = new int[] {};break;
		}
		return dice;
	}
}



Measured memory_bytes: 26216
#include <iostream>
#include <string>
#include<math.h>
using namespace std;
int main()
{
    int N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;
    int a[N];
    bool stone = false;
    string result;
    bool end = false;
    bool cont3 = false;
    int non_stone_cnt = 0;
    for(int i = 0; i < N; i++){
      char c;
      cin >> c;
      if(c == '.'){
        a[i] = 0;
        stone = false;
        non_stone_cnt++;
        if(non_stone_cnt >= 3 && i <= D && i > B - 1){
          cont3 = true;
        }
      }
      else if(c == '#'){
        a[i] = 1;
        if(stone && A - 1 < i && i <= D - 1){
          result = "No";
          end = true;
          break;
        }
        non_stone_cnt = 0;
        stone = true;
      }
    }

    if(!end){
      if(C >= D && !cont3){
          result = "No";
      }
      else{
        result = "Yes";
      }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;




int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i, 0, n) {
		cin >> v[i];
	}

	int ans = 0;
	for (int i = 100; i >= 1; i--) {
		int last = -1;
		for (int j = 0; j < n; j++) {
			if (v[j] == i) {
				v[j]--;
				if (last == -1 || j != last+1) {
					ans++;
				}
				last = j;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include <math.h>//pow(x,y)=x^y
#include <algorithm>//sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(i,n) for (int i=0; i <(n);i++)
#define ll long long
#define rev(s) reverse(s.begin(),s.end())
#define sor(v) sort(v.begin(),v.end())

using namespace std;


int main() {
int x;
int q;
cin >> x;

if(x < 600){
q = 8;
}else if(600<=x && x<800){
q = 7;
}else if(800<=x && x<1000){
q = 6;
}else if(1000<=x && x<1200){
q = 5;
}else if(1200<=x && x<1400){
q = 4;
}else if(1400<=x && x<1600){
q = 3;
}else if(1600<=x && x<1800){
q = 2;
}else if(1800<=x && x<2000){
q = 1;
}
cout << q <<endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<functional>
#include<vector>
using namespace std;

long long a,b;
typedef pair<long long,long long> P;

bool sortp(const P& a,const P&b){
	return a.first<b.first;
}
long long digits(long long a){
	for(long long i=0;;i++){
		if(!(a>>=1))
			return i;
	}
}
long long booldigits(long long& a,long long b){
	return (a&((long long) 1)<<b);
}

long long xorbits(long long a){
	long long num=digits(a);
	long long ans=0;
	for(long long i=0;i<num+1;i++)
	{
		long long bits=0;
		bits+=a>>(i+1);
		bits*=(((long long) 1)<<i );
		if(booldigits(a,i))
		{
			bits+=(a-((a>>i)<<i)+1);
		}
		//cout<<bits<<' ';
		if(bits%2)
			ans+=(((long long)1)<<i);
	}
	return ans;
}

int main()
{
	cin>>a>>b;//b>a
	cout<<(xorbits(b)^xorbits(a>0?a-1:0))<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define llint long long
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    if(n < 1000) cout << "ABC" << endl;
        else cout << "ABD" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    ll N; cin >> N;
    vector<ll> a(N);
    rep(i, N) cin >> a.at(i);

    ll ans = 0;
    rep(i, N) ans += a.at(i);
    cout << ans - N << endl;
}

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

int main(){
    double a,b,p,q,r;
    cin>>a>>b>>p>>q>>r;
    double x=b*p-(b-a)*q;
    cout<<b+x/(r+q)<<endl;
}


Measured memory_bytes: 3280
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int h1,m1,h2,m2,k;
    cin >> h1>>m1>>h2>>m2>>k;
    // int oki;
        cout << (h2-h1)*60+(m2-m1)-k << endl;
    
    return 0;
}

Measured memory_bytes: 3612
from sys import stdin
a,b = map(int,stdin.readline().split())
def get(n):
    x = []
    x.append(n/3)
    n = n-n/3
    x.append(n/2)
    x.append(n-n/2)
    return x
x = get(a)
x.sort()
y = get(b)
y.sort()
ans = []
ans.append(b*(x[-1]-x[0]))
ans.append(a*(y[-1]-y[0]))
h = a
w = b
if h > 1:
    for i in xrange(1,h):
        rem = h-i
        fir = [i*w, (h-i)*(w/2), (h-i)*(w-w/2)]
        fir.sort()
        ans.append(fir[-1]  - fir[0])
h = b
w = a
if h > 1:
    for i in xrange(1,h):
        rem = h-i
        fir = [i*w, (h-i)*(w/2), (h-i)*(w-w/2)]
        fir.sort()
        ans.append(fir[-1]  - fir[0])
ans.sort()
print ans[0]


Measured memory_bytes: 9852
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>


int main(void)
{
    int64_t A, B;
    std::cin >> A >> B;

    if (B == 1) {
        std::cout << 0 << std::endl;
        return 0;
    }

    B -= A;
    A--;

    int64_t count = 1;
    while (B > 0) {
        B -= A;
        count++;
    }

    std::cout << count << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct w
{
    int c,t;
} e[1010];
bool cmp(w a,w b)
{
    return a.c<b.c;
}
int main()
{
   int n,t;
   scanf("%d%d",&n,&t);
   for(int i=1;i<=n;i++)
   {
       scanf("%d%d",&e[i].c,&e[i].t);
   }
   sort(e+1,e+1+n,cmp);
   for(int i=1;i<=n;i++)
   {
       if(e[i].t<=t)
       {
           printf("%d\n",e[i].c);
           return 0;
       }
   }
   printf("TLE\n");
    return 0;
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}


void pre(){



}


unordered_map<int,int> factor(int n){

    unordered_map<int,int> f;
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            while(n%i==0){
                f[i]++;
                n/=i;
            }
        }
        if(n==1)break;
    }
    if(n>1)f[n]++;
    return f;
}

void solve(){

    int n;
    cin >> n;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    unordered_map<int,int> tot;
    for(int i=1;i<=n;i++){
        unordered_map<int,int> cur = factor(a[i]);
        for(auto it : cur){
            tot[it.ff] = max(tot[it.ff] , it.ss);
        }
    }

    long long  lcm=1;
    for(auto it : tot){
        lcm *= fast(it.ff,it.ss);
        lcm %= mod;
    }

    long long ans=0;
    for(int i=1;i<=n;i++){
        ans += (lcm*inv(a[i]))%mod;
        ans %= mod;
    }
    cout << ans ;

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 4060
let sorted_string = function
  | 0 :: [0] -> None
  | x :: [y] when x <= y -> Some ((string_of_int x) ^ " " ^ (string_of_int y))
  | x :: [y] when x > y -> Some ((string_of_int y) ^ " " ^ (string_of_int x))
  | _ -> None;;

let rec loop () =
  read_line()
  |> Str.split (Str.regexp " ")
  |> List.map int_of_string
  |> sorted_string
  |> function | None -> ()
              | Some x -> print_endline x;
                loop();;

loop()



Measured memory_bytes: 4292
#include<stdio.h>
int main()
{
	int a, a_min =2001, b, b_min = 2001;
	for (int i = 1; i <= 3; i++) {
		scanf("%d", &a);
		if (a < a_min) {
			a_min = a;
		}
	}
	for(int i=1;i<=2;i++){
		scanf("%d", &b);
		if (b < b_min) {
			b_min = b;
		}

	}
	printf("%d\n", a_min + b_min-50);
}

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  char c; cin >> c;
  if(c=='a' or c=='e' or c=='i' or c=='o' or c=='u'){
    cout << "vowel\n";
  } else {
    cout << "consonant\n";
  }
  return 0;
}

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

int main(){
    const int K = 38;
    const int N = K + (K-1)*(K-1);
    int A[K-1][K];
    for(int i=0; i<K-1; i++) for(int j=0; j<K; j++) A[i][j] = i*K+j+1;

    vector<vector<int>> ans;
    for(int j=0; j<K; j++){
        vector<int> res;
        for(int i=0; i<K-1; i++) res.push_back(A[i][j]);
        res.push_back(N);
        ans.push_back(res);
    }
    for(int r=0; r<K-1; r++) for(int i=0; i<K-1; i++){
        vector<int> res;
        for(int j=0; j<K-1; j++) res.push_back(A[(i+j*r)%(K-1)][j]);
        res.push_back(A[r][K-1]);
        ans.push_back(res);
    }

    cout << N << " " << K << endl;
    for(auto& v : ans){
        for(int i=0; i<K; i++){
            cout << v[i] << " \n"[i==K-1];
        }
    }

    // cout << flush;
    // assert(ans.size() == N);
    // map<int, int> cnt;
    // for(auto& v : ans){
    //     assert(v.size() == K);
    //     set<int> st;
    //     for(int i=0; i<K; i++){
    //         assert(1 <= v[i] && v[i] <= N);
    //         assert(!st.count(v[i]));
    //         st.insert(v[i]);
    //         cnt[v[i]]++;
    //     }
    // }
    // for(auto& p : cnt) assert(p.second == K);
    // for(int i=0; i<N; i++) for(int j=0; j<i; j++){
    //     map<int, int> num;
    //     for(int a : ans[i]) num[a]++;
    //     for(int a : ans[j]) num[a]++;
    //     int dub = 0;
    //     for(auto& p : num) if(p.second == 2) dub++;
    //     assert(dub == 1);
    // }

    return 0;
}


Measured memory_bytes: 768
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,k = mi()
aa = [[]for _ in range(k)]
for i in range(k):
    d = ii()
    aa[i] = li()

dp = [0]*(n+1)
dp[0] = 1
for i in range(k):
    for l in aa[i]:
        dp[l] = 1
ans = 0
for i in range(n+1):
    if dp[i] == 0:
        ans += 1
print(ans)




Measured memory_bytes: 67844
s = input()
cA = 0
cB = 0
cC = 0
for i in s:
    if i == "a":
        cA+=1
    elif i == "b":
        cB +=1
    elif i == "c":
        cC +=1
    else:
        pass
if cA == 1 and cB==1 and cC == 1:
    print('Yes')
else:
    print('No')

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

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

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

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

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

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

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

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    ll ma = 0, ma2 = 0;
    REP(i, n) {
        if(ma <= a[i]) {
            ma2 = ma;
            ma = a[i];
        } else if(ma2 < a[i]) {
            ma2 = a[i];
        }
    }

    REP(i, n) {
        if(a[i] == ma) cout << ma2 << endl;
        else cout << ma << endl;
    }

    return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <math.h> 
using namespace std;
int main(){
  string s;
  cin >> s;
  int counter = 0;
  for(int i = 0; i < 3; i++){
    if(s[i] == 'o') counter++;
  }
  cout << 700 + 100*counter << endl;
}

Measured memory_bytes: 768
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
 
public class Main {
	public static void main(String[] args) {
		execute();
	}
 
	private static void execute() {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			String s = sc.next();
			
			Set<Integer> first = new HashSet<>();
			long ans = 0;
			for(int x=0; x<n-2; x++) {
				if(first.contains((int)s.charAt(x))) {
					continue;
				}
				first.add((int)s.charAt(x));
				Set<Integer> second = new HashSet<>();
				for(int y=x+1; y<n-1; y++) {
					if(second.contains((int)s.charAt(y))) {
						continue;
					}
					second.add((int)s.charAt(y));
					Set<Integer> third = new HashSet<>();
					for(int z=y+1; z<n; z++) {
						if(third.contains((int)s.charAt(z))) {
							continue;
						}
						third.add((int)s.charAt(z));
						ans++;
					}
				}
			}
			
			System.out.println(ans);
			
		}
	}
}

Measured memory_bytes: 27272
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int n,k,i;
  string s,t;
  cin >> n;
  cin >> s;
  cin >> k;
  t=s.substr(k-1,1);
  for(i=0;i<n;i++)
    if(s.substr(i,1)!=t)
      s.replace(i,1,"*");
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


int main(){fastio
    
    ll a,b;cin>>a>>b;
    if(a>=13)cout<<b<<endl;
    else if(a>=6)cout<<b/2<<endl;
    else cout<<0<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, k, o;
    vector<ll> a, b, c;
    ll z = 1;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> o;
        if (o >= 0) a.push_back(o);
        //else if (o == 0) b.push_back(o);
        else c.push_back(o);
    }
    sort(a.begin(), a.end()); sort(c.begin(), c.end()); reverse(c.begin(), c.end());
    if (n == k) {
        for (int i = 0; i < a.size(); i++) z *= a[i], z %= mod;
        for (int i = 0; i < c.size(); i++) z *= -c[i], z %= mod;
        if (c.size() % 2) z = (mod - z) % mod;
    } else if (a.empty() && k % 2) {
        for (int i = 0; i < k; i++) z = z * -c[i] % mod;
        z = (mod - z) % mod;
    } else if (a.size() == 1 && k % 2 && k + 1 == n && k > 1) {
        for (int i = 0; i < c.size(); i++) c[i] = -c[i];
        c.push_back(a[0]);
        sort(c.begin(), c.end());
        for (int i = 0; i < k; i++) z = z * c[i] % mod;
        z = (mod - z) % mod;
    } else {
        vector<pair<ll, int>> d;
        int e = 0;
        reverse(c.begin(), c.end());
        if (c.size() % 2) c.pop_back();
        for (ll i : a) d.push_back({i, 0});
        for (ll i : c) d.push_back({-i, 1});
        sort(d.begin(), d.end()); reverse(d.begin(), d.end());
        for (int i = 0; i < k; i++) e += d[i].second;
        if (e % 2 == 0) {
            for (int i = 0; i < k; i++) z *= d[i].first, z %= mod;
        } else {
            int u1 = -1, v1 = -1, u2 = -1, v2 = -1;
            for (int i = k - 1; i >= 0; i--) {
                if (d[i].second) {
                    u1 = i;
                    break;
                }
            }
            for (int i = k; i < n; i++) if (!d[i].second) {
                v1 = i;
                break;
            }
            for (int i = k - 1; i >= 0; i--) {
                if (!d[i].second) {
                    u2 = i;
                    break;
                }
            }
            for (int i = k; i < n; i++) if (d[i].second) {
                v2 = i;
                break;
            }
            if ((u2 == -1 || v2 == -1) || (v1 != -1 && u1 != -1 && d[v1].first * d[u2].first > d[v2].first * d[u1].first)) {
                for (int i = 0; i < n; i++) {
                    if (i < k) {
                        if (i != u1) z *= d[i].first, z %= mod;
                    } else {
                        if (i == v1) z *= d[i].first, z %= mod;
                    }
                }
            } else {
                for (int i = 0; i < n; i++) {
                    if (i < k) {
                        if (i != u2) z *= d[i].first, z %= mod;
                    } else {
                        if (i == v2) z *= d[i].first, z %= mod;
                    }
                }
            }
        }
    }
    cout << z;
}


Measured memory_bytes: 10752
#include<iostream>
#include<utility>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	long long int a,b;
	cin>>a>>b;
	long long int c[a],d[a];
	vector<pair<long long,long long>> v(a);
	for(int i=0;i<a;i++){
		cin>>c[i]>>d[i];
		v[i]=make_pair(c[i],d[i]);
	}
	sort(v.begin(),v.end());
	long long int f=0,g=0;
	while(b>0){
		if(b>=v[f].second){
			g+=v[f].first*v[f].second;
			b-=v[f].second;
		}
		else{
			g+=v[f].first*b;
			break;
		}
		f++;
	}
	cout<<g<<endl;
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define int long long
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
signed main(){
  int A,B,C;
  str S,W,T;
  cin>>A>>B>>C;
  if(A<C&&C<B)cout<<"Yes"<<endl;
  else if(A>C&&C>B)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

using namespace std;

int main() {
    unsigned int n;
    cin >> n;

    vector<int> vt(n);
    for (int i = 0; i < n; ++i) {
        cin >> vt[i];
    }

    cout << *max_element(vt.begin(), vt.end()) -
            *min_element(vt.begin(), vt.end()) << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.range;
import std.conv;

void main() {
    string[] input = split(readln());
    long n = to!long(input[0]);
    long m = to!long(input[1]);
    if (n > m) swap(n,m);
    long ans = 0;
    if (n == 1) {
        ans = max(0, m-2);
        if (m == 1) ans = 1;
    } else {
        ans = (n-2)*(m-2);
    }
    writeln(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

ll ans = 1;
ll k;
void get(ll curr, ll par, vector<ll> v[], ll cnt1)
{
    ans*=max(k-cnt1,(ll)0);
    ans%=MOD;
    //cout<<"at "<<curr+1<<" enemies = "<<cnt1<<"\n";
    if(v[curr].size() == 1 && par!=-1)
        return;
    
    ll cnt = 1;
    if(par != -1)
        cnt++;
    
    for(auto it = v[curr].begin();it!=v[curr].end();it++)
    {
        if(*it == par)
            continue;
        get(*it,curr,v,cnt); 
        cnt++;
    }
        
}

int main()
{
   FAST/**/
   
   ll n;
   cin>>n>>k;
   
   vector<ll> v[n];
   for(ll i=0;i<n-1;i++)
   {
       ll a,b;
       cin>>a>>b;
       a--;
       b--;
       
       v[a].pb(b);
       v[b].pb(a);
   }
   
   get(0,-1,v,0);
   cout<<ans;
   
   return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N,K;
cin >> N >> K;

vi A(N);
map<int,int> cnt;
rep(i,N) {
    cin >> A[i];
    cnt[A[i]]++;
}

vector<pii> P = {};

for(auto x : cnt) {
    P.push_back(pii(x.first, x.second));
}
sort(P.begin(), P.end(), [](pii i1, pii i2) { 
    return i1.second > i2.second;
});

int ans = 0;

for(int i = K; i < P.size();i++) {
    ans += P[i].second;
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 12660
#include "bits/stdc++.h"
using namespace std;
long long mod=1e9+7;

long long modpow(long long a,long long p){
    if(p==0)return 1;
    if(p%2==0){
      long long halfP=p/2;
      long long half=modpow(a,halfP);
      return half*half%mod;
    }else{
      return a*modpow(a,p-1)%mod;
    }
}

int main(){
  long long h,w,a,b;
  cin>>h>>w>>a>>b;
  vector<long long> tx(h+w+2);
  vector<long long> fx(h+w+2);
  tx[0]=1;
  fx[0]=1;
  for(long long i=1;i<h+w+2;i++){
    tx[i]=(i*tx[i-1])%mod;
    fx[i]=modpow(tx[i],mod-2);
  }
  long long ans=0;
  for(long long i=0;i+b<w;i++){
    long long x=(h-a-1)+(b+i);
    long long y=(h-a-1);
    long long l=(a-1)+(w-b-1-i);
    long long r=(w-b-1-i);
    ans+=((((tx[x]*fx[y])%mod)*fx[x-y])%mod)*((((tx[l]*fx[r])%mod)*fx[l-r])%mod)%mod;
    ans%=mod;
  }
  ans%=mod;
  cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <string>

using namespace std;

const int CMax = 100002;

int n, A[CMax], ats;
string S;

int main ()
{
    cin >> S;
    if (S.length() > 3 && S[0] == 'Y' && S[1] == 'A' && S[2] == 'K' && S[3] == 'I') {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		
		if (x < 5) {
			System.out.println(0);
			return;
		}
		
		int happy = (x / 500) * 1000;
		happy += ((x % 500) / 5) * 5;
		System.out.println(happy);
	}

}


Measured memory_bytes: 21844
import java.util.Scanner;

/**
 *
 * AOJ Card Game</br>
 *
 * ?????????????????????????????????????????????????????????????????°?????????????????????</br>
 * ?????¨ 1 ??????????????¨??????????¨???? 20 ??\?????????????¢??????? 50% ??\????????¨??????YES???????????§???????????? NO ?????????
 *
 * @author ?????????????????§???
 *
 */
public class Main{

	// ???????????????????????°
	private static final int DECK = 10;
	// ???????????????????????????????¨??????????
	private static final int CARDNUM_SUM = 20;

	/*
	 * ????????°???????????¨?????????????????????
	 */
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {

			// ????????????????????????????????????????????????
			int my_card1 = sc.nextInt();
			int my_card2 = sc.nextInt();

			// ????????????????????????????????????????????????
			int your_card = sc.nextInt();

			// ????????????????????????????¨??????????????¶????????????´??????????´???´???
			int c_draw = 0;

			/*
			 * ??°???????????????????????¬?????????????????????????????????????¨????????????¨????????????
			 */
			for (int c_cnt = 0; c_cnt <= DECK; c_cnt++) {

				if (my_card1 == c_cnt || my_card2 == c_cnt || your_card == c_cnt) {
					continue;
				}
				if ((my_card1 + my_card2 + c_cnt) < CARDNUM_SUM) {
					c_draw++;
				}
			}
			// ?¢????????±??????????????????????
			System.out.println((((double) c_draw) / (DECK - 3)) > 0.5 ? "YES" : "NO");

		} // while?????????????????????
			// ????????????????????????
		sc.close();
	}// ?????????????????????????????????

}// CardGame?????????????????????

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

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (b < a) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  int a, b, t; cin >> a >> b >> t;

  cout << t / a * b << endl;
  
  return (0);
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
using namespace std;
template<typename T>inline void read(T&x)
{
	T f;register char ch;x=0;f=1;
	for(ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=(x*10)+(ch^48);
	x*=f;
}

const int MAXN=2e5+7;

static int n,a[MAXN],b[MAXN];

inline void init()
{
	read(n);
	Rep(i,1,n)read(a[i]),b[i]=a[i];
}

inline void solve()
{
	sort(b+1,b+n+1);
	Rep(i,1,n)if(a[i]<=b[n/2])printf("%d\n",b[n/2+1]);
	else printf("%d\n",b[n/2]);
}

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

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[100005],s1[100005];
    int a;
    scanf("%d",&a);
    scanf(" %s",s1);
    if(a<3200)
    {
        printf("red");
    }
    else
    {
        printf("%s",s1);
    }
    
}

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

bool isprime(int X){
    rep(i,2,X-1){
        if(X%i==0){
            return 0;
        }
    }
    return 1;
}

int main(){
    
    int X;
    cin>>X;
    if(X==1){
        cout<<2<<endl;
        return 0;
    }
    if(X==2){
        cout<<2<<endl;
        return 0;
    }
    if(X==3){
        cout<<3<<endl;
        return 0;
    }

    rep(i,0,500){
        if(isprime(X+i)){
            cout<<X+i<<endl;
            return 0;
        }
    }
    
}




Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int n,a[105];
double cnt;
int ans,ansn=0x7f7f7f7f; 
int main()
{
	fast;
	cin>>n;
	for (int i=0;i<n;i++)
	   cin>>a[i],cnt+=a[i];
	cnt/=n;
	for (int i=0;i<n;i++)
	   if (abs(a[i]-cnt)<abs(ansn-cnt))
	   {
	   	   ans=i;
	   	   ansn=a[i];
	   }
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

#define MAX_N 100000007

long long par[MAX_N];
long long ranka[MAX_N];


void init(long long n)
{
	for(long long i=0;i<n;i++)
	{
		par[i]=i;
		ranka[i]=0;
	}
}

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

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

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

bool same(long long x,long long y)
{
	return find(x)==find(y);
}


int main()
{
	long long n,m,q;
	cin >> n >> m >> q;

	vector<pair<long long,long long> > c0;
	vector<pair<long long,long long> > c1;

	for(long long i=0;i<q;i++)
	{
		long long a,b,c;
		cin >> a >> b >> c;
		if(c==0)
			c0.push_back(make_pair(a,b));
		else
			c1.push_back(make_pair(a,b));
	}

	init(n);

	for(long long i=0;i<c0.size();i++)
	{
		unite(c0[i].first,c0[i].second);
	}

	for(long long i=0;i<c1.size();i++)
	{
		if(same(c1[i].first,c1[i].second))
		{
			cout << "No" << endl;
			return 0;
		}
	}

	set<long long> var;

	for(long long i=0;i<n;i++)
	{
		var.insert(find(i));
	}

	long long node=var.size();

	if(node<3)
	{
		if(c1.size()>0)
			cout << "No" << endl;
		else
		{
			if(m==n-1)
				cout << "Yes" << endl;
			else
				cout << "No" << endl;
		}
		return 0;
	}

	long long cnt=0;

	vector<long long> cntcnt(n,0);
	
	for(long long i=0;i<n;i++)
	{
		cntcnt[find(i)]++;
	}
	for(long long i=0;i<n;i++)
	{
		if(cntcnt[i]>0)
			cnt+=(cntcnt[i]-1);
	}

	long long mn=cnt+(node);
	if(c1.size()>0)
		mn=n;
	else
		mn=n-1;
	long long mx=cnt+(node)*(node-1)/2;
	

	if(m>=mn and m<=mx)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 10096
n = int(input())
r = [int(input()) for _ in range(n)]


max_num = 1 - 10**9
min_num = r[0]
for i in range(1,n):
    max_num = max(max_num, r[i]-min_num)
    min_num = min(min_num, r[i])
print(max_num)


Measured memory_bytes: 13596
#include<stdio.h>
int a[200010],dp[110],n,k;
int min(int a,int b){return a>b?b:a;}
int f(int x){return x>0?x:-x;}
int g(int x){return x%(k+1);}
int main(){
	int i,j;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(i=1;i<=k;i++)dp[g(i)]=f(a[i]-a[0]);
	for(i=k+1;i<n;i++){
		dp[g(i)]=2147483647;
		for(j=1;j<=k;j++)dp[g(i)]=min(dp[g(i)],dp[g(i-j)]+f(a[i]-a[i-j]));
	} 
	printf("%d",dp[g(n-1)]);
	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

typedef std::pair<long, int> P;

int n, m;
long d[500][500];
int c[500][500];
int main(){
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++){
		for(int j = 0; j < m; j++){
			scanf("%ld", &d[i][j]);
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			scanf("%d", &c[i][j]);
		}
	}
	long ans = INF;
	std::vector<P> list[3];
	for(int mod = 0; mod < 3; mod++){
		//printf("mod %d\n", mod);
		for(int col = 0; col < m; col++){
			//printf("  col %d\n", col);
			long res = 0;
			for(int sum = mod; sum < n*2-1; sum += 3){
				if(sum < n){
					int i = sum;
					int j = 0;
					for(; i >= 0; i--, j++){
						res += d[c[i][j]-1][col];
					}
				}
				else{
					int i = n-1;
					int j = sum-i;
					for(; j < n; i--, j++){
						res += d[c[i][j]-1][col];
					}
				}
			} 
			//printf("    (%ld, %d)\n", res, col);
			list[mod].push_back(P(res, col));
		}
		std::sort(list[mod].begin(), list[mod].end());
	}
	/*
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < list[i].size(); j++){
			printf("(%ld, %d), ", list[i][j].first, list[i][j].second);
		}
		printf("\n");
	}
	//*/
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if(
				list[0][i].second == list[1][j].second ||
				list[1][j].second == list[2][k].second ||
				list[2][k].second == list[0][i].second){
					continue;
				}
				if(ans > list[0][i].first + list[1][j].first + list[2][k].first){
					//printf("%d %d %d\n", i, j, k);
					ans = list[0][i].first + list[1][j].first + list[2][k].first;
				}
			}
		}
	}
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 1280
/*
 * atcoder/abc112_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * a_1 + a_2 + ... + a_N = M
 * を満たす正整数列aの最大公約数の最大値を求める問題.
 * d = GCD(a_1, a_2, ..., a_N)とおく.
 * 任意のa_nがdの倍数なので、任意のa_nをb_n * d^c_nと表せる.
 * よって、sum(a_n) はd * (b_1 * d^(c_1-1) + b_2 * d^(c_2-1) + ... + b_N * d^(c_N-1))と表せる.
 * したがって、Mはdの倍数である <=> a_nの最大公約数はMの約数である.
 *
 * 次にMの約数のうち最大のものをもとめる.
 * Mの約数をdとおく.
 * d * (N-1) + (M - d * (N - 1)) = Mと構築できるのは、
 * a_n >= dより、M - d * (N - 1) >= dの時.
 * - d * (N - 1) - d >= - M
 *   d * (N - 1) + d <= M
 *   d * N <= M
 *
 * 最後に、
 * d * N <= Mを満たす時、M - d * (N - 1)がdの倍数であることを示す.
 * Mはdの倍数より、d * L - d * (N - 1)と表せる.
 * d * (L - N - 1)
 * dの積の形で表せたのでM - d * (N - 1)はdの倍数である.
 *
 * 以上より、求める最大公約数はMの約数dのうちdN <= Mを満たす最大のdと等しい.
 *
 * 実装について
 * Mが10^9とやや大きいので約数列挙にはsqrt(M)のアルゴリズムを使用する.
 */
ll N, M;
void solve() {
  cin >> N >> M;
  vector<ll> D;
  for (int i=1; i*i<=M; i++) {
    if (M%i==0) {
      D.push_back(i);
      if (i*i != M) D.push_back(M/i);
    }
  }

  ll max_ = 0;
  for (auto&&d: D) {
    if (d * N > M) continue;
    chmax(max_, d);
  }
  cout << max_ << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


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

const int M = 402;
const int N = 100002;
int n, m, X_[N], Y_[N];
bool valid[M], killed[M][M];

signed main(){
 
   //  freopen("input10.txt","r",stdin);
   // freopen("output10.txt","w",stdout);

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>m>>n;
    for(int i=1;i<=n;i++)
    	cin>>X_[i]>>Y_[i];

    for(int i=1;i<=m;i++){
    	killed[i][i] = true;
    	valid[i] = true;
    	for(int j=n;j>=1;j--)
    		if(killed[i][X_[j]] && killed[i][Y_[j]]){
    			valid[i] = false;
    			break;
    		}
    		else if(killed[i][X_[j]])
    			killed[i][Y_[j]] = true;
    		else if(killed[i][Y_[j]])
    			killed[i][X_[j]] = true;
    }


    int ans = 0;
    for(int i=1;i<=m;i++)
    	for(int j=i+1;j<=m;j++)
    		if(valid[i] && valid[j]){
    			bool good = true;
    			for(int k=1;k<=m;k++)
    				if(killed[i][k] && killed[j][k])
    					good = false;
    			ans += good;
    		}

    cout<<ans;
    return 0;
}




 



Measured memory_bytes: 2048
import numpy as np

N, Q = map(int, input().split())
S = np.zeros(N+1, dtype="S1")
S[1:] = list(input())

A = (S == b'A')
C = (S == b'C')
AC = (A[:-1] & C[1:]) # Aが右、Cが左になる形
AC_cum = list(AC.cumsum())

for _ in range(Q):
  l, r = map(int, input().split())
  print(AC_cum[r-1] - AC_cum[l-1])
  



Measured memory_bytes: 19516
#include<bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;
 
const int N=2e5+5;
int n,a[N],b[N],cnt[N],dem[N],res[N];
set<pii>pq;
vector<int>pos[N];
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
    }
    for(int i=1;i<=n;i++)
    {
        cin>>b[i];
        cnt[b[i]]++;
        dem[b[i]]++;
    }
    for(int i=1;i<=n;i++) if(dem[i]) pq.insert(mp(cnt[i],i));
    for(int i=1;i<=n;i++)
    {
        int id=(*pq.rbegin()).se;
        pq.erase(mp(cnt[id],id));
        if(id==a[i])
        {
            if(pq.empty()) return cout<<"No",0;
            id=(*pq.rbegin()).se;
            pq.erase(mp(cnt[id],id));
            pq.insert(mp(cnt[a[i]],a[i]));
        }
        pq.erase(mp(cnt[id],id));
        dem[id]--;
        cnt[id]--;
        if(dem[a[i]]) pq.erase(mp(cnt[a[i]],a[i]));
        cnt[a[i]]--;
        if(dem[id]) pq.insert(mp(cnt[id],id));
        if(dem[a[i]]) pq.insert(mp(cnt[a[i]],a[i]));
        res[i]=id;
    }
    cout<<"Yes"<<'\n';
    for(int i=1;i<=n;i++) cout<<res[i]<<' ';
}

Measured memory_bytes: 21452