akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const ll MOD=1000000007;

struct edge{
    ll from;
    ll to;
    ll cost;
};
int main(){
    ll N,M;cin>>N>>M;
    vector<edge> edges;
    rep(i,M){
        edge add;
        cin>>add.from>>add.to>>add.cost;
        add.from--;add.to--;add.cost*=-1;
        edges.push_back(add);
    }
    ll dist[N];
    fill(dist+1,dist+N,INF);
    dist[0]=0;
    rep(i,N){
        rep(j,edges.size()){
            ll a=edges.at(j).from,b=edges.at(j).to,c=edges.at(j).cost;
            if(dist[a]+c<dist[b])dist[b]=dist[a]+c;
        }
    }
    ll ans=-dist[N-1];
    bool negative[N];
    rep(i,N)negative[i]=false;
    rep(i,N){
        rep(j,edges.size()){
            ll a=edges.at(j).from,b=edges.at(j).to,c=edges.at(j).cost;
            if(dist[a]==INF)continue;
            if(dist[a]+c<dist[b]){
                dist[b]=dist[a]+c;
                negative[b]=true;
            }
            if(negative[a]==true)negative[b]=true;
        }
    }
    if(negative[N-1])cout<<"inf"<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#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);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

struct UnionFind {

	vi data;

	UnionFind(int n = 0) {
		data.assign(n, -1);
	}

	int find(int k) {
		if (data[k] < 0) return k;
		return data[k] = find(data[k]);
	}
	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return false;
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return true;
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int k) { return -data[find(k)]; }

};

