akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()

const int Mod = 1e9 + 7;
const int inf = 1e18;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n ;
  cin >> n;
  vector<int> a(n);
  int Mn = inf;
  int sum = 0;
  for(int i = 0; i < n  ; i++) {
    cin >> a[i];
    sum += a[i];
    if(a[i] % 10 != 0) {
      Mn = min(Mn , a[i]);
    }
  }
  dg2(Mn, sum);
  if(sum % 10 == 0) {
    if(Mn == inf) sum = 0;
    else sum = sum - Mn;
  }  
  cout << sum << '\n';
  

}

Measured memory_bytes: 3600
#include<stdio.h>
int main(){
	int a,b,c,i,cnt=0;

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

	for(i=a;i<=b;i++){
		if(c%i==0){
			cnt++;
		}
	}
	printf("%d\n",cnt);

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << ": " << x << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define INF (1LL << 30)
#define int long long
#define pii pair<long long, long long>
#define MOD 1000000007
#define print(x) cout << (x) << endl
using namespace std;
typedef long long ll;

int mem[52][2]; // [0]: P, [1]: B
int layer[52];
int layersum[52];
int memsum[52][2];

void a()
{
    mem[0][0] = 1;
    mem[0][1] = 0;
    memsum[0][0] = 1;
    memsum[0][1] = 0;
    layer[0] = 1;
    
    layersum[0] = 1;
    FOR(i,1, 51)
    {
        mem[i][0] = mem[i - 1][0] * 2 + 1;
        mem[i][1] = mem[i - 1][1] * 2 + 2;
        memsum[i][0] = memsum[i-1][0] + mem[i][0];
        memsum[i][1] = memsum[i-1][1] + mem[i][1];
        layer[i] = mem[i][0] + mem[i][1];
        layersum[i] = layersum[i-1] + layer[i];
    }
}

signed main()
{
    int N,X;
    cin>>N>>X;
    a();
    int ans = 0;

    int l = 0;

    for(int i=N; i>=1; --i){
        if (X == 0) break;
        --X;

        if (X <= layer[i-1]) continue;
        ans += mem[i-1][0] +1;
        X -= layer[i-1] + 1;
    }
    if (X) ans++;

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

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

int main() {

	vector <int> a(3);

	cin >> a[0] >> a[1] >> a[2];

	sort(a.begin(), a.end());

	if (a[1]==a[0]) {
		cout << "YES" << endl;
	}

	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define vs vector<string>
#define vc vector<char>
#define vvc vector< vector<char> >

#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

using namespace std;

string generate1(string s){
	vc c; for (char cc : s) c.push_back(cc);
	sort(all(c));
	return string(all(c));
}
string generate2(string s){
	vc c; for (char cc : s) c.push_back(cc);
	sort(rall(c));
	return string(all(c));
}

int main(){
	string s, t; cin >> s >> t;
	s = generate1(s);
	t = generate2(t);
	if (s<t) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

const int maxn=2e5+10;
vector<int> G[maxn];
int n;
int dist1[maxn];
int dist2[maxn];
int cnt1,cnt2;

void dfs1(int u,int pre,int d)
{
    dist1[u]=d;
    for(int i=0;i<G[u].size();i++){
        if(G[u][i]!=pre){
            dfs1(G[u][i],u,d+1);
        }
    }
}

void dfs2(int u,int pre,int d)
{
    dist2[u]=d;
    for(int i=0;i<G[u].size();i++){
        if(G[u][i]!=pre){
            dfs2(G[u][i],u,d+1);
        }
    }
}

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n-1;i++){
        int from,to;
        scanf("%d%d",&from,&to);
        G[from].push_back(to);
        G[to].push_back(from);
    }
    dfs1(1,-1,0);
    dfs2(n,-1,0);
    for(int i=1;i<=n;i++){
        if(dist1[i]<=dist2[i])
            cnt1++;
        else
            cnt2++;
    }
    if(cnt1>cnt2)
        printf("Fennec\n");
    else
        printf("Snuke\n");
    return 0;
}


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

int main()
{
    int s,t,g;
    cin>>s>>t;
    int a[t],sum=0;
    for(int i=0;i<t;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    if((s>sum) || (s==sum))
        {
            g=s-sum;
            cout<<g;
        }
        else{
            cout<<"-1";
        }
        return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000009
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define int ll
#define Endl endl


signed main(){
    int N,Ans=0,sum=1;
    int a[104];
    cin >> N;
    REP(i,N){
        cin >> a[i];
    }
    REP(i,N-1){
        if(a[i]==a[i+1]){
            sum++;
        }else{
            Ans+=sum/2;
            sum=1;
        }
    }
    Ans+=sum/2;
    cout << Ans << endl;
}   


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  int P[N];
  REP(i,N)cin>>P[i];
  set<int> s;
  REP(i,K)s.insert(P[i]);
  int ans=1;
  REP(i,N-K){
    if(P[i]==*s.begin() and P[i+K]>*s.rbegin())ans--;
    // cerr<<*s.begin()<<" "<<*s.rbegin()<<endl;
    ans++;
    s.erase(P[i]);
    s.insert(P[i+K]);
  }
  int a=0,b=1;
  FOR(i,1,N){
    if(P[i-1]<P[i])b++;
    else b=1;
    if(b==K)a++;
  }
  ans-=max(a-1,0);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 10368
use std::io::*;

fn main() {
    let s = read_v();
    let mut ch = [0, 0, 0, 0];

    for c in s.into_iter() {
        match c {
            'N' => ch[0] = 1,
            'W' => ch[1] = 1,
            'S' => ch[2] = -1,
            'E' => ch[3] = -1,
            _ => {}
        }
    }
    if ch[0] + ch[2] == 0 && ch[1] + ch[3] == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

// fn read() -> u32 {
//     let s = stdin();
//     let b = s.bytes()
//         .map(|c| c.unwrap() as char)
//         .take_while(|c| !c.is_whitespace())
//         .collect::<String>();
//     b.parse().ok().unwrap()
// }

fn read_v() -> Vec<char> {
    let s = stdin();
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<Vec<char>>();
    b
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
int N,M;
int a[100001];
bool light[100001];
int ans=0;
int main(){
  cin >> N;
  for(int i=1;i<=N;i++)cin >> a[i];
  int now=1;
  light[now]=true;
  while(1){
    int x=a[now];
   
    if(light[2]==true){ break;}
    else if(light[x]==true){ans=-1;break;}
    ans++;
    light[x]=true;
    now=x;
    
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,i,j,a[111]={},r,cl[8]={};
	int c=0,maxc=0,minc=1,tar=0;
	cin>>n;
	FOR(i,0,n){
		cin>>r;
		if(r>=3200){
			a[i]=8;
			tar++;
		}else a[i]=r/400;
	}
	a[n]=10;
	sort(a,a+n);
	FOR(i,0,8){
		if(a[lower_bound(a,a+n,i)-a]==i){
			cl[i]=1;
			c++;
		}
	}
	//minc
	if(c>1)minc=c;
	c+=tar;
	//if(c>8)c=8;
	cout<<minc<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <list>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    int n;
    cin>>n;
    int a[101];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    int ave=sum/n;
    int ans=INF;
    for(int i=-1;i<=1;i++){
        int p=ave+i;
        int tmp=0;
        for(int j=0;j<n;j++){
            tmp+=pow((a[j]-p),2);
        }
        ans=min(tmp,ans);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
INF = 1 << 60

h, n = map(int, input().split())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n):
    a[i], b[i] = map(int, input().split())

MAX = h - 1 + max(a)
dp = [[INF for j in range(MAX + 1)] for i in range(n)]
dp[0][0] = 0
if 0 <= a[0] < MAX + 1:
    dp[0][a[0]] = b[0]
for j in range(MAX + 1):
    if 0 <= j - a[0] < MAX + 1:
        dp[0][j] = min(dp[0][j], dp[0][j - a[0]] + b[0])
for i in range(1, n):
    for j in range(MAX + 1):
        dp[i][j] = min(dp[i][j], dp[i - 1][j])
        if 0 <= j - a[i] < MAX + 1:
            dp[i][j] = min(dp[i][j], dp[i][j - a[i]] + b[i])
ans = INF
for j in range(h, MAX + 1):
    ans = min(ans, dp[-1][j])
print(ans)

Measured memory_bytes: 173164
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    if(s == "Sunny")
        cout << "Cloudy";
    if(s == "Cloudy")
        cout << "Rainy";
    if(s == "Rainy")
        cout << "Sunny";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,a[100000];
	int i,x[100000];
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		x[a[i]]=i;
	}
	for(i=1;i<=n;i++){
		printf("%d ",x[i]);
	}
	return 0;
}

Measured memory_bytes: 2476
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 998244353;
const int N = 5000000;
const int K = 350;
int dp[N][4], b[N], cnt[N];
set < int > a[4];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < 3 * n; i++){
        if (s[i] == 'R') a[0].insert(i + 1);
        if (s[i] == 'G') a[1].insert(i + 1);
        if (s[i] == 'B') a[2].insert(i + 1);
    }
    for (int i = 0; i < n; i++){
        int x, y, z;
        x = *a[0].begin();
        a[0].erase(a[0].begin());
        y = *a[1].begin();
        a[1].erase(a[1].begin());
        z = *a[2].begin();
        a[2].erase(a[2].begin());
        int mx = max({x, y, z});
        int mn = min({x, y, z});
        if (z == mx && x == mn){
            b[z] = 3;
            b[x] = 1;
            b[y] = 2;
        }
        if (z == mx && y == mn){
            b[z] = 3;
            b[x] = 2;
            b[y] = 1;
        }
        if (y == mx && x == mn){
            b[z] = 2;
            b[x] = 1;
            b[y] = 3;
        }
        if (y == mx && z == mn){
            b[z] = 1;
            b[x] = 2;
            b[y] = 3;
        }
        if (x == mx && y == mn){
            b[z] = 2;
            b[x] = 3;
            b[y] = 1;
        }
        if (x == mx && z == mn){
            b[z] = 1;
            b[x] = 3;
            b[y] = 2;
        }
    //    cout << x << " " << y << " " << z << endl;
    }
    dp[0][0] = 1;
    int ans1 = 1;
    int ans2 = 1;
    for (int i = 1; i <= 3 * n; i++){
        if (b[i] == 1){
            cnt[1]++;
        }
        if (b[i] == 2){
            ans1 = ans1 * cnt[1] % mod;
            cnt[2] = (cnt[2] + 1) % mod;
            cnt[1]--;
        }
    //    cout << ans << " " << cnt[1] << endl;
    }
    cnt[1] = 0;
    for (int i = 3 * n; i >= 1; i--){
        if (b[i] == 3){
            cnt[1]++;
        }
        if (b[i] == 2){
            ans2 = ans2 * cnt[1] % mod;
            cnt[2] = (cnt[2] + 1) % mod;
            cnt[1]--;
        }
    //    cout << ans << " " << cnt[1] << endl;
    }
    for (int i = 1; i <= n; i++) ans1 = ans1 * i % mod;
    cout << ans1 * ans2 % mod;
}


Measured memory_bytes: 20756
//String Transformation

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<char, char>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    string s,t;cin>>s>>t;
    vector<int>u(26,-1);
    vector<int>v(26,-1);
    rep(i,0,s.size()){
        if(u[s[i]-'a']==-1){
            u[s[i]-'a']=t[i];
        }else if(u[s[i]-'a']==t[i])continue;
        else{
            cout<<"No"<<nnn;
            return 0;
        }
        if(v[t[i]-'a']==-1){
            v[t[i]-'a']=s[i];
        }else if(v[t[i]-'a']==s[i])continue;
        else{
            cout<<"No"<<nnn;
            return 0;
        }
    }
    cout<<"Yes"<<nnn;
    return 0;
}

Measured memory_bytes: 3872
//shivamkr21
#include<bits/stdc++.h>
#define endl "\n"
#define lli long long int
using namespace std;
int main()
{
	lli n,d;
  	cin>>n>>d;
  	lli a=2*d;
  	a++;
  	if(n%a==0)
    {
      	cout<<n/a<<endl;
    }
  	else
    {
      	cout<<(n/a)+1<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <cassert>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <map>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	if (k == 1) cout << 0 << endl;

	else cout << (n - k) + 1 - 1 << endl;
	return 0;
}


Measured memory_bytes: 256
import math
def isPrime(z):
    if z == 1:
        return False
    if z == 2:
        return True
    for i in range(2, int(z**(1/2))+1):
        if z % i == 0:
            return False
    return True


n = int(input())
pn = 0
for _ in range(n):
    k = int(input())
    if isPrime(k):
        pn += 1
print(pn)


Measured memory_bytes: 5752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9 + 7;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
const int mod = 1e9 + 7;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main() {
    int x, y, s;
    while (cin >> x >> y >> s) {
        if (x == 0 && y == 0 && s == 0) break;
        int mmax = 0;
        rrep(pa, 1, s) { //original a price
            rrep(pb, 1, s) {
                if (pa * (100 + x) / 100 + pb * (100 + x) / 100 != s) continue;
                int sum = pa * (100 + y) / 100 + pb * (100 + y) / 100;
                chmax(mmax, sum);
            }
        }
        cout << mmax << endl;
    }
}



Measured memory_bytes: 3088
#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;
typedef long long ll;


int N;
vector<vector<pair<int, ll>>> to;
vector<int> ans;


void dfs(int u, int v=-1, ll w=0){
    
    for (pair<int,int> k : to[u]) {
        if(k.first == v) continue;
        
        k.second += w;
        if(k.second%2==0) ans[k.first] = 0;
        else ans[k.first] = 1;
    
        dfs(k.first, u, k.second);
    }
    
    
    
}



int main()
{
    cin >> N;
    to.resize(N);
    ans.assign(N,0);
    
    rep(i,N-1){
        int u,v;
        ll w;
        cin >> u >> v >> w;
        u--,v--;
        to[u].push_back(make_pair(v,w));
        to[v].push_back(make_pair(u,w));
    }
    
    
    
    dfs(0);
    
    rep(i,N) cout << ans[i] << endl;
    
    
    
    return 0;
}



Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
int n,m,a[105],tot;
vector<int> ans;
signed main(){
	n=read(); m=read();
	for(int i=1;i<=m;i++){a[i]=read(); if(a[i]&1)tot++;}
	if(m==1){
		if(a[1]==1)cout<<1<<endl<<1<<endl<<1<<endl; else
		if(a[1]&1)cout<<a[1]<<endl<<2<<endl<<a[1]/2<<" "<<a[1]/2+1<<endl;
		else if(a[1]==2)cout<<a[1]<<endl<<2<<endl<<1<<" "<<1<<endl;
		else cout<<a[1]<<endl<<2<<endl<<a[1]/2-1<<" "<<a[1]/2+1<<endl;
		return 0;
	}
	if(tot>2){
		puts("Impossible"); return 0;
	}
	for(int i=2;i<m;i++)if(a[i]&1){
		if(a[1]&1)swap(a[i],a[m]); else swap(a[1],a[i]);
	}
	for(int i=1;i<=m;i++)cout<<a[i]<<" "; puts("");
	a[1]++; a[m]--;
	for(int i=1;i<=m;i++)if(a[i])ans.push_back(a[i]);
	cout<<ans.size()<<endl;
	for(auto i:ans)cout<<i<<" ";
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n;
	cin >> n;
	vector<int>stick(n);
	vector<int>sticks;
	rep(i, n)cin >> stick[i];
	sort(all(stick));
	sticks = stick;
	sort(rall(stick));
	int c, ans = 0;
	rep(i, n-2) {
		for (int j = i + 1; j < n - 1; j++) {
			c = stick[i] - stick[j] + 1;
			auto itr = lower_bound(sticks.begin(), sticks.end() - (j+1), c);
			if (itr == sticks.end() -(j+1))continue;
			ans += (sticks.end() - itr) - (j+1);
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3608
#include <iostream>
using namespace std;
string str[100] = { "KIHBR","AKIHBR","KIHABR","KIHBAR","KIHBRA","AKIHABR",
"AKIHBAR","AKIHBRA","KIHABAR","KIHABRA","KIHBARA",
"AKIHABAR","AKIHABRA","AKIHBARA","KIHABARA","AKIHABARA" }, s;
int main(){
    ios::sync_with_stdio(false);
    cin >> s;
    for (int i = 0; i < 16; i++)
        if (s == str[i])
            return cout << "YES\n", 0;
    cout << "NO\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) REP((i),0,(n))
#define RREP(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rrep(i,n) RREP(i,n,0)
#define each(it,X) for(__typeof((X).begin())  it=(X).begin();it!=(X).end();it++)
#define all(v) ((v).begin(),(v).end())
#define fi first
#define se second
#define pb push_back
typedef pair<int,int>pr;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef set<int>si;
const int INF=1070000000ll;
const int mod=1000000007ll;

int n,fld[20][20];
int p[3][5][5]={
    {{0,1,0,0,0},{1,1,1,0,0},{0,1,0,0,0},{0,0,0,0,0},{0,0,0,0,0}},
    {{1,1,1,0,0},{1,1,1,0,0},{1,1,1,0,0},{0,0,0,0,0},{0,0,0,0,0}},
    {{0,0,1,0,0},{0,1,1,1,0},{1,1,1,1,1},{0,1,1,1,0},{0,0,1,0,0}},
};
bool flag;
bool paint(int h,int w,int s){
    rep(i,5)rep(j,5){
        if(p[s][i][j]==0)continue;
        if(fld[h+i][w+j]==0)return false;
    }

    rep(i,5)rep(j,5){
        if(p[s][i][j]==0)continue;
        fld[h+i][w+j]--;
    }
    return true;
}
void repaint(int h,int w,int s){
    rep(i,5)rep(j,5){
        if(p[s][i][j])fld[h+i][w+j]++;
    }
}

void dfs(int h,int w,int cnt){
    if(h==10){
        if(cnt==0){
            flag=true;
        }
        return;
    }
    int th=(w==9?h+1:h),tw=(w+1)%10;
    rep(i,3){
        if(cnt<=0)break;
        if(paint(h,w,i)){
            dfs(h,w,cnt-1);
            if(flag){
                cout<<w+1+(i==2)<<" "<<h+1+(i==2)<<" "<<i+1<<endl;
                return;
            }
            repaint(h,w,i);
        }
    }

    if(fld[h][w])return;
    dfs(th,tw,cnt);
}
signed main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    cin>>n;
    rep(i,10)rep(j,10)cin>>fld[i][j];
    dfs(0,0,n);
    return 0;
}

Measured memory_bytes: 1196
// AtCoder ABC120: A - Favorite Sound
// 2019.9.9 bal4u
// Template for Online Contest

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

typedef long long ll;

#define gc() getchar()
#define pc(c) putchar(c)

int in() {  // 整数の入力
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

ll inL() {  // long long 整数の入力
	ll n = 0; int c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n) { // 整数の表示
	int i; char b[30];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

void outL(ll n) { // 整数の表示
	int i; char b[30];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

int ins(char *s) { // 文字列の入力
	char *p = s--;
	do *++s = gc();
	while (*s > ' ');
	*s = 0;
	return s - p;
}

void outs(char *s) {  // 文字列の表示
	while (*s) pc(*s++);
}

#define MIN(a,b)  ((a)<=(b)?(a):(b))
#define MAX(a,b)  ((a)>=(b)?(a):(b))
#define ABS(a)    ((a)>=0?(a):-(a))
inline static int chmax(int *a, int b) { if (*a < b) *a = b; }
inline static ll  chmaxL(ll *a, int b) { if (*a < b) *a = b; }
inline static int chmin(int *a, int b) { if (*a > b) *a = b; }
inline static ll  chminL(ll *a, int b) { if (*a > b) *a = b; }

int cmp_int(const void *u, const void *v) { return *(int *)u - *(int *)v; }

int main()
{
	int A, B, C, ans;

	A = in(), B = in(), C = in();
	ans = B/A;
	if (ans > C) ans = C;
	out(ans);
	return 0;
}


Measured memory_bytes: 128
if __name__ == '__main__':
    A, B = map(int, input().split())
    # A, B = 500, 500
    grid = [["#"] * 50 + ["."] * 50 for _ in range(100)]

    n_locatable_elements = (49 - 1) // 2 + 1
    for i in range(A - 1):
        x = 2 * (i % n_locatable_elements)
        y = 2 * (i // n_locatable_elements) + 1
        grid[y][x] = "."

    for i in range(B - 1):
        x = 2 * (i % n_locatable_elements) + 50 + 1
        y = 2 * (i // n_locatable_elements) + 1
        grid[y][x] = "#"

    print("100 100")
    for row in grid:
        print("".join(row))


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

int main()
{
  int N,T,E;
  int x;
  int ans=-1;
  cin>>N>>T>>E;
  for(int i=0;i<N;i++){
    cin>>x;
    int t=T/x;
    for(int t=x;t<=T+E;t+=x){
      if(t<T-E)continue;
      ans=i+1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
x, y = map(int, input().split())

a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
elif x in c and y in c:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9172
package main

import (
  "bufio"
  . "fmt"
  "os"
)

func main() {
  in := bufio.NewReader(os.Stdin)
  out := bufio.NewWriter(os.Stdout)
  defer out.Flush()

  var S, W int
  Fscan(in, &S)
  Fscan(in, &W)
  if S > W {
    Fprintln(out, "safe")
    return
  }
  Fprintln(out, "unsafe")
  return
}

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


int main(){
    int N,K; cin >> N >> K;
    vector<pair<ll, ll>> sushi(N);
    map<ll, ll> type;

    for(int i=0; i<N; i++){
        int t,d; cin >> t >> d;
        sushi[i] = {d, t};
    }

    sort(sushi.begin(), sushi.end(), greater<pair<ll, ll>>());

    ll ans = 0LL;
    ll dsum = 0LL;
    ll tsum = 0LL;
    for(int i=0; i<K; i++){
        dsum += sushi[i].first;
        type[sushi[i].second]++;
    }

    tsum = type.size();
    ans += dsum + tsum*tsum;

    int pre = K-1, nxt = K;
    while(true){
        while(pre>=0 && type[sushi[pre].second]==1) pre--;
        if(pre == -1) break;

        while(nxt<N && type[sushi[nxt].second]!=0) nxt++;
        if(nxt == N) break;

        dsum -= sushi[pre].first;
        dsum += sushi[nxt].first;
        tsum++;
        ans = max(ans, dsum+tsum*tsum);

        type[sushi[pre].second]--;
        type[sushi[nxt].second]++;
        pre--;
    }


    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define PI (acos(-1.0))

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> a;
    vector<int> cost;

    a.push_back(0);

    rep(i,n){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

    a.push_back(0);

    cost.push_back(0);

    int x = 0;

    rep(i,n){
        cost.push_back(cost[i] + abs(a[i + 1] - x));
        x = a[i + 1];
    }

    cost.push_back(cost[cost.size() - 1] + abs(x));

    for(int i = 1; i <= n; i++){
        int ans = (cost[i - 1] - cost[0]) + abs(a[i + 1] - a[i - 1]) + (cost[n + 1] - cost[i + 1]);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 2168
#include<stdio.h>
int main(){

  int a[100000],b[50000],i,j,x,y,count=0,left,right,mid;

  scanf("%d",&x);
  for(i=0;i<x;i++){
    scanf("%d",&a[i]);
    }

  scanf("%d",&y);
  for(i=0;i<y;i++){
    scanf("%d",&b[i]);
  }


  for(i=0;i<y;i++){
    left=0;
    right=x;
    while(left<right){
      mid=(left+right)/2;
      if(a[mid]==b[i]){
	count++;
	break;
      }
	else if(b[i]<a[mid]){
	  right=mid;
	}
	  else left=mid+1;
	}
      }
    
  
	
	printf("%d\n",count);
	
      return 0;
    }
    
      



Measured memory_bytes: 2276
/*

  "With age, comes wisdom. With travel, comes understanding.
   Remember that happiness is a way of travel – not a destination"

*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int             long long int
#define ld              long double
#define F               first
#define S               second
#define pb              push_back
#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpi             vector <pii>
#define vpp             vector <pair<int, pii>>
#define mii             map <int, int>
#define mpi             map <pii, int>
#define spi             set <pii>
#define endl            "\n"
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
     int x = 1;
     while (b)
     {
          if (b & 1) x *= a;
          a *= a;
          b >>= 1;
     }
     return x;
}

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> Set;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int a[N], i, j, n, k;
int dp[N];

void solve()
{
     cin >> n >> k;
     for (i = 1; i <= n; i++)
          cin >> a[i];

     fill(dp, dp + N, 1e9);
     dp[1] = 0;
     for (i = 1; i <= n; i++)
          for (j = 1; j <= k; j++)
               dp[i + j] = min(dp[i + j], abs(a[i + j] - a[i]) + dp[i]);

     cout << dp[n];

}

int32_t main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

     cout << setprecision(9) << fixed;
     clock_t z = clock();
     solve();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

     return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	ll N, x;
  	cin >> N >> x;
  	ll a[N];
  	for(int i=0;i<N;i++) cin >> a[i];

  	sort(a, a+N);

  	int ans = 0;
  	int i = 0;
  	while(i<N-1 &&x>=a[i]){
  		x -= a[i];
  		i++;
  		ans++;
  	}
  	if(i==N-1 && a[N-1]==x) ans++;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

template<class... Args>
auto input(Args&&... args) {
    return InputType2(std::forward<Args>(args)...);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

auto gcd(size_t l, size_t r) {
    if (r == 0)
        return l;
    return gcd(r, l % r);
}

auto gcd(size_t a, size_t b, size_t c) {
    return gcd(a, gcd(b, c));
}

int main() {
    ll a = input();
    ll b = input();
    ll c = input();
    ll k = input();
    auto x = min(a, k);
    k -= x;
    auto y = x;
    x = min(b, k);
    k -= x;
    x = min(c, k);
    k -= x;
    y += -x;
    cout << y << endl;
    return 0;
}


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

int main()
{
  long long int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k<=a)
  {
    cout << k << endl;
  }else if(k>a && k-a<=b)
  {
    cout << a << endl;
  }
  else if(k>a+b && k-a-b<=c)
  {
    cout << a-(k-a-b) << endl;
  }
 return 0; 
}


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

int gcd2(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd2(b, a%b));
   }
}

int gcd3(int a, int b, int c){
  return(gcd2(gcd2(a,b),c));  
}

int main()
{
   int K;
   int sum = 0;
   cin >> K;
   for(int i = 1; i < K+1;i++){
       for(int j = 1; j < K+1; j++){
           for(int k = 1; k < K+1; k++){
              sum += gcd3(i,j,k);
           }
       }
   }

   cout << sum << endl;
   return 0;
}

Measured memory_bytes: 3596
[n, k] = [int(i) for i in input().split()]
s = input()

if (s[k - 1] == 'A'):
    s0 = s[:k - 1] + 'a' + s[k:]
elif (s[k - 1] == 'B'):
    s0 = s[:k - 1] + 'b' + s[k:]
elif (s[k - 1] == 'C'):
    s0 = s[:k - 1] + 'c' + s[k:]

print(s0)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
        int n, m; cin >> n >> m;

        map<int, bool> mp;

        vector<int> v;
        for (int x = 0; x < n; ++x){
            int q; cin >> q;
            v.push_back(q);
            mp[x+1] = true;
        }

        for (int x = 0; x < m; ++x){
            int q, w; cin >> q >> w;

            if (mp[q] == true){
                if (v[q-1] > v[w-1]){
                    mp[q] = true;
                }
                else{
                    mp[q] = false;
                }
            }

            if (mp[w] == true){
                if (v[w-1] > v[q-1]){
                    mp[w] = true;
                }
                else{
                    mp[w] = false;
                }
            }
        }

        int cnt = 0;
        for (auto x : mp){
            if (x.second == true){
                cnt++;
            }
        }

        cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 8316
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    String w = sc.next();

    sc.close();

    String[] W = w.split("");
    
    HashMap<String, Integer> hashMap = new HashMap<>();

    for (int i = 0; i < W.length; i++) {
      if (hashMap.containsKey(W[i])) {
        int v = hashMap.get(W[i]);
        hashMap.put(W[i], v + 1);
      } else {
        hashMap.put(W[i],1);
      }
    }

    boolean valid = true;

    for (int i = 0; i < W.length; i++) {
      int v = hashMap.get(W[i]);
      if (v % 2 != 0) {
        valid = false;
        break;
      }
    }

    if (valid) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }

}

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

int main(){
    int n;
    cin >> n;
    int min,max;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        if(i==0){min=a;max=a;}
        if(min>a){min=a;}
        if(max<a){max=a;}
    }
    cout << max-min << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()

WBWB = []
phase = 'W'
count = 0
for i in range(len(S)):
    if S[i] == 'W' and phase == 'B':
        WBWB.append(count)
        phase = 'W'
        count = 0
    if S[i] == 'B' and phase == 'W':
        WBWB.append(count)
        phase = 'B'
        count = 0
    count += 1
WBWB.append(count)
temp = []
if WBWB[0] == 0:
    WBWB = WBWB[1:]

if len(WBWB) == 0:
    ans = 0
else:
    ans = len(WBWB) - 1

print(ans)

Measured memory_bytes: 4724
#include "bits/stdc++.h"
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        int n;
        cin>>n;
        string str;
        map < string, int > m;
        for(int i = 0; i < n; ++i){
            cin >> str;
            m.insert({str,++m[str]});
        }
        int max = 0;
        for (auto itr = m.begin(); itr != m.end(); ++itr) { 
            if((*itr).second > max)
                max = (*itr).second;
        }
        for (auto itr = m.begin(); itr != m.end(); ++itr) { 
            if((*itr).second == max)
                cout << (*itr).first << endl; 
        }
    }
    return 0;
}



Measured memory_bytes: 23808
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

int dp[100005];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int N;
    cin >> N;
    vector<int> h(N);
    rep(i, N) cin >> h[i];

    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for (int i = 2; i < N; ++i) {
        dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
    }

    cout << dp[N-1] << endl;

    return 0;
}


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

using namespace std;

int main(){
  int w,h;
  char c;
  cin >> w>> h>>c;
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      if(i==0 || i==h-1){
	if(j==0 || j==w-1) cout << "+";
	else cout << "-";
      }
      else if(j==0 || j==w-1) cout << "|";
      else if(i==h/2 && j==w/2) cout << c;
      else cout << ".";
    }
    cout << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int dp[201010];
int main(){
    int n;
    cin>>n;
    int P[n];
    rep(i,n) cin>>P[i];

    int ans=0;
    rep(i,n){
        int p=P[i];
        dp[p]=dp[p-1]+1;
        ans=max(ans,dp[p]);
    }

    cout<<n-ans<<endl;
}


 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define inf 1e9+10
#define eps 1e-7
using namespace std;
inline ll read(){
	ll x=0;ll f=1;char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)) {x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,k;
ll ans;
int main(){
	n=read();k=read();
	ll sum=n/k;
	ans+=sum*sum*sum;
	if(k%2==0&&k<=2*n){
		sum=(n-k/2)/k;
		if(k!=1) sum++;
		ans+=sum*sum*sum;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
def read(): return list(map(int, input().split()))


def main():
    s = input()
    if len(s) < 4:
        print("No")
        return

    for i in range(4):
        if s[i] != "YAKI"[i]:
            print("No")
            return

    print("Yes")


if __name__ == '__main__':
    main()

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

int main(){
    int x, y;
    cin >> x >> y;
    const int MAX = 1e9 + 7;
    int ans = 2 * MAX;
    int cur = x, cnt = 0;

    while(cur < MAX){
        if(cur == y)ans = min(ans, cnt);
        if(cur == -y)ans = min(ans, cnt + 1);
        ++cur, ++cnt;
    }
    
    cur = -x,cnt = 1;
    while(cur < MAX){
        if(cur == y)ans = min(ans, cnt);
        if(cur == -y)ans = min(ans, cnt + 1);
        ++cur, ++cnt;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
/* Life is all about calculated risks.
    But man am I bad at math. */

#include <bits/stdc++.h> 
#define ll long long int
#define INF (ll)1e12
#define MOD 1000000007

#define DEBUG(x) cerr<<"> "<< #x << ':' <<x<<endl;

using namespace std;

ll f(ll st, ll end);

ll n;
ll a[3010];

vector<vector<ll>> dp(3010, vector<ll>(3010, -1));

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

    cin>>n;
    for(ll i=1; i<=n; i++)
    {
        cin>>a[i];
    }

    ll X = f(1,n);
    ll Y = min( f(2,n) , f(1,n-1) );

    cout<<X-Y<<endl;

    return 0;
}

ll f(ll st, ll end)
{
    if(dp[st][end] != -1)
    {
        return dp[st][end];
    }

    if(st > end)
    {
        return 0;
    }

    return dp[st][end] = max( a[st] + min(f(st+2,end),f(st+1,end-1)) , a[end] + min(f(st+1,end-1),f(st,end-2)) );
}

Measured memory_bytes: 71296
#include<iostream>
#define N 105000
#define P 1000000007
using namespace std;
long long   n,m,x[N],y[N],h[N],w[N],t,tl;
long long sum,ans;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>m;
    cin>>tl;
    for(int i=1;i<n;i++)
    {
        cin>>t;
        w[i]=t-tl;
        x[i]=i*(n-i)%P;
        tl=t;
    }
    cin>>tl;
    for(int j=1;j<m;j++)
    {
        cin>>t;
        h[j]=t-tl;
        y[j]=j*(m-j)%P;
        tl=t;
    }
    for(int j=1;j<m;j++)
        sum=(sum+1LL*y[j]*h[j]%P)%P;
    for(int i=1;i<n;i++)
        ans=(ans+1LL*x[i]*w[i]%P*sum)%P;
    ans=(ans+P)%P;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3456
import Foundation
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
let nd=readInts()
let n=nd[0]
let d=nd[1]
var count=0
var xy:[[Int]]=[]
for _ in 1...n{
  let a=readInts()
  xy.append(a)
}
for i in 0...n-2{
  for j in i+1...n-1{
    var distance=0
    for k in 0...d-1{
      distance+=(xy[i][k]-xy[j][k])*(xy[i][k]-xy[j][k])
    }
    if Double(sqrt(Double(distance)))-Double(Int(sqrt(Double(distance))))==0.0{
      count+=1
    }
  }
}
print(count)

Measured memory_bytes: 13656
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  string s;
  int k;
  cin >> s;
  cin >> k;
  vector<string> ss;
  int n = s.size();
  REP(i,0,n) {
    REP(j,1,k+1) {
      ss.push_back(s.substr(i,j));
    }
  }
  sort(ss.begin(), ss.end());
  unique(ss.begin(), ss.end());
  cout << ss[k-1] << endl;

  return 0;
}


Measured memory_bytes: 1660
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const gojo=(a:number,b:number):number=>{if(a%b===0)return b;return gojo(b,a%b)};
const main=()=>{
  let [n,k]=tnn(2)
  let l=desc(tnn(n))
  let a=0
  for(let i=0;i<k;i++)a+=l[i]
  to(a)
}
main()

Measured memory_bytes: 7372
#include<cstdio>
bool dp[100001];
int main(){
    int n,k,a[100];
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=0;i<=k;i++){
        dp[i]=false;
        for(int j=0;j<n&&a[j]<=i;j++){
            if(!dp[i-a[j]]){
                dp[i]=true;
                continue;
            }
        }
    }
    printf("%s\n",dp[k]?"First":"Second");
    return 0;
}

Measured memory_bytes: 256
public class Main{
	void qq(){
		for(int i=1; i<10; i++){
			for(int j=1; j<10; j++){
				System.out.println(i+"x"+j+"="+i*j);
			}
		}
	}
	
	public static void main(String[] args){     
		new Main().qq();     
		} 
	}
	

Measured memory_bytes: 16856