akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

int main() {
	string s;
	cin >> s;
	int n = s.size();

  if(n==1 || n%2==1){
    cout<<"No"<<endl;
    return 0;}
  
	for (int i = 0; i <= n - 1; i++) {
		if(i%2==0){
          if(s[i]!='h'){cout<<"No"<<endl;
                        return 0;}
        }
          if(i%2==1){
            if(s[i]!='i'){
              cout<<"No"<<endl;
              return 0;}
          }
	}

	cout << "Yes" << endl;
		return 0;
}


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

int main(){
    int N;
    cin >> N;
    int a[N];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }

    sort(a, a+N);
    cout << a[N-1] - a[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string oddeven(long long x){
  long long a;
    a=x/2;
  if(a*2==x){
  return "even";
  }
  else{
  return "odd";
  }
}
int main(){
  long long H,W;
  cin>>H>>W;
  string a,b;
  a=oddeven(H);
  b=oddeven(W);
  if(H==1 || W==1){
  cout<<1<<endl;
  }
  else if(a=="odd" && b=="odd"){
    cout<<H*(W-1)/2+H/2+1<<endl;
  
  }
  else{
  cout<<(H*W)/2<<endl;
      
  }
}

Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pII;
#define pb push_back
#define mp make_pair
#define clr(x,y) memset(x,y,sizeof(x))
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=1e6+5;
//ll fmod(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;}return res;}
//ll gcd(ll x,ll y){return y==0?x:gcd(y,x%y);}
int main()
{
    ll n,m;
    while(cin>>n>>m)
    {
        if(min(n, m) == 1)
        {
            if(max(n, m) == 1)
                cout<<1<<endl;
            else
            cout<<max(n, m) - 2<<endl;
        }
        else
        {
            cout<<(n - 2)*(m - 2)<<endl;
        }
    }

}
















Measured memory_bytes: 256
from collections import deque

def isOneColor(w):
    sw = sorted(w)
    if sw[0] == sw[-1]:
        return True
    else:
        return False

def nextColor(c1, c2):
    cs = ['r', 'g', 'b']
    cs.remove(c1)
    cs.remove(c2)
    return cs[0]

def bfs(iw):
    q = deque()
    s = set()

    s.add(str(iw))
    q.append([iw, 0])
    while q:
        w, t = q.popleft()
        if isOneColor(w):
            return t
        else:
            for i in range(len(w)-1):
                if w[i] != w[i+1]:
                    nw = w.copy()
                    nc = nextColor(nw[i], nw[i+1])
                    nw[i], nw[i+1] = nc, nc
                    if str(nw) not in s:
                        s.add(str(nw))
                        q.append([nw, t+1])

    return -1

if __name__ == '__main__':
    while True:
        w = list(input())
        if w == ['0']:
            break

        t = bfs(w)
        if t == -1:
            print('NA')
        else:
            print(t)

Measured memory_bytes: 10396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

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

    vector<string> vec;
    for (int i = 0; i < s.length(); i++) {
        for (int j = 1; j <= K; j++) {
            vec.push_back(s.substr(i, j));
        }
    }

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

    int cnt = 0;
    for (int i = 0; i < vec.size(); i++) {
        if (i == 0 || vec.at(i) != vec.at(i - 1)) cnt++;
        if (cnt == K) {
            cout << vec.at(i) << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1660
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define R(i,a,b) for (int i=(a);i<(b);i++)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define N 500055
#define int ll
using namespace std;
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 int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,ans,a[30];
char str[N];
signed main(){
	n=read();
	scanf("%s",str+1);
	F(i,1,n) a[str[i]-'a']++;ans=1;
	F(i,0,25) ans=1ll*ans*(a[i]+1)%mod; 
	ans=(ans-1+mod)%mod;
	wrn(ans);
	return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pb push_back
#define N 200003
#define inf (ll)1e9+1
#define warmup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7; 
int cnt[10][10];
ld eps=1e-1;

int power(int b,int p)
{
    int r=1;
    while(p)
    {
        if(p&1)
            r*=b;
        b*=b;
        p>>=1;
    }   
    return r;
}   

signed main()
{
    warmup
    
    int n;
    cin>>n;
    int i,j;
    for(i=1;i<=n;++i)
        ++cnt[i%10][i/power(10,floor(log10(i)))];
    
    int ans=0;
    for(i=0;i<=9;++i)
        for(j=0;j<=9;++j)
            ans+=cnt[i][j]*cnt[j][i];
        
    cout<<ans;
    
    
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a < b && b < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();

    }
}


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

#define ll long long
#define ull unsigned ll

#define vi vector <int>
#define ii pair <int, int>
#define vii vector <ii>
#define INFLL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0


int main ()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout.tie(NULL);

    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    
    int n;
    cin >> n;
    ll mul = 1;
    vector <ll> num(n);
    bool zero = false;
    for (int i=1; i<=n; i++){
        ll a;
        cin >> a;
        num[i-1] = a;
        if (a == 0) zero = true;

    }
    if (zero) {cout << 0 << endl; return 0;}

    bool flag = true;
    for (int i=0; i<n; i++){
        mul *= num[i];
        if (mul >= 1e18 || mul < 1){
            if (mul != 1000000000000000000){
                flag = false;
                break;
            }
            
        }
    }

    if (!flag) cout << -1 << endl;
    else cout << mul << endl;
    return 0;
}

Measured memory_bytes: 3924
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
const Int MAX = 305;
Int ex[MAX*2][MAX*2];
Int dp[MAX*2+2][MAX*2+2];
signed main(){
  Int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(Int i=0;i<h;i++) cin>>s[i];

  using P = pair<int, int>;
  vector<P> vp;
  memset(ex,0,sizeof(ex));
  for(Int i=0;i<h;i++){
    for(Int j=0;j<w;j++){
      if(s[i][j]!='#') continue;
      vp.emplace_back(1+i+j,1+i-j+w);
      ex[1+i+j][1+i-j+w]=1;      
    }
  }
  
  auto ch=
    [&](Int i,Int j)->Int{
      if(i<0||i>=MAX*2) return 0;
      if(j<0||j>=MAX*2) return 0;
      return ex[i][j];
    };
  
  const int LIM = h+w;
  Int ans=0;
  for(Int k=1;k<=LIM;k++){
    for(Int i=0;i<MAX*2;i++)
      for(Int j=1;j<MAX*2;j++)
        dp[i][j+1]=dp[i][j]+(ch(i,j)&&ch(i,j-k));

    for(P p:vp){
      int i,j;
      tie(i,j)=p;
      if(i-k>=0)  ans+=dp[i-k][min(MAX*2-1,j+k+1)]-dp[i-k][j];
      if(i+k<MAX*2) ans+=dp[i+k][min(MAX*2-1,j+k+1)]-dp[i+k][j];
    }

    for(Int j=0;j<MAX*2;j++)
      for(Int i=0;i<MAX*2;i++)
        dp[j][i+1]=dp[j][i]+(ch(i,j)&&ch(i-k,j));
    
    for(P p:vp){
      int i,j;
      tie(i,j)=p;
      if(j-k>=0)  ans+=dp[j-k][min(MAX*2-1,i+k+1)]-dp[j-k][i];
      if(j+k<MAX*2) ans+=dp[j+k][min(MAX*2-1,i+k+1)]-dp[j+k][i];   
    }            
  }

  //cout<<ans<<endl;
  if(1){
    for(Int i=0;i<MAX*2;i++){
      for(Int j=0;j<MAX*2;j++){
        if(!ex[i][j]) continue;
        for(Int k=1;k<=LIM;k++){
          if(ch(i+k,j)&&ch(i,j+k)) ans--;
          if(ch(i+k,j)&&ch(i,j-k)) ans--;
          if(ch(i-k,j)&&ch(i,j+k)) ans--;
          if(ch(i-k,j)&&ch(i,j-k)) ans--;
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 7032
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

char grid[1002][1002];

int solve(int n, int m)
{
	ll dp[n + 1][m + 1];
	dp[n][m] = 1;
	for (int i = n; i >= 1; i--)
	{
		for (int j = m; j >= 1; j--)
		{
			if (i == n and j == m)
				continue;
			if (grid[i][j] == '#')
				dp[i][j] = 0;
			else
				dp[i][j] = (((i == n) ? 0 : dp[i + 1][j]) +  ((j == m) ? 0 : dp[i][j + 1])) % mod;
		}
	}
	return dp[1][1];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			cin >> grid[i][j];
		}
	}
	cout << solve(n, m);
}

Measured memory_bytes: 12428
#include <stdio.h>
int main(void){
    int H,W,i,j;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0)break;
        for(i=1;i<=H;i++){
            for(j=1;j<=W;j++){
                if(i%2==1){
                    if(j%2==0)printf(".");
                    else printf("#");
                }
                else{
                    if(j%2==0)printf("#");
                    else printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2048
# include <bits/stdc++.h>
using namespace std;
 
const int N = 1e5+3;
vector<int>v[N];
bool vis[N];
list<int>L;
 
void tzg(int u, bool des)
{
    for(int i=0; i<v[u].size(); ++i)
    {
        int e = v[u][i];
        if(!vis[e])
        {
            if(des) L.push_front(e);
            else L.push_back(e);
            vis[e] = true;
            tzg(e, des);
            return;
        }
    }
}
int main()
{
    int n, m, a, b;
    scanf("%d%d",&n,&m);
    while(m--)
    {
        scanf("%d%d",&a,&b);
        v[a].push_back(b);
        v[b].push_back(a);
    }
    L.push_back(1);
    L.push_back(v[1][0]);
    vis[1] = vis[v[1][0]] = true;
    tzg(1,true);
    tzg(v[1][0], false);
    printf("%d\n",L.size());
    for(auto it=L.begin(); it!=L.end(); ++it)
        printf("%d ",*it);
    printf("\n");
    return 0;
}


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

int main(){
  ll N;
  cin >> N;
  
  ll xpy[N], xmy[N];
  
  for (int i = 0; i < N; i++){
    ll X,Y;
    cin >> X >> Y;
    
    xpy[i] = X+Y;
    xmy[i] = X-Y;
  }
  sort(xpy, xpy+N);
  sort(xmy, xmy+N);
  
  cout << max((xpy[N-1]-xpy[0]),(xmy[N-1]-xmy[0])) << endl;
  
  return 0;
}

Measured memory_bytes: 6760
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;

int main() {
	int N, A, B;
	cin >> N;
	cin >> A;
	cin >> B;
	N -= A;
	N %= B;
	cout << N << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define INF 1e9
typedef long long llong;
using namespace std;

int main(){
	llong a,b;
	cin>>a>>b;
	
	llong ans=0;
	for(llong i=a;i<=a+(3-a%4);++i) ans^=i;
	for(llong i=b-b%4;i<=b;++i) ans^=i;
	
	cout<<ans<<endl;
	return 0;
}//ABC121_d.復習.解答参考.

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

using namespace std;

int N, M;
constexpr auto none = numeric_limits<double>::max();

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N >> M;
  vector<vector<int>> edges(N);
  for (int i = 0; i < M; ++i) {
    int s, t;
    cin >> s >> t;
    --s;
    --t;
    edges[s].push_back(t);
  }

  vector<vector<double>> costs(N, vector<double>(N + 1, none));
  fill(costs[N - 1].begin(), costs[N - 1].end(), 0.);
  for (int i = N - 2; i >= 0; --i) {
    int num_edges = edges[i].size();
    for (int j = i + 1; j <= N; ++j) {
      if (j == N || costs[j][j] != none) {
        costs[i][j] = 0.;
        for (auto next : edges[i]) {
          costs[i][j] += (1. + costs[next][j]) / num_edges;
        }
      }
    }
    fill_n(costs[i].begin(), i, costs[i][N]);
    if (num_edges > 1) {
      for (int j = 0; j < num_edges; ++j) {
        double cost = 0.;
        for (int k = 0; k < num_edges; ++k) {
          if (j != k) {
            cost += (1. + costs[edges[i][k]][i]) / (num_edges - 1);
          }
        }
        costs[i][i] = min(costs[i][i], cost);
      }
    }
  }

  auto result = none;
  for (auto v : costs[0]) {
    result = min(result, v);
  }
  cout << setprecision(15) << result << endl;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x;
  cin>>x;
  bool f=1;
  int n=x-1;
  while(f){
    n++;
    f=0;
    for(int i=2;i*i<=n;i++){
      if(n%i==0){
        f=1;
        break;
      }
    }
  }
  cout<<n<<endl;
}

Measured memory_bytes: 256
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
a,b = map(int,input().split())

ans1 = a + b
ans2 = a - b
ans3 = a*b

ans = max(ans1,ans2,ans3)

print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif

using namespace std;

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

constexpr int MAX_SIZE = 50;
constexpr int MAX_S = 10;

int w, h;
int sx, sy, gx, gy;

string field[MAX_SIZE];
bool initial_floar[MAX_SIZE][MAX_SIZE];
int match[MAX_SIZE][MAX_SIZE];
int dist[MAX_SIZE][MAX_SIZE][2][1 << MAX_S];

bool get_floor(int x, int y, int s) {
	return (__builtin_popcount(match[y][x] & s) + initial_floar[y][x]) & 1;
}

int bfs() {
	typedef tuple<int, int, bool, int> state; // x, y, floor, switch state
	constexpr int dx[] = {1, 0, -1, 0};
	constexpr int dy[] = {0, 1, 0, -1};

	queue<state> que;
	fill_n((int *)dist, sizeof(dist) / sizeof(int), INT_MAX);
	dist[sy][sx][0][0] = 0;
	que.push(state(sx, sy, 0, 0));

	while(!que.empty()) {
		int x, y, s;
		bool f;
		tie(x, y, f, s) = que.front();
		que.pop();

		const int &d = dist[y][x][f][s];

		dump(x, y, f, s, d);

		if(field[y][x] == '|') {
			if(dist[y][x][!f][s] > d + 1) {
				dist[y][x][!f][s] = d + 1;
				que.push(state(x, y, !f, s));
			}
		}

		if(islower(field[y][x])) {
			const int next_s = s ^ (1 << (field[y][x] - 'a'));
			const bool next_f = get_floor(x, y, next_s);

			if(dist[y][x][next_f][next_s] > d + 1) {
				dist[y][x][next_f][next_s] = d + 1;
				que.push(state(x, y, next_f, next_s));
			}
		}

		rep(dir, 4) {
			const int nx = x + dx[dir];
			const int ny = y + dy[dir];

			if(field[ny][nx] == '#') continue;
			if(field[ny][nx] != '|' && f != get_floor(nx, ny, s)) continue;

			if(dist[ny][nx][f][s] > d + 1) {
				if(nx == gx && ny == gy) return d + 1;
				dist[ny][nx][f][s] = d + 1;
				que.push(state(nx, ny, f, s));
			}
		}
	}

	return -1;
}

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

	cin >> w >> h;

	rep(i, h) {
		cin >> field[i];

		rep(j, w) {
			switch(field[i][j]) {
			case '%':
				sx = j;
				sy = i;
				break;
			case '&':
				gx = j;
				gy = i;
				break;
			case '^':
				initial_floar[i][j] = 1;
				break;
			default:
				if(isupper(field[i][j])) {
					initial_floar[i][j] = 1;
					field[i][j] = tolower(field[i][j]);
				}
			}
		}
	}

	int s;
	cin >> s;

	rep(k, s) {
		rep(i, h) {
			string row;
			cin >> row;

			rep(j, w) {
				if(row[j] == '*') {
					match[i][j] |= (1 << k);
				}
			}
		}
	}

	cout << bfs() << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 21832
from collections import deque
from itertools import product
h, w = map(int, input().split())
si, sj = map(lambda x: int(x)-1, input().split())
gi, gj = map(lambda x: int(x)-1, input().split())
fld = ''.join([input()for _ in range(h)])
INF = 10**18


def to_v(i, j):
    return i*w+j


n = h*w
start = to_v(si, sj)
goal = to_v(gi, gj)


def generate_v2(v):
    i, j = divmod(v, w)
    it = [-2, -1, 0, 1, 2]
    for di, dj in product(it, repeat=2):
        x, y = i+di, j+dj
        if x < 0 or h <= x or y < 0 or w <= y:
            continue
        if (di, dj) in [(-1, 0), (1, 0), (0, -1), (0, 1), (0, 0)]:
            d = 0
        else:
            d = 1
        yield d, x*w+y


def bfs(init_v):
    next_v = deque([init_v])
    INF = 10**18
    dist = [INF]*n
    dist[init_v] = 0
    visited = [0]*n
    while next_v:
        v = next_v.popleft()
        if visited[v]:
            continue
        visited[v] = 1
        for d, v2 in generate_v2(v):
            if fld[v2] == '#':
                continue
            if dist[v2] <= dist[v]+d:
                continue
            dist[v2] = dist[v]+d
            if d:
                next_v.append(v2)
            else:
                next_v.appendleft(v2)
    return dist


ans = bfs(start)[goal]
print(-1 if ans == INF else ans)


Measured memory_bytes: 106408
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int A, B, K; cin >> A >> B >> K;
    rep(i, A, B+1) {
      if (i < A+K or B-K < i) cout << i << endl;
    }
}


Measured memory_bytes: 256
N = int(input())
l = []
for i in range(N):
    t = int(input())
    l.append(t)

# 最大公約数と最小公倍数
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)

def multiple(a, b):
    return a*b // euclid(a, b)

import functools

# N個の最小公倍数
# euclidとmultipleが必要

def lcm(nums):
        return functools.reduce(multiple, nums)

print(lcm(l))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  int n;
  cin >> n;
  vector<int>b(n);
  rep(i,n)cin >> b[i];
  vector<int>ans;
  int sz = n;
  while(!b.empty()){
    int B = -1;
    rep(i,sz)if(b[i] == i + 1)B = i;
    if(B == -1){
      cout << -1 << endl;
      return 0;
    }
    ans.push_back(B + 1);
    b.erase(b.begin() + B);
    sz--;
  }
  reverse(all(ans));
  rep(i,n)cout << ans[i] << endl;

  return 0;
}


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

int main(){
	
	int n; scanf("%d",&n);
	
	multiset<int> mul;
	
	for(int i = 0 ; i < n ; i++){
		int temp ; scanf("%d",&temp);
		
		auto indx = mul.lower_bound(temp);
		if(indx != mul.begin()){
			indx--;
			mul.erase(indx);
			mul.insert(temp);
		}
		else
			mul.insert(temp);
		
	}
	cout << (int) mul.size() << endl;
	
	return 0;
}


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

int main() {
  string s;
  cin >>s;
  int count_A,count_B;
  for(int i = 0;i < s.size();i++){
      if(s.at(i) == 'A'){
          count_A = i;
          break;
      }
  }
  for(int i = s.size()-1;i > -1;i--){
      if(s.at(i) == 'Z'){
          count_B = i;
          break;
      }
  }
  cout << count_B - count_A +1 << endl;;
  
}

Measured memory_bytes: 640
def listConvert(baseList):
  maxNum = max(baseList)
  newList = [0] * (maxNum + 1)
  for a in baseList:
    newList[a] += 1
  return newList

def mainFunc(baseList):
  if baseList[0] != 0:
    return 0

  newList = listConvert(baseList)
  if newList[0] > 1:
    return 0
  if newList.count(0) > 0:
    return 0

  result = 1
  preA = 1
  mod = 998244353
  for a in newList:
    result = (result * pow(preA, a)) % mod
    preA = a
  return result

n = int(input())
baseList = list(map(int, input().split()))

print(mainFunc(baseList))


Measured memory_bytes: 14020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

struct timer {
    std::chrono::system_clock::time_point start, end;

    timer() {
        start = std::chrono::system_clock::now();
    }

    double get() {
        end = std::chrono::system_clock::now();
        return std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
    }
};

int D;
int c[26], s[365][26], t[365], last[26], ans[366];

void calc() {
    for (int i = 0; i < D; ++i) {
        ans[i + 1] = ans[i] + s[i][t[i]];
        last[t[i]] = i + 1;
        for (int j = 0; j < 26; ++j)
            ans[i + 1] -= c[j] * (i + 1 < last[j] ? i + 1 : i + 1 - last[j]);
    }
}

void change(int d, int q) {
    int old = t[d];
    if (old == q)
        return;

    t[d] = q, last[old] = 0, last[q] = 0;
    int dif = 0, pos1 = 0, pos2 = 0;
    for (int i = 0; i < D; ++i) {
        last[t[i]] = i + 1;
        if (i < d)
            pos1 = last[q], pos2 = last[old];
        else {
            ans[i + 1] += s[d][q] - s[d][old];
            if (last[q] == d + 1)
                dif += c[q] * (d + 1 - pos1);
            if (last[old] <= d + 1)
                dif -= c[old] * (d + 1 - pos2);
        }
        ans[i + 1] += dif;
    }
}

void greedy() {
    for (int i = 0; i < D; ++i) {
        ans[i + 1] = INT_MIN;
        int maidx = 0;
        for (int k = 0; k < 26; ++k) {
            int res = ans[i] + s[i][k], old = last[k];
            last[k] = i + 1;
            for (int j = 0; j < 26; ++j)
                res -= c[j] * (i + 1 - last[j]);

            if (ans[i + 1] < res) {
                ans[i + 1] = res;
                maidx = k;
            }
            last[k] = old;
        }
        t[i] = maidx;
        last[t[i]] = i + 1;
    }
}

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

    cin >> D;
    for (int i = 0; i < 26; ++i)
        cin >> c[i];
    for (int i = 0; i < D; ++i)
        for (int j = 0; j < 26; ++j)
            cin >> s[i][j];

    greedy();
    std::mt19937_64 gen(0);
    std::uniform_int_distribution<> dist1(1, D);
    std::uniform_int_distribution<> dist2(1, 26);

    timer tm;
    while (tm.get() < 1800) {
        stack<pii> stk;
        int pres = ans[D];
        for (int j = 0; j < 1300; ++j) {
            int d = dist1(gen), q = dist2(gen);
            d--, q--;
            stk.emplace(pii{d, t[d]});
            change(d, q);
            if (ans[D] >= pres)
                break;
        }
        if (ans[D] < pres) {
            while (!stk.empty()) {
                auto [d, q] = stk.top();
                change(d, q);
                stk.pop();
            }
        }
    }
    for (int i = 0; i < D; ++i)
        cout << t[i] + 1 << '\n';

    return 0;
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

vector<vector<ll>> g(100010); 
vector<ll> dist(100010);

int main(){
    ll n, z, w;
    cin >> n >> z >> w;

    ll a[n];
    rep(i, n)cin >> a[i];

    if(n == 1)cout << abs(w - a[0]);
    else cout << max(abs(w-a[n-1]), abs(a[n-2] - a[n-1]));
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
#include<cstdio>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = (1 << 31) - 1;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, ans = 0, w, l;
double A, B, OK, NG, MID, X;

bool check(double K) {
	double T;
	if (tan(K) < B / A) {
		T = A * A * B - A * A * A * tan(K) / 2;
	}
	else {
		T = A * B * B / (2*tan(K));
	}

	//cout << T << endl;

	if (T > X)return true;
	return false;
}

void input() {
	cin >> A >> B >> X;
}


void solve() {
	double pi = 3.14159265248979;
	OK = pi / 2;
	NG = 0;
	q = 40;
	while (q--) {
		MID = (OK + NG) / 2;
		if (check(MID))NG = MID;
		else OK = MID;
	}


	printf("%.10f\n", OK * (180 / pi));
}

int main() {
	input();
	solve();
} 

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:u32 = read();
    let a:Vec<u32> = (0..n).map(|_| read()).collect();
    let mut b:Vec<(u32,u32)> = vec![];

    for i in (0..n) {
        b.push((a[i as usize], i));
    }
    //println!("{:?}", b);

    b.sort();
    for e in b.iter() {
        print!("{} ", e.1+1);
    }
    println!("");
    
}

Measured memory_bytes: 6908
#include <bits/stdc++.h>
#include <chrono>
#define fr first
#define sc second
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
const ll md = 1000000007;

ll ad(ll a, ll b) {
    return (a%md + b%md + md) % md;
}

ll ml(ll a, ll b) {
    return ( (a%md) * (b%md) ) % md;
}

ll pw(ll x, ll n) {
    ll res = 1;
    x %= md;
    while (n) {
        if (n & 1)  res = (res*x)%md;
        x = (x*x)%md;
        n >>= 1;
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll n, k, dn = 0, cur, ans = 0, cnt = 0;
    unordered_map<int, int> m;
    cin >> n >> k;
    vl a(10000);
    for(int i = 1; i <= k; i = cur + 1) {
        cur = k/(k/i);
        m[cur] = dn;
        a[dn++] = cur;
    }
    vl dp(dn, 0);
    for(int i = dn - 1; i >= 0; i--) {
        dp[i] = pw(k/a[i], n);
        for(int j = 2*a[i]; j <= k; j = (cur/a[i] + 1)*a[i]) {
            cur = k / (k / j);
            dp[i] -= ((cur-j)/a[i] + 1) * dp[m[cur]];
            dp[i] %= md;
            if(dp[i] < 0) dp[i] += md;
        }
        if(i == 0) {
        	ans += ((a[i]*(a[i]+1))/2) * dp[i];
        } else {
        	ans += ((a[i]*(a[i]+1))/2 - (a[i-1]*(a[i-1]+1))/2) * dp[i];
        }
        ans %= md;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3720
import sys
from fractions import gcd

N=input()
A=map(int, sys.stdin.readline().split())

mod=10**9+7
def lcm(a, b):
    g=gcd(a, b)
    return a*b/gcd(a, b)

lc=1
for a in A:
    lc=lcm(lc,a)

ans=0
for a in A:
    b=lc*pow(a,mod-2,mod)
    ans+=b

print ans%mod

Measured memory_bytes: 35864
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>

int main()
{
	long long n;

	std::cin >> n;

	std::vector<long long> v(n), v2(n);

	for (size_t i = 0; i < n; i++)
	{
		std::cin >> v[i];
	}

	for (size_t i = 0; i < n; i++)
	{
		std::cin >> v2[i];
	}

	v2[0] += v[0];

	for (size_t i = 1; i < n; i++)
	{
		v[i] += v[i - 1];
		v2[i] += std::max(v[i], v2[i - 1]);
	}



	std::cout << v2[n - 1] << std::endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;

int main(){
    int K, A, B;
    cin >> K >> A >> B;
    int k = K;
    while(K<=1000){
        if(K>=A&&K<=B){
            cout << "OK" << endl;
            return 0;
        }
        K +=k;
    }
    cout << "NG" << endl;
    return 0;
 }



Measured memory_bytes: 3592
#include <iostream>

int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a < b && b < c) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int N;
    long long int K;
    cin >> N >> K;
    vector<long long int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A.at(i);
    }
    vector<int> cnt(60);
    for(int j=0; j<60; j++) {
        for(int i=0; i<N; i++) {
            cnt.at(j) += (A.at(i) >> j) & 1;
        }
    }

    int keta;
    for(int k=0; k<60; k++) {
        if(K >> k == 0) {
            keta = k;
            break;
        }
    }

    long long int Ktmp = 0;
    for(int k=keta; k>=0;k--) {
        if(cnt.at(k) <= N/2) {
            Ktmp ^= (1LL << k);
            if(Ktmp > K) {
                Ktmp ^= (1LL << k);
            }
        }
    }

    long long int ans = 0;
    for(int i=0; i<N; i++) {
        ans += Ktmp^A.at(i);
    }
    cout << ans << endl;
    return 0;
}


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

// macro
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define MOD 1000000007
#define ll long long

using namespace std;

int main() {
    ll x;
    cin >> x;
    ll d = x % 11;
    if(d == 0) {
      cout << x/11*2;
    } else if(d < 7) {
      cout << (x-d)/11*2+1;
    } else {
      cout << (x-d)/11*2+2;
    }
    cout << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
     
    int main(void){
        int k ,x; cin >> k >> x;
        for(int i=max(-1000000,x-k+1);i<=min(1000000,x+k-1);i++){
            cout << i<<" ";
        }
        cout << endl;
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)


//template functions
/////////////////////////
long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}
long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}
long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

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


//Answer


int main() {

long r;
cin>>r;
cout<<r*r<<endl;


}


Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>


int main()
{
    int n;
    scanf("%d", &n);
    std::vector<int> a(n);
    for (int i = 0; i < n; ++ i)
        scanf("%d", &a[i]);
    std::sort(a.begin(), a.end());
    int x = 0, y = 0;
    for (int i = n - 1; i >= 0; -- i) {
        if (i > 0 && a[i] == a[i - 1]) {
            if (x == 0) x = a[i];
            else if (y == 0) y = a[i];
            -- i;
        }
    }
    printf("%lld\n", x * 1ll * y);
}

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

const int N = 15;
unordered_map<int, int>dy;
int n, m, i, j, cost[1 << N][N], S, _S, a, b, c, f[1 << N][N], F, t, T, g[1 << N], M;
vector<int>V[N];

void Min (int &x, int y) { if (x > y) x = y; }

int getcost (int a, int b) {
	int ret = 0;
	for (int i = 0; i < n; ++i) if (b >> i & 1) ret += cost[a][i];
	return ret;
}

int main () {
	memset(f, 0x3f, sizeof f);
	scanf("%d%d", &n, &m); M = (1 << n) - 1;
	for (i = 0; i < n; ++i) dy[1 << i] = i;
	for (i = 1; i <= m; ++i) {
		scanf("%d%d%d", &a, &b, &c); --a; --b;
		V[a].emplace_back(b); V[b].emplace_back(a);
		for (j = _S = M ^ (1 << a) ^ (1 << b); j; j = (j - 1) & _S) cost[j ^ (1 << a)][b] += c, cost[j ^ (1 << b)][a] += c;
		cost[1 << a][b] = cost[1 << b][a] = c;
	}
	f[1][0] = 0;
	for (i = 0; i < M; ++i) f[i][0] = 0;
	for (i = 1, a = M >> 1; i <= a; ++i) {
		F = i << 1 | 1;
		for (b = 1; b < n; ++b) if (F >> b & 1) for (auto v : V[b]) if (F >> v & 1) Min(f[F][b], f[F ^ (1 << b)][v] + cost[F ^ (1 << b) ^ (1 << v)][b]);

		for (t = 1; t < n; ++t) if (F >> t & 1) {
//			g[1 << t] = cost[F ^ (1 << t)][t];
			for (j = _S = F ^ (1 << t) ^ 1; j; j = (j - 1) & _S) {
				T = j; S = F ^ j ^ (1 << t) ^ 1;
				if (S == 0) g[S] = cost[T][0];
				else g[S] = g[S - (S & -S)] - cost[S ^ (S & -S) ^ 1][dy[S & -S]] + cost[T][dy[S & -S]];
				Min(f[F][t], f[S ^ (1 << t) ^ 1][t] + g[S]);
			}
		}
//		f[F][0] = 0;
	}
	printf("%d\n", f[M][n - 1]);
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
    
    double N, K;
    cin >> N >> K;
    double xx = 1/N;
    
    double ans = 0.0;
    
    
    for (int i = 1; i <= N; i++) {
        
        if (i < K) {
            double aa = log2(K/i);
            int bb = int(aa);
            if (aa != bb) {
                bb += 1;
            }
            bb = double(bb);
            
            ans = ans + xx * (pow(0.5, bb));
        }else{
            ans = ans + xx;
        }
        
        
        
    }
    
    
    cout << fixed;
    cout << setprecision(10) << ans << endl;
    
    
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int T;
int N;
int D;
int main(){
    cin>>T;
    REP(i,T){
        cin>>N>>D;
        N--;
        LL ans=N*127;
        if(N%2==1){
           ans+=(127-D);
        }else{
           ans+=D;
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int N, K;
  cin >> N >> K;
  string s;
  cin >> s;
  vector<int> c;
  int cnt = 0;
  char prev = '?';
  rep(i, N) {
    if (prev == s[i]) {
      cnt++;
    } else {
      prev = s[i];
      if (cnt) c.push_back(cnt);
      cnt = 1;
    }
  }
  if (cnt) c.push_back(cnt);
  dump(c);
  int n = c.size();
  list<int> ls;
  rep(i, n) ls.push_back(c[i]);
  rep(i, K) {
    if (1 < n) {
    // if (1 < ls.size()) {
      int acc = 0;
      int m = min(n, 3);
      // int m = min((int)ls.size(), 3);
      rep(j, m) {
        acc += ls.front();
        ls.erase(ls.begin());
      }
      ls.push_front(acc);
      n -= (m - 1);
    }
    dump(ls);
  }
  int ans = 0;
  for (int l : ls) {
    if (1 < l) ans += l - 1;
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

int  main()
{
	int n;
	cin >> n;
	rep1(i, 9)
	{
		rep1(j, 9)
		{
			if (i * j == n)
			{
				cout << "Yes\n";
				return 0;
			}
		}
	}
	cout << "No\n";
	return (0);
}


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

using namespace std;

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

  vector<int> r(26, 50);
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    int l = s.length();

    vector<int> c(26, 0);
    for (int j = 0; j < l; ++j) {
      ++c[s[j] - 'a'];
    }
    for (int j = 0; j < 26; ++j) {
      r[j] = min(r[j], c[j]);
    }
  }
  
  for (char c = 'a'; c <= 'z'; ++c) {
    for (int k = 0; k < r[c - 'a']; ++k)
      cout << c;
  }
  cout << "\n";
  
  return 0;
}


Measured memory_bytes: 256
N,W = map(int, input().split())
w = []
v = []
for _ in range(N):
    a,b = map(int, input().split())
    w.append(a)
    v.append(b)
    
dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if j < w[i]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
            
print(dp[N][W])

Measured memory_bytes: 120044
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

int main() {
  int A, P; cin >> A >> P;
  int result = (A*3+P)/2;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
def euclid(a, b):
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
    return b

N = int(input())
a_list = list(map(int, input().split()))

min_g = 10 ** 9 + 1
for n in range(N-1):
    g = euclid(a_list[n], a_list[n+1])
    min_g = min(min_g, g)

print(min_g)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }

int main() {  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b;
    cin >> a >> b;
    ll n = gcd(a, b);
    ll ret = 1;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            ret++;
            while (n % i == 0) {
                n /= i;
            }
        }
    }
    if (n != 1) ret++;

    cout << ret << "\n";
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long K,A,B;cin>>K>>A>>B;
    long def=B-A;
    long i=0,sum=1;
    while(i<K){
        if(sum>=A&&i<=K-2&&def>=2){
            i=i+2;
            sum+=def;
        }else{
            i++;
            sum++;
        }
    }cout<<sum<<endl;
}

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

int main() {
  string S;
  cin >> S;
  int a,b,c,d;
  a = 0;
  b = 0;
  c = 0;
  d = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'N') {
      a++;
    }
    else if (S.at(i) == 'W') {
      b++;
    }
    else if (S.at(i) == 'S') {
      c++;
    }
    else {
      d++;
    }
  }
  
  if (a > 0 && c == 0) {
    cout << "No" <<endl;
  }
  else if (b > 0 && d == 0) {
    cout << "No" <<endl;
  }
  else if (a == 0 && c > 0) {
    cout << "No" <<endl;
  }
  else if (b == 0 && d > 0) {
    cout << "No" <<endl;
  }
  else {
    cout << "Yes" <<endl;
  }
  
}


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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, K;
	
	cin>>N>>K;
	
	cout<<N-K+1<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C[3];
  cin>>A>>B;
  C[0]=A+B;
  C[1]=A-B;
  C[2]=A*B;
  sort(C,C+3);
  cout<<C[2]<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

void run() {
	int a, b, t; cin >> a >> b >> t;
	cout << (t/a*b) << endl;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
 
int main(){
  //input
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll n;
  cin  >> n ;
  cout<<n*(n-1)/2<<endl;
}  



Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int D = sc.nextInt();

        int canWatch = 2*D +1;

        int result = N / canWatch;

        if(N % canWatch != 0) result++;

        System.out.println(result);

    }
}


Measured memory_bytes: 21972
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
int main(){
  int t=1;
  //cin>>t;
    while(t--){
            string a,b;
            int c;
            cin>>a>>b;
            c=stoi(a+b);
            int temp=sqrt(c);
            if(temp*temp==c)
                cout<<"Yes";
            else
                cout<<"No";


  }
  return 0;
  }



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
typedef char CHAR;
typedef unsigned char UCHAR;
typedef short SHORT;
typedef unsigned short USHORT;
typedef int INT;
typedef unsigned int UINT;
typedef long long LLONG;
typedef unsigned long long ULLONG;

#define LengthOf(x)    (sizeof(x) / sizeof(x[0]))

#if 0
//No.4
int main()
{
	return 0;
}
#endif

#if 1
//NO.3
int sub(INT N, INT M, INT X, INT C[12], INT A[12][12], bool read[12], INT skill[12], INT cost, INT start)
{
	INT ret = 0;

	//skillを満たした
	bool master = true;
	for (int i = 0; i < M; ++i) {
		if (skill[i] < X) { master = false; break; }
	}

	if (master) { 
		ret = cost;
	}
	else {
		//もう一冊読む
		INT minCost = 0x7FFFFFFF;
		for (int i = start; i < N; ++i) {
			if (read[i] == false) {
				read[i] = true;
				INT newSkill[12];
				for (int j = 0; j < M; ++j) { newSkill[j] = skill[j] + A[i][j]; }

				INT tmpCost = sub(N, M, X, C, A, read, newSkill, cost + C[i], start+1);
				if (tmpCost >= 0 && tmpCost < minCost) { minCost = tmpCost; }

				read[i] = false;
			}
		}

		if (minCost == 0x7FFFFFFF) {
			ret = -1;
		}
		else {
			ret = minCost;
		}
	}

	return ret;
}

//No.3
int main()
{
	INT N, M, X;
	INT C[12];
	INT A[12][12];

	cin >> N >> M >> X;
	for (int i = 0; i < N; ++i) {
		cin >> C[i];
		for (int j = 0; j < M; ++j) {
			cin >> A[i][j];
		}
	}

	bool read[12];
	INT skill[12];
	memset(read, 0, sizeof(read));
	memset(skill, 0, sizeof(skill));

	INT cost = sub(N, M, X, C, A, read, skill, 0, 0);

	cout << cost;
	return 0;
}
#endif


Measured memory_bytes: 3624
import java.util.Scanner;
class Main {
 public static void main(String[] args){
 Scanner scan = new Scanner(System.in);
 int x = scan.nextInt();
 int hours = x / (60 * 60);
 int y = x - (hours * 60 * 60);
 int min = y / 60;
 int sec = y - (min * 60);
 System.out.println(hours + ":" + min + ":" + sec);
 }
 }


Measured memory_bytes: 26348