int main() {

	int n, m;
	cin >> n >> m;

	UnionFind uf(n + m);

	rep(i, n) {
		int k;
		cin >> k;
		rep(j, k) {
			int l;
			cin >> l;
			uf.unite(i, l - 1 + n);
		}
	}

	bool ok = true;
	rep(i, n - 1)if (!uf.same(i, i + 1))ok = false;

	if (ok)cout << "YES" << endl;
	else cout << "NO" << endl;

}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N);
    ll mn = L_INF;
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        mn = min(mn, A[i]);
    }

    ll cnt1 = 0, cnt2 = 0, cnt3 = 0;
    for (ll i = 0; i < N; i++) {
        if (A[i] == mn) {
            ++cnt1;
        }
        else if (A[i] == mn + 1) {
            ++cnt2;
        }
        else {
            ++cnt3;
        }
    }

    if (cnt3 > 0) {
        cout << "No\n";
        return;
    }

    if (cnt2 == 0) {
        if (mn + 1 == N) {
            cout << "Yes\n";
        }
        else if (2 * mn <= N) {
            cout << "Yes\n";
        }
        else {
            cout << "No\n";
        }
        return;
    }

    ll c = mn + 1;
    if (cnt1 >= c) {
        cout << "No\n";
    }
    else if (cnt2 < (c - cnt1) * 2) {
        cout << "No\n";
    }
    else {
        cout << "Yes\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3992
#include <iostream>

#define P 1000000007

using namespace std;

long inv[100001];
long fac[100001];

void init(){
    inv[0] = 1;
    inv[1] = 1;
    fac[0] = 1;
    fac[1] = 1;
    for(int i = 2; i <= 100000; i++){
        inv[i] = ((-(P/i)*inv[P%i])%P +P)%P;
        fac[i] = (fac[i-1]*i)%P;
    }
}

int main(){
    int N;
    long A[100000];
    long S[100000];
    long ans = 0;
    init();
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    S[0] = 0;
    for(int i = 0; i < N; i++){
        S[0] = (S[0] + inv[i+1])%P;
    }
    for(int i = 1; i < N; i++){
        S[i] = ((S[i-1] + inv[i+1] - inv[N-i+1])%P + P)%P;
    }
    for(int i = 0; i < N; i++){
        ans = (ans+(fac[N]*((S[i]*A[i])%P)%P))%P;
    }
    cout << ans << endl;
}

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

int main(){
  int N;cin>>N;
  vector<int> p(N);
  for(int i=0;i<N;i++) cin>>p.at(i);
  int ans=0;
  for(int i=1;i<N-1;i++){
    if(p.at(i-1)<p.at(i) && p.at(i)<p.at(i+1)) ans++;
    else if(p.at(i-1)>p.at(i) && p.at(i)>p.at(i+1)) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3584
#include <stdio.h>

int main()
{
	int S, h, m, s,sub;
	scanf("%d", &S);
	h = S / 3600;
	sub = S % 3600;
	m = sub / 60;
	s = sub % 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

Measured memory_bytes: 592
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {


        static void Main(string[] args)
        {

            string line = null;
            while ((line = Console.ReadLine()) != null)
            {
                string[] lines = line.Split(' ');
                int a = int.Parse(lines[0]);
                string op = lines[1];
                int b = int.Parse(lines[2]);

                if (op ==  "?")
                    break;

                switch (op)
                {
                    case "+":
                        Console.WriteLine(a + b);
                        break;
                    case "-":
                        Console.WriteLine(a - b);
                        break;
                    case "*":
                        Console.WriteLine(a * b);
                        break;
                    case "/":
                        Console.WriteLine(a / b);
                        break;
                }
            }
        }
    }
}

Measured memory_bytes: 9212
# include <iostream>

using namespace std;
  
int main() {
	int Participants  = 0;
	int Days = 0;
	int Left = 0;
	int Frequence[100] = {0};
	
	cin >> Participants >> Days >> Left;
	int Total = 0;
	for ( int i = 0; i < Participants; i++ ) {
		cin >> Frequence[i];
		Total += ( Days - 1 ) / Frequence[i] + 1;
	} // for
	
	Total += Left;
	cout << Total;
}// main

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int ans[200005];
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int cnt=0;
    for(int i=1;i<=min(a,b);i++)
    {
        if((a%i==0)&&(b%i==0))
        {
            ans[++cnt]=i;
        }
    }
    printf("%d\n",ans[cnt-c+1]);
//    int n;
//    scanf("%d",&n);
//    for(int i=1; i<=n; i++)
//    {
//        scanf("%d",&a[i]);
//    }
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
answer = 0
ans = [0,0,0]

for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1,N):
            if L[i]!= L[j] and L[j] != L[k] and L[k] != L[i]:
                ans[0] = L[i]
                ans[1] = L[j]
                ans[2] = L[k]
                if abs(ans[2] - ans[1]) < ans[0] and ans[2] + ans[1] > ans[0] :
                    answer = answer+1
print(answer)


Measured memory_bytes: 9204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp64 {
    class Program {
        static void Main(string[] args) {
            string S = Console.ReadLine();

            switch (S) {
                case "Sunny":
                    Console.WriteLine("Cloudy");
                    break;
                case "Cloudy":
                    Console.WriteLine("Rainy");
                    break;
                case "Rainy":
                    Console.WriteLine("Sunny");
                    break;

            }

        }
    }
}


Measured memory_bytes: 9044
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int n, min;
    long sum = 0;
    cin >> n;
    vector<int> a(n);
    int minus_group = 0;
    int current_minus_length = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
        if (a.at(i) < 0)
        { //0?
            current_minus_length++;
        }
        if (a.at(i) > 0 || i == n - 1)
        {
            if (current_minus_length % 2 != 0)
            {
                minus_group++;
            }
            current_minus_length = 0;
        }
        a.at(i) = abs(a.at(i));
        if (i == 0)
        {
            min = a.at(0);
        }
        if (min > a.at(i))
        {
            min = a.at(i);
        }
    }
    for (int i = 0; i < n; i++)
    {
        sum += a.at(i);
    }
    if (minus_group % 2 != 0)
    {
        sum -= min * 2;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int D;
  cin >> D;
  vector<int> c(26);
  rep(i, 26) cin >> c[i];

  vector<vector<int>> s(D);
  rep(d, D)
  {
    s[d].resize(26);
    rep(i, 26)
    {
      cin >> s[d][i];
    }
  }

  vector<int> t(D);
  rep(i, D)
  {
    cin >> t[i];
    t[i]--;
  }

  int M;
  cin >> M;
  vector<int> d(M);
  vector<int> q(M);
  rep(i, M)
  {
    cin >> d[i];
    cin >> q[i];
    d[i]--;
    q[i]--;
  }

  rep(m, M)
  {
    t[d[m]] = q[m];

    long long score = 0;
    vector<int> last(26, 0);

    rep(i, D)
    {
      score += s[i][t[i]];
      last[t[i]] = i + 1;
      rep(j, 26)
      {
        score -= c[j] * (i + 1 - last[j]);
      }
    }
    cout << score << endl;
  }

  return 0;
}


Measured memory_bytes: 3972
s = int(input())
S = [s]
cnt = 1

while True:
  cnt += 1
  if s % 2 == 0:
    s = s//2
  else:
    s = 3 * s + 1
  
  if S.count(s) == 1:
    print(cnt)
    exit()
  S.append(s)
  

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main() {
    int K;
    cin >> K;
    queue<ll> Q;
    FOR(i,1,9) {
        Q.push(i);
    }

    ll ans;
    ll rem;
    FOR(i,1,K) {
        ans = Q.front();
        Q.pop();
        rem = ans%10;
        if (rem!=0) Q.push(ans*10 + rem-1);
        Q.push(ans*10 + rem);
        if (rem!=9) Q.push(ans*10 + rem+1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

// Extended Print Func
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& input){
    os << "[ ";
    REP(i, input.size()){
        os << input[i];
        if (i < input.size()-1) { os << " "; }
    }
    os << " ]";
    return os;
}
void print() { std::cout << "\n"; }
template<class T, class... A> void print(const T& first, const A&... rest) { std::cout << first << " "; print(rest...); }
template<class... A> void print(const A&... rest) { print(rest...); }



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

  ll N;
  cin >> N;
  vector<double> v(N);
  REP(i,N){ cin >> v[i]; }
  sort(v.begin(), v.end());
  double ans = v[0];
  REP3(i,1,N){
      ans = (ans+v[i])/2;
  }
  cout << fixed << setprecision(10) << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
N = int(input())
p = [int(input()) for _ in range(N)]

mx_idx = 0
mx = 0
for i in range(N):
    if mx < p[i]:
        mx = p[i]
        mx_idx = i

tmp = p[mx_idx]
p[mx_idx] = tmp * (1 / 2)
print(int(sum(p)))

Measured memory_bytes: 3188
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M = inpl()

if N == 2 or M==2:
    print(0)
elif N == 1 and M == 1:
    print(1)
elif N == 1:
    print(M-2)
elif M == 1:
    print(N-2)
else:
    print((N-2)*(M-2))


Measured memory_bytes: 4196
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int q[N];
#define f(i,a,b) for(int i=a;i<b;i++)
#define read(x)  scanf("%d",&x)
int main(){
int k,a,b;
scanf("%d%d%d",&k,&a,&b);
for(int i=a;i<=b;i++){
	if(i%k==0){
		printf("OK");
		return 0;
	}
	else if(i==b)printf("NG");
}
return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define RB rbegin()
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define MD 1000000007
#define PPF pop_front()
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;u.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>u;
map<LL,LL>ww,cc;
LL ar[50000001];
LL br[50000001];
LL cr[500][500];
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
LL veve(LL A[], LL n, LL k)
{
    sort(A, A + n);
    LL product = 1;
    if (A[n - 1] == 0 && (k & 1))
        return 0;
    if (A[n - 1] <= 0 && (k & 1))
    {
        for (LL i = n - 1; i >= n - k; i--)
        {
            product *= A[i];
            product%=1000000007;
        }
        return product%1000000007;
    }
    LL i = 0;
    LL j = n - 1;

    if (k & 1)
    {
        product *= A[j];
        product%=1000000007;
        j--;
        k--;
    }
    k >>= 1;
    for (LL itr = 0; itr < k; itr++)
    {
        LL left_product = A[i] * A[i + 1];
        LL right_product = A[j] * A[j - 1];
        if (left_product > right_product)
        {
            product *= (left_product%1000000007);
            product%=1000000007;
            i += 2;
        }
        else
        {
            product *= (right_product%1000000007);
            product%=1000000007;
            j -= 2;
        }
    }
    return product%1000000007;
}
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    while(tt--)
    {
        UOSMOY;
        cin>>n>>m;
        for(i=0; i<n; i++)
        {
            cin>>ar[i];
        }
        k=veve(ar,n,m);
        if(k<0)
        {
            k%=1000000007;
            cout<<1000000007+k<<endl;

        }
        else
        {
            k%=1000000007;
            cout<<k<<endl;
        }
    }
    return 0;
    //IN
    //AL
}


Measured memory_bytes: 5228
N = gets.to_i 
S = gets.to_i
D = N - S
R = Math.sqrt(N).floor

def f(b, n)
  n < b ? n : f(b, n / b) + (n % b)
end

def impossible
  S > N ? -1 : nil 
end

def largest
  N == S ? N + 1 : nil 
end
 
def smaller
  (2..R).lazy.select{|b| f(b, N) == S}.first
end

def larger
  x1 = (R + 1).downto(1).lazy.select{|x| D % x == 0}.
       select{|x| f(D / x + 1, N) == S}.first
  x1 ? D / x1 + 1 : nil
end

puts impossible || largest || smaller || larger || -1

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>

using namespace std;

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

  vector<int> WE(n), EW(n);
  int count=0;
  for(int i=0; i<n; i++) {
    if(s[i] == 'W')
      count++;
    WE[i] = count;
  }
  count=0;
  for(int i=n-1; i>=0; i--) {
    if(s[i] == 'E')
      count++;
    EW[i] = count;
  }

  int countMin = 1e9;
  for(int i=0; i<n; i++) {
    //cout<<(i-1 > 0 ? WE[i-1] : 0)<<" "<<                                      
    // (i+1 < n ? EW[i+1] : 0)<<endl;                                           
    int cnt = (i-1 > 0 ? WE[i-1] : 0) +
      (i+1 < n ? EW[i+1] : 0);
    countMin = min(countMin, cnt);
  }
  cout<<countMin<<endl;
}



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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector< VI > 	VVI;
typedef long long int 	LL;
typedef vector<LL> 		VL;
#define si(n) cin>>n
#define dout(n) cout<<n<<"\n"
#define DRT() int t; si(t); while(t--)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
//# define M_PI           3.14159265358979323846264338327950288
// DSU
void IO(){
	#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
	#endif
	srand(chrono::steady_clock::now().time_since_epoch().count());
	off;
}

int main(){
	IO();
	string s;
	cin>>s;
	LL sum = 0;
	for(auto it : s){
		sum += it - '0';
		sum = sum % 9;
	}
	if(sum)
		cout<<"No";
	else
		cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
 using namespace std;
 const long long mod=1e9+7;

 int main(){
 int N,M;
 cin>>N>>M;
 vector<int>oks(N+1,true);
 for(int i=0;i<M;++i){
 int a;cin>>a;
oks[a]=false;
 }

 vector<long long int>dp(N+1);
 dp[0]=1;
 for(int now=0;now<N;++now){
 for(int next=now+1;next<=min(N,now+2);++next){
 if(oks[next]){
 dp[next]+=dp[now];
 dp[next]%=mod;
}
 }
 }

 cout<<dp[N]<<endl;
 return 0;
 }

Measured memory_bytes: 1408
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int gcd(int a,int b){
	while(a){
		b%=a;swap(a,b);
	}return b;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	printf("%lld\n",(long long)a/gcd(a,b)*b);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define DIM 200007
#define INF 1000000000000000007LL
#define modulo 1000000007
using namespace std;
#define int long long
long long n,a[DIM],h[DIM];
set<pair<int,int> > s;

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

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

    long long res = 0;
    for(int i = 1; i <= n; ++i)
    {
        auto it = s.upper_bound({h[i],0});
        vector<pair<int,int> > vec;
        int d;


        if(s.empty() || it == s.begin()) d = a[i];
        else {
            auto it2 = it;
            it2--;
            d = it2->second + a[i];
        }res = max(res,d); //cout<<i<<' '<<res<<endl;
        while(it!=s.end() && it->second<d)
        {
            vec.push_back(*it);
            it++;
        }
        for(auto i:vec)
            s.erase(i);
        s.insert({h[i],d});
    }
    cout<<res;
    return 0;
}


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

int main() {
  int K,X;
  cin >> K >> X;
 
  int max_left = X - K + 1;
  int max_right = X + K - 1;
  
  for(int i = max_left;i <= max_right;i++){
    cout << i << " ";
  }
  cout << endl;

  return 0;
}



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

using i64 = int64_t;

constexpr i64 MOD = 1e9 + 7;

void solve(i64 n, i64 k, i64 node, int par, vector<vector<int>> &tree, vector<i64> &v){
    if(par == 0){
        v[node] = k;
        for(int i=0;i<tree[node].size();++i){
            int to = tree[node][i];
            if(v[to] >= 0)continue;
            v[to] = k - (i+1);
            solve(n, k, to, node, tree, v);
        }
    }else{
        int cnt = 0;
        for(int i=0;i<tree[node].size();++i){
            int to = tree[node][i];
            if(v[to] >= 0)continue;
            if(to == par)continue;
            v[to] = (k-2-cnt);
            solve(n, k, to, node, tree, v);
            cnt++;
        }
    }
}

int main(){
    i64 n, k;
    cin >> n >> k;
    vector<vector<int>> tree(n+1, vector<int>());
    for(int i=0;i<n-1;++i){
        int a, b;
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    vector<i64> v(n+1, -1);
    solve(n, k, 1, 0, tree, v);
    i64 ans = 1;
    for(int i=1;i<=n;++i){
        //cerr << v[i] << endl;
        ans *= v[i];
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13568
// ------------------------------------
// Date:2018/ 2/17
// Problem:ABC 086 Product a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)

int main()
{
  int a,b;
  cin >> a >>b;
  if (a%2==1 && b%2==1) cout << "Odd" << endl;
  else cout << "Even" << endl;
  return 0;
}


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

int main() {
    int N, Z, W;
    cin >> N >> Z >> W;
    if(N == 1) {
        int a;
        cin >> a;
        cout << abs(a - W) << endl;
    } else {
        int a, b;
        for(int i=0; i+1<N; ++i) cin >> a;
        cin >> b;
        cout << max(abs(b - W), abs(a - b)) << endl;
    }
}

Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
xyh = []
for _ in range(n):
    xyh.append(LIST())
for x in range(0, 101):
    for y in range(0, 101):
        h = -1
        flag = True
        tmp = []
        for i in range(n):
            clc = abs(x - xyh[i][0]) + abs(y - xyh[i][1])
            if xyh[i][2] == 0:
                tmp.append(xyh[i][:2])
                continue
            if xyh[i][2] + clc == h or h == -1:
                h = xyh[i][2] + clc
            else:
                flag = False
                break
        if flag and h > 0:
            for i in tmp:
                clc = abs(x - i[0]) + abs(y - i[1])
                if h - clc > 0:
                    flag = False
            if flag:
                print(x, y, h)
                exit()


Measured memory_bytes: 64488
#include <cstdio>
const int MAXN = 1e5+5;
char S[MAXN];
int N;

int solve() {
    int sum = 1;
    for (int i = 1; i < N; ++i) {
        if (S[i] != S[i-1]) ++sum;
    }
    return sum;
}

int main() {
    scanf("%d", &N);
    scanf(" %s", S);
    printf("%d\n", solve());
    return 0;
}

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

const int maxn = 205;
int N, X, S[maxn];

const int M = 1e9+7;
void madd(int& a, int b) {
    a += b;
    if (a >= M) a -= M;
}
int mult(int a, int b) {
    return (1LL*a*b) % M;
}
int modexp(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b&1) b >>= 1;
        a = mult(a,a);
        b >>= 1;
    }
    return res;
}
int inverse(int x) {
    return modexp(x,M-2);
}

int dp[100005][maxn];
int inv[maxn];

int f(int x, int i) {
    int& res = dp[x][i];
    if (res != -1) return res;
    if (i == N) return res = x;
    res = mult(mult(N-i-1,inv[N-i]),f(x,i+1));
    madd(res,mult(mult(1,inv[N-i]),f(x%S[i],i+1)));
    return res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> N >> X;
    for (int i = 1; i <= N; i++) {
        inv[i] = inverse(i);
        cin >> S[i-1];
    }
    sort(S,S+N,greater<int>());
    memset(dp,-1,sizeof dp); 
    int ans = f(X,0);
    /*
    for (int i = 1; i <= N; i++) {
        ans = mult(ans,i);
    }
    */
    cout << ans << '\n';
}


Measured memory_bytes: 80384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

class SegmentTree {
  vector<int> dat;
  int n, def;
public:
  SegmentTree(int num, int x) {
    n = 1;
    while (n < num)
      n <<= 1;
    dat.resize(2 * n - 1, x);
    def = x;
  }
  void update(int i, int x) {
    i += (n - 1);
    dat[i] = x;
    while (i > 0) {
      i = (i - 1) / 2;
      dat[i] = min(dat[2 * i + 1], dat[2 * i + 2]);
    }
  }
  int query(int a, int b, int i = 0, int li = 0, int ri = -1) {
    if (!i) ri = n;
    if (ri <= a || li >= b) return def;
    if (li >= a && ri <= b) return dat[i];
    int vl = query(a, b, 2 * i + 1, li, (li + ri) / 2);
    int vr = query(a, b, 2 * i + 2, (li + ri) / 2, ri);
    return min(vl, vr);
  }
};

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  SegmentTree seg(n, INT_MAX);
  rep(query, q) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c)
      cout << seg.query(x, y+1) << endl;
    else
      seg.update(x, y);
  }
  return 0;
}


Measured memory_bytes: 3900
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC130 A - Rounding
// 2020.06.19

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X, A; cin >> X >> A;
  if(X < A){
    cout << 0 << endl;
  }else{
    cout << 10 << endl;
  }
}

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

