akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int s,a,b;cin>>s;
  a=s/100;
  b=s%100;
  if(a>0&&a<13){
    if(b>0&&b<13)cout<<"AMBIGUOUS"<<endl;
    else cout<<"MMYY"<<endl;
  }
  else{
    if(b>0&&b<13)cout<<"YYMM"<<endl;
    else cout<<"NA"<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <map>
const int MOD = 1e9+7;
using namespace std;


int main(){
	int n, m;
	cin >> n >> m;
	if (n == m) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int n ;
  scanf("%d",&n) ;

  char s[100], t[100] ;
  scanf("%s", s) ;
  scanf("%s", t) ;

  int i ;
  for( i = 0 ; i < n ; i++ ){
    printf("%c%c",s[i],t[i]) ;
  }
  printf("\n") ;

  return 0 ;
}


Measured memory_bytes: 128
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    x = II()
    print( 'Yes' if x >= 30 else 'No')

    
main()

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

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

int b[1000][1000];
int one[1000000];
int to[1000000];

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

	int W, H;
	cin >> H >> W;
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			int h;
			cin >> h;
			h--;
			b[i][j] = h;
			x[h] = j;
			y[h] = i;
		}
	}

	int ans = 0;
	for(int h = 0; h < H * W; h++) {
		set<int> s;
		for(int k = 0; k < 4; k++) {
			int nx = x[h] + dx[k];
			int ny = y[h] + dy[k];
			if(nx < 0 || W <= nx || ny < 0 || H <= ny) continue;
			int th = b[ny][nx];
			if(th < h) {
				if(one[th]) one[h] = 1;
				else s.insert(to[th]);
			}
		}
		if(one[h]) {
			ans++;
		}
		else {
			if(s.size() == 0) {
				to[h] = h;
			}
			else if(s.size() == 1) {
				to[h] = *s.begin();
			}
			else {
				one[h] = 1;
				ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 20408
fun main (args : Array<String>) {
	val (a, b, c) = readLine()!!.split(" ").map(String::toInt)
	val A : Int = a.toInt()
	val B : Int = b.toInt()
	val C : Int = c.toInt()
	var count : Int = 0
	for (i in 1..C) {
		if ((A * i) <= B) {
			count++
		}
	}
	println("${count}")
}

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

using namespace std;

typedef long long ll;
int main()
{
    int n;
        cin>>n;
        double a[n],sum=0;
        for(int i=0;i<n;i++)
        {
                cin>>a[i];
                sum+=a[i];
        }
        sum/=n;
        int index=0;
        double mn=1e9;
        for(int i=0;i<n;i++)
        {
                if(abs(sum-a[i])<mn)
                {
                        mn=abs(sum-a[i]);
                        index=i;
                }
        }
        cout<<index;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>
#include <iostream>

#define REP(i, n) for (int i=0;i<(n);i++)
#define FOR(i, a, b) for (int i=(a);i<(b);i++)

using namespace std;

int main() {
    int A, B, C, D, m1, m2;
    scanf("%d", &A);
    scanf("%d", &B);
    scanf("%d", &C);
    scanf("%d", &D);
    m1 = min(A, B);
    m2 = min(C, D);
    printf("%d\n", m1+m2);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        if(x < a) {
            System.out.println(0);
        } else {
            System.out.println(10);
        }
    }
}

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

using ll = long long;
using P = pair<int, int>;

const int MAX = 1e5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int cnt[MAX];

int main() {
  // 入力
  int N, M;
  cin >> N >> M;
  int a[M], b[M];
  for (int i = 0; i < M; i++) cin >> a[i] >> b[i];

  for (int i = 0; i < M; i++) {
    a[i]--, b[i]--;
    cnt[a[i]]++;
    cnt[b[i]]++;
  }

  bool flag = true;
  for (int i = 0; i < N; i++) if (cnt[i] & 1) {
    flag = false;
    break;
  }

  // 解答
  cout << (flag ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define all(vec) vec.begin(), vec.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
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;
}

int main(){
  cout << fixed << setprecision(15);
  int d, b; cin >> d >> b;
  double p = 0;
  for(int i = 1; i <= d; i++){
    double prob = 1.0 / d;
    int k = i;
    while (k < b){
      k *= 2;
      prob /= 2;
    }
    p += prob;
  }
  cout << p << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
dist = []
for i in range(m-1):
    dist.append(x[i+1]-x[i])
dist.sort(reverse=True)
ans = x[-1] - x[0]
for i in range(min(n-1, m-1)):
    ans -= dist[i]
print(ans)

Measured memory_bytes: 13968
using System;
using System.Collections.Generic;
using System.Globalization;

namespace cswork
{
    class Program
    {
        public Program() { }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        void Omame()
        {
            cin = new Scanner();
            int a = cin.nextInt();
            int b = cin.nextInt();
            int c = cin.nextInt();
            int d = cin.nextInt();

            int count = 0;
            for (int i = 0; i <= 100; i++)
            {
                if (a <= i && i <= b)
                {
                    if (c <= i && i <= d)
                    {
                        count++;
                    }
                }
            }

            count--;
            if (count < 0)
            {
                count = 0;
            }
            Console.WriteLine(count);
        }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();

            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next();
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N), b(N), c(N);
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    for(int i=0; i<N; i++){
        cin >> b[i];
    }
    for(int i=0; i<N; i++){
        cin >> c[i];
    }
    sort(a.begin(), a.end());
    sort(c.begin(), c.end());
    ll ans=0;

    for(int i=0; i<N; i++){
        auto aa=lower_bound(a.begin(), a.end(), b[i]);
        auto cc=upper_bound(c.begin(), c.end(), b[i]);
        ans+=(aa-a.begin())*(c.end()-cc);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e6 + 3;

long long int rev_mod(long long int num){
	long long int pow_num = MOD - 2;
	long long int mod_num = MOD;
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

long long int pow_mul(long long int num, long long int p){
	long long int pow_num = p;
	long long int mod_num = MOD;
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

long long int fact[1000005];

int main(){
    fact[0] = 1;
    for(int i = 1; i < 1000005; i++){
        fact[i] = fact[i - 1] * i % MOD;
    }
    int Q;
    cin >> Q;
    for(int loop = 0; loop < Q; loop++){
        long long int x, d, n;
        cin >> x >> d >> n;
        if(d == 0){
            cout << pow_mul(x, n) << endl;
            continue;
        }
        long long int L = x * rev_mod(d) % MOD;
        long long int R = L + n - 1;
        if(L == 0 || R / MOD >= 1){
            cout << 0 << endl;
            continue;
        }
        cout << fact[R] * rev_mod(fact[L - 1]) % MOD * pow_mul(d, n) % MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 8704
n = int(input())
li=[[] for i in range(n)]
for i in range(n):
    li[i]=list(input().split())
x = input()

ans=0
flag=0
for i in li:
    if flag==1:
        ans+=int(i[1])
    if i[0]==x:
        flag=1
print(ans)

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

#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,ans=0;
    cin>>n;
    m=n;
    while(m>0){
        ans+=(m%10);
        m/=10;

    }

    if(n%ans==0){
        cout << "Yes"<<endl;
    }
    else{
        cout << "No"<<endl;
    }

    return 0;
}



Measured memory_bytes: 256
import collections
N = int(input())
S = [str(input()) for i in range(N)]
c = collections.Counter(S)
l = c.most_common()
dict = [l[0][0]]
if l[0][1] == N:
    print(*dict)
    exit()
for i in range(N - 1):
    if l[i][1] == l[i + 1][1]:
        dict.append(l[i + 1][0])
        continue
    break
a = sorted(dict)
for x in a:
    print(x)

Measured memory_bytes: 51584
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  int N;
  cin >> N;
  lint dp[N+1]={};
  dp[0]=2,dp[1]=1;
  for(int i=2;i<=N;i++) dp[i]=dp[i-1]+dp[i-2];
  cout << dp[N] << endl;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

for i in range(n-1):
    if h[i] > h[i+1]+1:
        print("No")
        exit()
    
    if h[i] == h[i+1]+1:
        h[i+1] += 1
    
print("Yes")

Measured memory_bytes: 14396
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
  //int N;
  //cin >> N;
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  
  sort(a, a+3);
  
  
  
  cout << abs(a[0]-a[1]) + abs(a[1]-a[2]) << endl;
  
}

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

int bfs(vector<vector<int> > &g,int u,vector<bool> &visited)
{
  queue<int> q;
  q.push(u);
  visited[u]=true;
  int cnt=1;
  while(!q.empty())
  {
    int v=q.front();
    q.pop();
    for(int i=0;i<(int)g[v].size();i++)
      if(!visited[g[v][i]])
      {
        visited[g[v][i]]=true;
        q.push(g[v][i]);
        cnt++;
      }    
  }
  return cnt;
}

int main()
{
  int n,m;
  cin>>n>>m;
  vector<vector<int> > g(n+1);
  for(int i=0;i<m;i++)
  {
    int u,v;
    cin>>u>>v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int ans=0;
  vector<bool> visited(n+1,false);
  for(int i=1;i<=n;i++)
    if(!visited[i])
      ans=max(ans,bfs(g,i,visited));
  cout<<ans;
  return 0;
}
              

Measured memory_bytes: 14956
//
// Created by 日熊悠太 on 2019-02-20.
//

#include <cstdio>
#include <vector>

int main()
{
    int n, m;

    std::scanf("%d%d", &n, &m);

    std::vector<int> a(m+1, 0);

    for (int i = 0; i < n; i++) {
        int k;
        std::scanf("%d", &k);
        for (int j = 0; j < k; j++) {
            int t;
            std::scanf("%d", &t);
            a[t]++;
        }
    }

    int answer = 0;
    for (int i = 0; i < m+1; i++) {
        if (a[i] == n) {
            answer++;
        }
    }

    std::printf("%d\n", answer);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll= long long;
using ld= long double;
using P =pair<ll,ll>;


//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<=(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define sort(a) sort(ALL(a))//sortの省略
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define in(T, x) T x;cin >> x;//Tは型,xが入力値
#define vec(T,a,n,x) vector<T> a(n,x);
#define vec2(T,a,n,m) vector<vector<T>> a(n,vector<T>(m));
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define out(x) cout << x << endl//出力
#define bout(b) if(b){out("Yes");}else{out("No");}//真偽問題に対する出力
#define ain(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}//配列の宣言と入力
#define a2in(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}//2つの配列を同時宣言、入力

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }//dp表とかで最大値更新するやつ
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }//最小値更新


signed main(){
  in(ll,N);
  in(ll,A);
  in(ll,B);
  ll wa=0;
  REP(i,N){
    ll ketawa=0;
    ll I=i;
    REP(j,10000){
      
      ketawa+=I%10;
      I/=10;
      
    }
    if(ketawa>=A && ketawa<=B)wa+=i;
  }
  out(wa);
   

}


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

int main() {
    int n,m;
    cin >> n >> m;
    map<int,int> ma;
    int ac = 0;
    int penalty = 0;;
    for(int i=0; i<m; i++){
        int a;
        string b;
        cin >> a >> b;
        if(ma[a] == -1)continue;
        if(b == "AC"){
            ac++;
            penalty += ma[a];
            ma[a] = -1;
            continue;
        }
        ma[a]++;
    }
    cout << ac << " " << penalty << endl;
}

Measured memory_bytes: 4992
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
using namespace std;

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;

int solve(string s, vector<int> l, vector<int> r) {
	int N = s.length(), M = l.size();
	int R = l[0], zero = 0, one = 0;
	int j = 0;
	vector<int> dp(N + 1);
	dp[0] = 1;
	for (int i = l[0]; i < r[M - 1]; i++) {
		if (j < M && i == l[j]) {
			for (int i = R; i < r[j]; i++) {
				if (s[i] == '0') zero++;
				else one++;
			}
			R = r[j];
			j++;
		}
		vector<int> _dp(N + 1);
		for (int x = 0; x <= N; x++) {
			int k0 = i - l[0] - x, k1 = x;
			if (k0 < 0 || k1 < 0) continue;
			if (k0 < zero) _dp[x] = (_dp[x] + dp[x]) % MOD;
			if (k1 < one) _dp[x + 1] = (_dp[x + 1] + dp[x]) % MOD;
		}
		dp = _dp;
	}
	int ans = 0;
	for (int x = 0; x <= N; x++)
		ans = (ans + dp[x]) % MOD;
	return ans;
}

int main() {
	int N, M; cin >> N >> M;
	string s; cin >> s;
	vector<int> l, r;
	int ma = 0;
	while (M--) {
		int x, y; cin >> x >> y;
		x--;
		if (y <= ma) continue;
		ma = y;
		if (l.size() && l.back() == x)
			l.pop_back(), r.pop_back();
		l.pb(x); r.pb(y);
	}
	M = l.size();
	vector<int> v;
	v.pb(0);
	for (int j = 0; j + 1 < M; j++)
		if (r[j] <= l[j + 1])
			v.pb(j + 1);
	v.pb(M);
	int ans = 1;
	for (int k = 0; k + 1 < v.size(); k++) {
		vector<int> _l, _r;
		for (int j = v[k]; j < v[k + 1]; j++)
			_l.pb(l[j]), _r.pb(r[j]);
		ans = (ll)ans * solve(s, _l, _r) % MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
MOD = 10**9+7

N,K = gets.split.map &:to_i
A = gets.split.map(&:to_i).sort_by{_1.abs}

if (K%2==1 && A.all?{_1<0}) || N==K then
    p A[0..K-1].inject(1){|r,i| (r*i)%MOD}
    exit
end

A.reverse!
neg_count = A[0..K-1].count{_1<0}

if neg_count.odd? then
    last_neg_idx = A[0..K-1].rindex{_1<0}
    last_pos_idx =  A[0..K-1].rindex{_1>=0}

    next_neg_idx = A[K..-1].index{_1<0}
    next_pos_idx = A[K..-1].index{_1>=0}

    next_neg_idx += K if next_neg_idx
    next_pos_idx += K if next_pos_idx

    swap_neg = next_pos_idx && A[next_pos_idx].to_r/A[last_neg_idx].abs
    swap_pos = next_neg_idx && last_pos_idx && A[next_neg_idx].abs.to_r/A[last_pos_idx]
    neg = (swap_neg && swap_pos) ? swap_neg >= swap_pos : swap_neg

    if neg then
        A[last_neg_idx] = A[next_pos_idx]
    else
        A[last_pos_idx] = A[next_neg_idx]
    end
end

 p A[0..K-1].inject(1){|r,i| (r*i)%MOD}

Measured memory_bytes: 34280
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

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


int main() {
    ll X;
    cin >> X;
    if(X >= 30){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}




Measured memory_bytes: 3588
n = int(input())
dp = [[0 for _ in range(3)] for _ in range(n)]
a, b, c = map(int, input().split())
dp[0][0], dp[0][1], dp[0][2] = a, b, c
for i in range(1, n):
    a, b, c = map(int, input().split())
    dp[i][0] = max(dp[i - 1][1] + a, dp[i - 1][2] + a)
    dp[i][1] = max(dp[i - 1][0] + b, dp[i - 1][2] + b)
    dp[i][2] = max(dp[i - 1][0] + c, dp[i - 1][1] + c)
print(max(dp[n - 1]))

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

enum E_SUITS {
	S,
	H,
	C,
	D
};

int main(int argc, char** argv) {
	vector<tuple<char,int,bool>> deck;
	for(E_SUITS suit = S; suit <= D; suit=static_cast<E_SUITS>(suit+1)) {
		char s = ((suit==S)?'S':(suit==H)?'H':(suit==C)?'C':'D');
		for(int i = 1; i <= 52/4; ++i) {
			deck.push_back(tuple<char,int,bool>(s, i, false ));
		}
	}

	int cards_num;
	cin >> cards_num;

	for(int j = 0; j < cards_num; ++j) {
		pair<char, int> tmp_card;
		cin >> tmp_card.first >> tmp_card.second;
		E_SUITS s = ((tmp_card.first=='S')?S:(tmp_card.first=='H')?H:(tmp_card.first=='C')?C:D);
		deck[(s*52/4)+tmp_card.second-1] = make_tuple(tmp_card.first, tmp_card.second, true);	
	}

	for(auto v : deck)
		if(get<2>(v) == false) cout << get<0>(v) << " " << get<1>(v) << endl;

	return 0;
}

Measured memory_bytes: 3108
// created on : Sun Jun 21 2020
 
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        int n = in.nextInt();
        int k = in.nextInt();
        int a[] = readInt(n);
        Arrays.sort(a);
        long sum = 0;
        for(int i = 0; i < k; i++){
            sum += a[i];
        }
        println(sum);
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static int[] readInt(int N) throws IOException { 
    	int arr[] = new int[N];
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    	return arr;
    }
    
    static long[] readLong(int N) throws IOException { 
    	long arr[] = new long[N];
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    	return arr;
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i] + " "); 
    	} 
    	println(""); 
    }
    
    static void displayRuntime(long startTime){
        long stopTime = System.currentTimeMillis();
        long elapsedTime = stopTime - startTime;
        System.out.println("Runtime: " + elapsedTime / 1000D);
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}


Measured memory_bytes: 25972
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    int n;
    cin >> n;
    vi a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    sort(all(a));
    sort(all(b));
    
    if(n%2){
        int mn = a[n/2];
        int mx = b[n/2];
        cout << mx - mn + 1 << endl;
        return;
    }else{
        int mn = a[n/2] + a[(n-2)/2];
        int mx = b[n/2] + b[(n-2)/2];
        cout << mx - mn + 1 << endl;
        return;        
    }
    
    return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  for (int i = 0; i < n; i ++) {
    double a, b, c, d, e, f, px, py, r;
    cin >> a >> b >> c >> d >> e >> f;
    py = ((e - a) * (a*a + b*b - c*c - d*d) - (c - a) * (a*a + b*b - e*e - f*f)) / (2 * (e - a) * (b - d) - 2 * (c - a) * (b - f));
    if (c == a) {
      px = (2 * (b - f) * py - a*a - b*b + e*e + f*f) / (2 * (e - a));
    } else {
      px = (2 * (b - d) * py - a*a - b*b + c*c + d*d) / (2 * (c - a));
    }
    r = sqrt((px - a) * (px - a) + (py - b) * (py - b));
    cout << fixed;
    cout << setprecision(3) << px << " " << setprecision(3) << py << " " << setprecision(3) << r << endl;
  }
}


Measured memory_bytes: 3260
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    vector<vector<int> > a(n, vector<int>(n, -1));
    for(int i=0; ((n-1)>>i)>0; ++i){
        for(int x=0; x<n; ++x){
            for(int y=x+1; y<n; ++y){
                if(((x ^ y) & (1<<i)) != 0)
                    a[x][y] = i;
            }
        }
    }

    for(int x=0; x<n; ++x){
        for(int y=x+1; y<n; ++y){
            cout << (a[x][y] + 1);
            if(y == n - 1)
                cout << endl;
            else
                cout << ' ';
        }
    }

    return 0;
}


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

int main(){

  int n, k, s, f=0;
  while (scanf("%d%d%d", &n, &k, &s) && n!=0 && k!=0 && s!=0) {
    int ans = 0;
	for (int i = 1; i < 1<<n; i++) {
      int sum = 0, cnt = 0;
	  for (int j = 0; j < n; j++) {
        if (i & (1<<j)) {
          sum += (j+1);
  		  cnt++;
		}
	  }
	  if (cnt==k && sum==s)
   	    ans++;
	}
    printf("%d\n", ans);
  }

  return 0;
}

Measured memory_bytes: 3188
//Maximum Heap
#include <iostream>

using namespace std;

int parent(int i) {return i/2;}
int left(int i) {return 2*i;}
int right(int i) {return 2*i+1;}

void maxHeapify(int A[], int H, int i) {
    int l = left(i), r = right(i);

    int largest = i;
    if(l <= H && A[l] > A[largest]) largest = l;
    if(r <= H && A[r] > A[largest]) largest = r;
    
    if(largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(A, H, largest);
    }
}

void buildMaxHeap(int A[], int H) {
    for(int i=H/2; i>0; i--) maxHeapify(A, H, i);
}

int main() {
    int H;
    cin >> H;
    int A[H+1];
    for(int i=1; i<H+1; i++) cin >> A[i];

    buildMaxHeap(A, H);

    for(int i=1; i<H+1; i++) cout << " " << A[i];
    cout << endl;
}


Measured memory_bytes: 5012
#include<cstdio>
#include<cmath>
int main()
{
	int d,n;
	int t=1,x,k=1,tot=1;
	scanf("%d%d",&d,&n);
		for(int i=1;i<=d;i++)
			t*=100;
		x=t;
		while(1)
		{
			if(x%(t*100)!=0&&tot==n)
				break;
			else
			{
				k++;
				x=t*k;
				if(x%(t*100)!=0)
					tot++;
			}
			//printf("k:%d x:%d tot:%d\n",k,x,tot);
		}
		printf("%d\n",x);
	return 0;
}


Measured memory_bytes: 128
using System;

namespace AtCoderABC128A
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            string[] s = Console.ReadLine().Split(' ');

            int A = int.Parse(s[0]);
            int P = int.Parse(s[1]);

            ans = (A * 3 + P) / 2;

            Console.WriteLine(ans.ToString());
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<cmath>
#include<cstdlib>
#include<cassert>
#include<climits>
using namespace std;

int main() {
	int W, H, N;
	cin >> W >> H >> N;
	vector<int> x(N), y(N), a(N);
	for (int i = 0; i < N; i++)
		cin >> x[i] >> y[i] >> a[i];

	int x_low = 0, x_high = W, y_low = 0, y_high = H;

	for (int i = 0; i < N; i++) {
		switch (a[i]) {
		case 1:
			x_low = max(x_low, x[i]);
			break;
		case 2:
			x_high = min(x_high, x[i]);
			break;
		case 3:
			y_low = max(y_low, y[i]);
			break;
		case 4:
			y_high = min(y_high, y[i]);
			break;
		}
	}
	if (x_high <= x_low || y_high <= y_low)
		cout << 0 << endl;
	else
		cout << (x_high - x_low) * (y_high - y_low) << endl;
}

Measured memory_bytes: 256
/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

#include <stdio.h>
#include <stdlib.h>

char *lcs(char *s1, char *s2, int s1_len, int s2_len)
{
    int lens[s1_len+1][s2_len+1];
    int back_inds[s1_len+1][s2_len+1][2];
    char cs[s1_len+1][s2_len+1];
    int i, j;
    
    for (i=0; i<=s1_len; i++)
    {
        lens[i][0] = 0;
        back_inds[i][0][0] = -1;
        back_inds[i][0][1] = -1;
        cs[i][0] = '\0';
    }
    
    for (i=0; i<=s2_len; i++)
    {
        lens[0][i] = 0;
        back_inds[0][i][0] = -1;
        back_inds[0][i][1] = -1;
        cs[0][i] = '\0';
    }
    
    for (i=1; i<=s1_len; i++)
    {
        char c1 = s1[i-1];
        for (j=1; j<=s2_len; j++)
        {
            char c2 = s2[j-1];
            if (c1 == c2)
            {
                lens[i][j] = lens[i-1][j-1] + 1;
                back_inds[i][j][0] = i;
                back_inds[i][j][1] = j;
                cs[i][j] = c1;
            }
            else
            {
                cs[i][j] = '\0';
                if (lens[i-1][j] > lens[i][j-1])
                {
                    lens[i][j] = lens[i-1][j];
                    back_inds[i][j][0] = back_inds[i-1][j][0];
                    back_inds[i][j][1] = back_inds[i-1][j][1];
                }
                else
                {
                    lens[i][j] = lens[i][j-1];
                    back_inds[i][j][0] = back_inds[i][j-1][0];
                    back_inds[i][j][1] = back_inds[i][j-1][1];
                }
            }
        }
    }
    
    /*for (i=0; i<=s1_len; i++)
    {
        for (j=0; j<=s2_len; j++)
        {
            printf("(%d, %d)\t", back_inds[i][j][0], back_inds[i][j][1]);
        }
        printf("\n");
    }
    
    for (i=0; i<=s1_len; i++)
    {
        for (j=0; j<=s2_len; j++)
        {
            printf("%c\t", cs[i][j]);
        }
        printf("\n");
    }*/
    
    int ss_len = lens[s1_len][s2_len];
    char *ss = malloc(sizeof(char)*(ss_len+1));
    int row = back_inds[s1_len][s2_len][0];
    int col = back_inds[s1_len][s2_len][1];
    
    for (i=ss_len; i>0; i--)
    {
        int new_row, new_col;
        
        ss[i-1] = cs[row][col];
        new_row = back_inds[row-1][col-1][0];
        new_col = back_inds[row-1][col-1][1];
        row = new_row;
        col = new_col;
    }
    
    return ss;
}

int main()
{
    char s1[3001];
    char s2[3001];
    char *ss;
    
    scanf("%s", s1);
    scanf("%s", s2);
    ss = lcs(s1, s2, strlen(s1), strlen(s2));
    printf("%s\n", ss);
    free(ss);

    return 0;
}


Measured memory_bytes: 114560
n=int(input())
dic={}
for i in range(n):
  wk={}
  s=input()
  for i in range(len(s)):
    if s[i] in wk:
      wk[s[i]]+=1
    else:
      wk[s[i]]=1
  list=sorted(wk.items(),key=lambda x:x[0])
  key="".join(map(str,dict(list).items()))
  if key in dic:
    dic[key]+=1
  else:
    dic[key]=1
ans=0
for i in dic.values():
  if i==1:
    continue
  else:
    ans+=i*(i-1)/2
print(int(ans))

Measured memory_bytes: 23160
#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);

  int n;
  ll k;
  cin >> n >> k;

  vector<ll> a(n), b(n);
  rep(i, n){
    cin >> a[i] >> b[i];
  }

  ll mask = (1LL<<32) - 1LL;

  ll ans = 0;
  for(int i = 0; i < 31; i++){
    if(k & (1LL<<i)){

      ll tans = 0;
      ll num = k & (mask << i);

      for(int j = 0; j < n; j++){
        ll numa = a[j] & (mask << i);
        if((num | numa) == num && (a[j] & (1<<i)) == 0LL){
          tans += b[j];
        }
      }
      chmax(ans, tans);
    }
  }

  ll tans = 0;
  rep(j, n){
    if((k | a[j]) == k){
      tans += b[j];
    }
  }
  chmax(ans, tans);

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


Measured memory_bytes: 1792
n = int(input())

def divisor(n):
    c = 0
    for i in range(1, n+1):
        if n%i == 0:
            c += 1
    return c

ans = 0
for i in range(1, n+1, 2):
    if divisor(i) == 8:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>

int main()
{

  for ( ; ; ) {
    int h, w ;

    std::cin >> h >> w ;

    if ( h == 0 && w == 0 )
      return 0 ;

    for ( int i = 0 ; i < h ; ++i ) {
      for ( int j = 0 ; j < w ; ++j ) {
        std::cout << "#" ;
      }
      std::cout << std::endl ;
    }

    std::cout << std::endl ;
  }
  
}

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int seq[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
  int n;
  cin >> n;
  cout << seq[n-1] << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> mons(N+1);
  vector<int> yusya(N);
  for( int i = 0; i < N+1; i++ ){
      cin >> mons.at(i);
  }
  int64_t total = 0; //勇者が最大で倒せるモンスターの数
  for( int i = 0; i < N; i++ ){
    cin >> yusya.at(i);
    total += yusya.at(i);
  }
  
  int nokori = 0; //i番目の勇者がi番目の街のモンスターを倒したときの残り
  int64_t totalmins = 0; //あとで引くやつ
  for( int i = 0; i < N; i++ ){
    nokori = yusya.at(i) - mons.at(i);
    if( nokori < 0 ){
      nokori = 0;
    }
    if( mons.at(i+1) >= nokori ){
      mons.at(i+1) -= nokori;
    }else{
      totalmins += ( nokori - mons.at(i+1) );
      mons.at(i+1) = 0;
    }
  }
  cout << total - totalmins << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
 
int main()
{
    int n;
    cin>>n;
    vector<double>p(n);
    for(int i=0;i<n;i++)
        cin>>p[i];
    vector<vector<double>>dp(n+1, vector<double>(n+1,0.0));
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
        dp[i][0] = (1-p[i-1])*dp[i-1][0];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=i;j++)
            dp[i][j] = p[i-1]*dp[i-1][j-1] + (1-p[i-1])*dp[i-1][j];
    double sum = 0;
    for(int i=(n+1)/2;i<=n;i++)
        sum += dp[n][i];
    cout<<setprecision(10)<<sum<<"\n";
    
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
    int w,h,n;
    cin>>w>>h>>n;
    int l=0,r=w,u=h,d=0;
    rep(i,n){
        int x,y,a;
        cin>>x>>y>>a;
        if(a==1)l=max(l,x);
        if(a==2)r=min(r,x);
        if(a==3)d=max(d,y);
        if(a==4)u=min(u,y);
    }
    cout<<max(0,r-l)*max(0,u-d)<<endl;
    return 0;
}

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

int dp[3001][3001][2];

int solve(int* a, int i, int j, int t) {

	if (i > j)return 0;

	if (dp[i][j][t] != -1)return dp[i][j][t];

	if (t == 1)return dp[i][j][t] = max(a[i] + solve(a, i + 1, j, 0) , a[j] + solve(a, i, j - 1, 0));
	else return dp[i][j][t] = min(solve(a, i + 1, j, 1), solve(a, i, j - 1, 1));

}

int32_t main() {
	int n;
	cin >> n;
	int a[n + 1];
	int i;
	for (i = 1; i <= n; i++)cin >> a[i];

	memset(dp, -1, sizeof(dp));
	int ans = solve(a, 1, n, 1);

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

	int ansy = sum - ans;
	cout << ans - ansy << endl;
	return 0;
}

Measured memory_bytes: 141184
x,n=map(int,input().split())
p=list(map(int,input().split()))
a=[0]*102
for i in range(len(p)):
    a[p[i]]=1
sa=500
for j in range(len(a)):
    if a[j]==0 and sa>abs(x-j):
        m=j
        sa=abs(x-j)
print(m)

Measured memory_bytes: 9128
c = [[int(i) for i in input().split()] for i in range(3)]

for a1 in range(101):
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    if 0 <= b1 <= 100 or 0 <= b2 <= 100 or 0 <= b3 <= 100:
        if c[1][0] - b1 == c[1][1] - b2 == c[1][2] -b3 and 0<=c[1][0] <= 100 and c[2][0] - b1 == c[2][1] - b2 == c[2][2] -b3 and 0<=c[2][0] <= 100:
            print('Yes')
            break
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
const int NUM = 2e5 + 5;
vector<int> g[NUM];
bool vis[NUM];
int cc = 0;
void dfs(int node){
    vis[node] = 1;
    cc++;
    for(auto x:g[node])
        if(!vis[x])
            dfs(x);
}
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        int n,m; cin >> n >> m;
        map<pair<int,int>,bool> mp;
        FOR(i,0,m){
            int x,y; cin >> x >> y;
            if(mp[{x,y}] or mp[{y,x}]) continue;
            g[x].pb(y);
            g[y].pb(x);
            mp[{x,y}] = 1;
            mp[{y,x}] = 1;
        }
        int ans = 0;
        FOR(i,1,n+1){
            if(!vis[i]){
                cc = 0;
                dfs(i);
                ans = max(ans,cc);
            }
        }
        cout << ans ;
    }    
}

Measured memory_bytes: 45944
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = 0;
		int maxNum = 1;
		int minNum = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			a = sc.nextInt();
			maxNum = Math.max(a, maxNum);
			minNum = Math.min(a, minNum);
		}
		System.out.println(maxNum - minNum);
	}

}


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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

using namespace std;

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

  int x_a = abs(x - a);
  int x_b = abs(x - b);
  
  if (x_a > x_b) {
    cout << "B" << endl;
  } else {
    cout << "A" << endl;
  }
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

pub const MOD: usize = 1000000007;

fn main() {
    let n: usize = input();
    let mut ans = 0;
    for m in (1..).map(|x| x * 100) {
        if m > n {
            break;
        } else {
            let rest = n - m;
            if rest <= m / 100 * 5 {
                ans = 1;
            }
        }
    }
    println!("{}", ans);
}

pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n,nedge,too[500010],m,x,y,hed[500010],nxt[500010],dep[500010],d[500010];
void ae(int x,int y){
	nxt[++nedge]=hed[x];
	hed[x]=nedge;
	too[nedge]=y;
}
void dfs(int x,int l){
	dep[x]=dep[l]+1;
	for (int i=hed[x];i;i=nxt[i]){
		int y=too[i];
		if (y==l) continue;
		if (dep[y]){
			if (dep[y]>dep[x]) continue;
			printf("%d %d\n",x,y);
			d[x]^=1;
		}
		else{
			dfs(y,x);
		}
	}
	if (x>1){
		if (d[x]) printf("%d %d\n",x,l);
		else{d[l]^=1;printf("%d %d\n",l,x);}
	}
}
int main(){
	cin>>n>>m;
	if (m&1) return puts("-1"),0;
	FOR(i,1,m){
		getint(x),getint(y);
		ae(x,y),ae(y,x);
	}
	dfs(1,0);
	return 0;
}

Measured memory_bytes: 13056
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <deque>

using namespace std;

deque<int> q;

int main(int argc, char const *argv[]) {
    
    int n; cin >> n;

    for (int i = 1; i <= n; i ++) {
        int x; scanf("%d", &x);
        if (i & 1) q.push_front(x);
        else q.push_back(x);
    }

    if (n & 1) {
        while (q.size() > 1) {
            printf("%d ", q.front());
            q.pop_front();
        }
        printf("%d\n", q.front());
    }
    else {
        while (q.size() > 1) {
            printf("%d ", q.back());
            q.pop_back();
        }
        printf("%d\n", q.back());
    }

    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print1(a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
int n,ans;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n;
	rep2(i,1,n+1){
		if(i*i>n) break;
		if(n%i==0) ans=i+n/i-2;
	}
	print1(ans);
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var line string
	var t uint16
	sc := bufio.NewReader(os.Stdin)
	for {
		line, _ = sc.ReadString('\n')
		t = 0
		for _, r := range line {
			c, _ := strconv.Atoi(string(r))
			t += uint16(c)
		}
		if t == 0 {
			break
		} else {
			fmt.Println(t)
		}
	}
	return
}



Measured memory_bytes: 1088