using namespace std;
using ll = long long;

template <int T_MOD>
struct ModInt {
  static constexpr int MOD = T_MOD;
private:
  using ll = long long;
  int v;

  static int minv(int a, int m) {
    a %= m;
    if (a < 0) a += m;
    int b = m, u = 0, v = 1;
    while (a) {
      int t = b / a;
      b -= t * a; swap(a, b);
      u -= t * v; swap(u, v);
    }
    assert(b == 1);
    if (u < 0) u += m;
    return u;
  }

public:

  ModInt() : v(0) {}
  template<class T> ModInt(T v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
  explicit operator int() const { return v; }
  friend std::ostream& operator << (std::ostream& out, const ModInt& n) { return out << int(n); }
  friend std::istream& operator >> (std::istream& in, ModInt& n) { ll v_; in >> v_; n = ModInt(v_); return in; }
  friend bool operator == (const ModInt& a, const ModInt& b) { return a.v == b.v; }
  friend bool operator != (const ModInt& a, const ModInt& b) { return a.v != b.v; }

  ModInt inv() const {
    ModInt res;
    res.v = minv(v, MOD);
    return res;
  }

  ModInt neg() const {
    ModInt res;
    res.v = v ? MOD - v : 0;
    return res;
  }

  ModInt operator- () const {
    return neg();
  }

  ModInt operator+ () const {
    return ModInt(*this);
  }

  ModInt& operator ++ () {
    v++;
    if (v == MOD) v = 0;
    return *this;
  }

  ModInt& operator -- () {
    if (v == 0) v = MOD;
    v --;
    return *this;
  }

  ModInt& operator += (const ModInt& o) {
    v += o.v;
    if (v >= MOD) v -= MOD;
    return *this;
  }

  ModInt& operator -= (const ModInt& o) {
    v -= o.v;
    if (v < 0) v += MOD;
    return *this;
  }

  ModInt& operator *= (const ModInt& o) {
    v = int(ll(v) * ll(o.v) % MOD);
    return *this;
  }

  ModInt& operator /= (const ModInt& o) {
    return *this *= o.inv();
  }

  friend ModInt operator ++ (ModInt& a, int) { ModInt r = a; ++a; return r; }
  friend ModInt operator -- (ModInt& a, int) { ModInt r = a; --a; return r; }
  friend ModInt operator + (const ModInt& a, const ModInt& b) { return ModInt(a) += b; }
  friend ModInt operator - (const ModInt& a, const ModInt& b) { return ModInt(a) -= b; }
  friend ModInt operator * (const ModInt& a, const ModInt& b) { return ModInt(a) *= b; }
  friend ModInt operator / (const ModInt& a, const ModInt& b) { return ModInt(a) /= b; }  
};

const int mod = 1000000007;
using Mint = ModInt<mod>;

Mint power(Mint x, int p) {
  Mint ans = Mint(1);
  while(p) {
    if(p & 1) {
      ans *= x;
    }
    x *= x;
    p >>= 1;
  }
  return ans;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  Mint res = 0;
  vector<Mint> ar(k + 1);
  for(int x = k; x >= 1; --x) {
    ar[x] = power(k / x, n);
    for(int p = 2 * x; p <= k; p += x) {
      ar[x] -= ar[p];
    }
    res += ar[x] * Mint(x);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3672
package main

import (
	"fmt"
)

func main() {
	var k int
	fmt.Scan(&k)
	
	nums := []int{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}

	fmt.Println(nums[k-1])
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int fun(int x1,int y1,int x2,int y2){
    //cout<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<endl;
    int a,b,c,d;
    a = abs(x1-x2)+abs(y1-y2);
    //cout<<a<<"*/***"<<endl;
    return a;
}
int main(){
    int a,b,c,i,n;
    cin>>a>>b;
    int arr[100][2],ae[100][2];
    for(i = 0;i < a;i++){
        cin>>arr[i][0]>>arr[i][1];
    }
    for(i = 0;i < b;i++){
        cin>>ae[i][0]>>ae[i][1];
    }
    int d,j,k;
    for(i = 0;i < a;i++){
        c = 0x3f3f3f3f;
        for(j = 0;j < b;j++){
            d = fun(arr[i][0],arr[i][1],ae[j][0],ae[j][1]);
            if(c > d){

                c = d;
                k = j+1;
            }
        }
        cout<<k<<endl;

    }
}



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

using namespace std;
typedef long long ll;

int a[300003];

int main(void) {
    int n;
    ll ans = 0;
    cin >> n;
    for(int i=0; i<3*n; i++) scanf("%d", a+i);
    sort(a, a+3*n);
    for(int i=0; i<n; i++) ans += a[3*n-2-2*i];
    return !printf("%lld\n", ans);
}

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

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

	int n; cin >> n;  
	int sum = 0, i = 1;
	set<int> s;
	while(sum < n) {
		sum += i;
		s.insert(i);
		i++;
	}
	s.erase(sum - n);
	for(auto j = s.begin(); j != s.end(); j++){
		cout << *j << endl;
	}
	return 0;	
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

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

    double ans = 0;

    for (int i = 0; i < n; i++) {
        double x;
        string u;
        cin >> x >> u;

        if (u == "JPY") {
            ans += x;
        } else {
            ans += x * 380000.0;
        }
    }

    cout << fixed << setprecision(12) << ans << endl;
}


Measured memory_bytes: 256
N = int(input())

T, A = map(int,input().split())
H = list(map(int,input().split()))

a_t=[]
for i in range(N):
  
  s = abs(A-(T-H[i]*0.006))
  a_t.append(s)

print(a_t.index(min(a_t))+1)

Measured memory_bytes: 3060
while True:
    try:
        a,dax,b,bx = [],[],[],[]
        m = int(raw_input())
        for i in range(m):
            a.append(map(int, raw_input().split()))
        a = sorted(a)
        for i in range(m):
            dax.append(a[i][0]-a[0][0])
        n = int(raw_input())
        for i in range(n):
            b.append(map(int, raw_input().split()))
        b = sorted(b)
        for i in b:
            bx.append(i[0])
        for i in range(n-m+1):
            for j in range(m):
                if bx.count(bx[i]+dax[j]) == 0:
                    break
            else:
                print b[i][0]-a[0][0],b[i][1]-a[0][1]
                break
    except:
        break

Measured memory_bytes: 4396
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int L,R,x;
  cin >> L >> R;
  int y = 2019;
  if(R-L>=4038) cout << 0 << endl;
  else{
    for(int i=L;i<=R;i++){
      for(int j=L;j<i;j++){
        int a = i%2019;
        int b = j%2019;
        int c = a*b;
        x = c % 2019;
        if(x<y) y = x;
      }
    }
    cout << y << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    long long ans = 0;
    long long Q,H,S,D,N;
    cin >> Q >> H >> S >> D >> N;
    
    long long two = min( min ( Q*8, H*4 ), min( S*2, D ) );
    long long one = min( min ( Q*4, H*2 ), S );
    
    ans += ( N / 2 ) * two;
    ans += (N%2) * one;
    
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  string s; cin >> s;
  int ans = 1<<29;
  rep(i,s.size()-2){
    int now = 0;
    rep(j,3){
      now *= 10;
      now += s[i+j] - '0';
    }
    int temp = abs(753-now);
    ans = min(ans, temp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;
void swap_my(int &a,int &b){
  int keep = a;
  a = b;
  b = keep;
  
}
int main(){
  int w,n;
  cin >> w >> n;
  vector<int> status(w,0);
  for(int i = 0;i < w;i++){
	status[i] = i;
  }
  for(int i = 0;i < n;i++){
	int a,b;
	scanf("%d,%d",&a,&b);
	swap_my(status[a-1],status[b-1]);
  }
  for(int i = 0;i < w;i++){
	cout << status[i]+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1240
#include<stdio.h>
int n,h,f,x,y=-1;
int main()
{
	for(scanf("%d",&n);n--;y==f?h<x?x=h:0:y<f?x=h,y=f:0)
		scanf("%d%d",&h,&f);
	printf("%d %d\n",x,y);
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
    int n,k,s=0,i,t;
    cin>>n>>k;
    vector<int>a;
    for(i=0;i<n;++i)
    {
        cin>>t;
        a.push_back(t);
    }
    sort(a.begin(),a.end());
    for(i=0;i<n-k;++i)
        s+=a[i];
    cout<<s;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000
#define MAX 2000005
using ll=long long;
using Graph=vector<vector<int>>;
using pp=pair<pair<int,int>,int>;

int main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    cin>>B[i];
  }
  map<int,int> cnt1,cnt2;
  for(int i=0;i<N;i++){
    cnt1[A[i]]++;
    cnt2[B[i]]++;
  }
  bool flag=true;
  int i=0;
  map<int,int> m;
  vector<pair<int,int>> cnt;
  for(auto p:cnt2){
    int x=p.first;
    m[i]=x;
    cnt.push_back(make_pair(min(cnt1[x],cnt2[x]),i));
    i++;
    if(cnt1[x]+cnt2[x]>N){
      flag=false;
      break;
    }
  }

  if(!flag){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
    sort(cnt.begin(),cnt.end());
    reverse(cnt.begin(),cnt.end());
    int n=cnt.size();
    vector<int> C(N,-1);
    for(int i=0;i<N;i++){
      bool flag=true;
      for(int j=0;j<N;j++){
        int k=(i+j)%N;
        if(A[j]==B[k]){
          flag=false;
          break;
        }
      }
      if(flag){
        for(int j=0;j<N;j++){
          int k=(i+j)%N;
          cout<<B[k]<<" ";
        }
        cout<<endl;
        break;
      }
    }
  }
}


Measured memory_bytes: 35140
N, M = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
t = sum(l) / 4 / M
num = 0
ans = 0
for i in range(len(l)):
  if l[i] >= t:
    num += 1
  if num >= M:
    ans += 1
    break
if ans == 1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        for (int i = 0; i < n; i++) {
            System.out.println(converte(sc.nextLine()));
        }
    }
    static String converte(String s) {
        String a="";
        for(int i=1;i<26;i++) {
            for(int j=0;j<26;j++) {
                a="";
                for(char c:s.toCharArray()) {
                    if(c!=' ') {
                        a+=(char)(((c-'a')*i+j)%26+'a');                
                    }else {
                        a+=c;
                    }
                }

                for(String t:a.split(" ")) {
                    if(t.equals("that")||t.equals("this")) {
                        return a;
                    }
                }
            }
        }
        return "null";
    }
}


Measured memory_bytes: 63688
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n, k, q, i;
	int a;
	int ans[100000] = {};

	cin >> n >> k >> q;

	for (i = 0; i < n; i++) {
		ans[i] = k;
	}

	for (i = 0; i < q; i++) {
		cin >> a;
		ans[a-1] += 1;
	}

	for (i = 0; i < n; i++) {
		if (ans[i] - q > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;
}


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

int main()
{
	string s; cin >> s;
	int ans;

	if (s == "SUN") { ans = 7; }
	else if (s == "MON") { ans = 6; }
	else if (s == "TUE") { ans = 5; }
	else if (s == "WED") { ans = 4; }
	else if (s == "THU") { ans = 3; }
	else if (s == "FRI") { ans = 2; }
	else if (s == "SAT") { ans = 1; }

	cout << ans << endl;	

	return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a <= b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { 1,  0, -1,  0,  1, -1,  1, -1};
static const int dy[8] = { 0,  1,  0, -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;
const int mod = 1e9+7;

int m,nmin,nmax;
const int maxn = 205;
int score[maxn];
bool get_input(){
    scanf("%d %d %d",&m,&nmin,&nmax);
    if(m == 0) return false;
    
    _for(i,0,m){
        scanf("%d",&score[i]);
    }
    return true;
}
int main(){
    
    while(get_input()){
        int cnt = m;
        int p = 0;
        int ans = 0;
        int gap = -1;
        int k = nmax - 1;
        while(score[k] == score[k+1]){
            k--;
            nmax--;
        }

        p = nmin-1;
        
        while(p <= nmax-1){
            if(chmax(gap,score[p] - score[p+1])) ans = p+1;
            p++;
        }

        while(score[ans-1] == score[ans]) ans++;

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3196
<?php
	fscanf(STDIN, "%d", $N);
	$input=explode(' ',trim(fgets(STDIN)));

	$result = array();
	sort($input);

	for ($i = 0; $i < $N; $i++) {
      array_push($result, $input[$i]);
      if (count($result) === 2) {
        $tmp1 = array_pop($result);
        $tmp2 = array_pop($result);
        array_push($result, ($tmp1 + $tmp2)/2);
      }
    }

	echo (array_pop($result));
?>

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N, M;
  cin >> N >> M;
  VI xs(M);
  REP(i,M){
	int a, b;
	cin >> a >> b;
	xs[i] = max(0, N - a);
  }
  SORT(xs);

  cout << accumulate(ALL(xs), 0) - xs.back() << endl;

  return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
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, r;
    cin >> n >> r;
    if (n >= 10) cout << r;
    else cout << r + 100 * (10 - n);
}


Measured memory_bytes: 3624
n,h,w=map(int,input().split())
count=0
a=[[0] * 2 for i in range(n)]



for i in range(n):
    a[i]=list(map(int, input().split()))
    if a[i][0]>=h and a[i][1]>=w:
        count+=1
        
        
print(count)
        

Measured memory_bytes: 3188
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}

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


int main(){
  ll a,b,c,d,e,k; cin >> a >> b >> b >> b >> e >> k;
  if(e - a <= k) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
  while (1)
  {
    int x, y;
    cin >> x;
    cin >> y;
    if (x == 0 && y == 0)
    {
      break;
    }
    if (x > y)
    {
      int tmp = x;
      x = y;
      y = tmp;
    }
    cout << x << " " << y << endl;
  }
  return 0;
}


Measured memory_bytes: 3044