akhauriyash/Code-Regression huggingface dataset:
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	let a = input[0].split(" ")[0];
	let b = input[0].split(" ")[1];
	//文字列から10進数に変換するときはparseIntを使います
  	if(a*b%2===0){
      console.log("Even");
    } else {
      console.log("Odd");
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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



int main () {
    string s ;
    cin >> s ;
    int i = 0 , j = s.size()-1 ;
    int ans = 0 ;
    while (i < j) {
        if (s[i] == s[j]) {
            i++ , j-- ;
        }
        else {
            if (s[i] == 'x') {
                ans++ ;
                i++ ;
            }
            else if (s[j] == 'x') {
                ans++ ;
                j-- ;
            }
            else {
                cout << -1 << endl ;
                return 0 ;
            }
        }
    }
    cout << ans << endl ;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if(a < b)
	{
		cout << "a < b\n";
	}
	else if(a > b)
	{
		cout << "a > b\n";
	}
	else
	{
		cout << "a == b\n";
	}
}

Measured memory_bytes: 3020
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

void cmax(int& lhs,int rhs){lhs=max(lhs,rhs);}
int main(){
    string s;
    cin>>s;
    int k;
    cin>>k;
    int half=s.size()/2;
    
    vector<vector<vector<int>>> dp(half+1,vector<vector<int>>(half+1,vector<int>(k+1)));
    for(int i=0;i<=half;i++){
        for(int j=0;j<=half;j++){
            for(int l=0;l<=k;l++){
                if(i<half){
                    cmax(dp[i+1][j][l],dp[i][j][l]);
                }
                if(j<half){
                    cmax(dp[i][j+1][l],dp[i][j][l]);
                }
                if(i<half &&j<half){
                    if(s[i]!=s[s.size()-1-j] && l<k) cmax(dp[i+1][j+1][l+1],dp[i][j][l]+1);
                    if(s[i]==s[s.size()-1-j]) cmax(dp[i+1][j+1][l],dp[i][j][l]+1);
                }
                if(l<k) cmax(dp[i][j][l+1],dp[i][j][l]);
            }
        }
    }
    

    vector<vector<int>> posL(s.size()+1,vector<int>(26,-1));
    for(int i=0;i<s.size();i++) posL[i+1]=posL[i],posL[i+1][s[i]-'a']=i;
    vector<vector<int>> posR(s.size()+1,vector<int>(26,s.size()));
    for(int i=s.size()-1;i<s.size();i--) posR[i]=posR[i+1],posR[i][s[i]-'a']=i;

    vector<vector<vector<int>>> dp2(s.size()+1,vector<vector<int>>(s.size()+1,vector<int>(k+1)));
    for(int i=0;i<s.size();i++) for(int j=0;j<=k;j++) dp2[i][i+1][j]=1;
    for(int v=2;v<=s.size();v++){
        for(int i=0;i<s.size();i++){
        int j=i+v;
        if(i+v>s.size()) continue;
            for(int l=0;l<=k;l++){
                if(l>0){
                    cmax(dp2[i][j][l],dp2[i+1][j-1][l-1]+2);
                    cmax(dp2[i][j][l],dp2[i][j][l-1]);
                }
                cmax(dp2[i][j][l],dp2[i+1][j][l]);
                cmax(dp2[i][j][l],dp2[i][j-1][l]);
                if(i+1<=posL[j][s[i]-'a']) cmax(dp2[i][j][l],dp2[i+1][posL[j][s[i]-'a']][l]+2);
                if(posR[i][s[j-1]-'a']<=j-2) cmax(dp2[i][j][l],dp2[posR[i][s[j-1]-'a']+1][j-1][l]+2);
            }
        }
    }

    int res=0;
    int tmp=s.size()%2;
    for(int i=0;i<=half;i++){
        for(int j=0;j<=half;j++){
            for(int l=0;l<=k;l++){
                cmax(res,dp[i][j][l]*2+dp2[i][half+tmp][k-l]);
                cmax(res,dp[i][j][l]*2+dp2[half][s.size()-j][k-l]);
            }
        }
    }
    cout<<dp2[0][s.size()][k]<<endl;
    
    return 0;
}


Measured memory_bytes: 137984
a,b,c=map(int,input().split())
if a==b:
  if c!=a:
    ans='Yes'
  else:
    ans='No'
elif c==b:
  if a!=c:
    ans='Yes'
  else:
    ans='No'
elif a==c:
  if b!=a:
    ans='Yes'
  else:
    ans='No'
else:
  ans='No'
  
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long ans=1;
  string s;
  cin >> s;
  map<char, int> mp;
  for(int i=0;i<s.size();i++){
    mp[s[i]]++;
  }
  for(size_t i=0;i<s.size();i++){
    ans+=s.size()-i-mp[s[i]];
    mp[s[i]]--;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
from copy import deepcopy
from collections import deque
from itertools import product
import numpy as np
inputs = open(0).readlines()
class Grid():
    def __init__(self, grid, w=0, h=0, function=lambda x: x):
        self.w = w = w if w else len(grid[0])
        self.h = h = h if h else len(grid)
        dtype = type(function(grid[0][0]))
        self.grid = np.empty((h, w), dtype=dtype)
        for i, rows in zip(range(h), grid):
            for j, val in zip(range(w), rows):
                self.grid[i][j] = function(val)
    
    def is_valid_x(self, x):
        return 0 <= x < self.w
    def is_valid_y(self, y):
        return 0 <= y < self.h
    def is_valid_xy(self, x, y):
        return self.is_valid_x(x) and self.is_valid_y(y) 
    
    def __iter__(self):
        return iter(self.grid)
    def __repr__(self):
        return '\n'.join([' '.join(map(str, rows)) for rows in self.grid])
    def __getitem__(self, x):
        return self.grid[x]
    def __setitem__(self, x, val):
        self.grid[x] = val
h, w = map(int, inputs[0].split())
grid_origin = Grid(inputs[1:], function=lambda x: int(x == '.'))

def bfs(root):
    queue = deque([root])
    while queue:
        x, y, d = queue.popleft()
        d += 1
        grid[y, x] = 0
        for dx, dy in zip([1, 0, -1, 0], [0, 1, 0, -1]):
            if grid.is_valid_xy(x+dx, y+dy) and grid[y+dy, x+dx]:
                queue.append((x+dx, y+dy, d))
                grid[y+dy, x+dx] = 0
    return d-1
    
ans = 0
for i, j in product(range(h), range(w)):
    if grid_origin[i, j]:
        grid = deepcopy(grid_origin)
        ans = max(ans, bfs((j, i, 0)))
print(ans)

Measured memory_bytes: 12544
#include <iostream>
using namespace std;
bool notp[1010101];
int prime[202020],nump,mu[1010101],a[201010];
long long t[1010101];
const int maxn = 1000000;
const int mod = 998244353;
inline long long pow (long long di,long long ci) {
	long long ret = 1;
	while (ci) {
		if (ci&1)
			ret = ret*di % mod;
		di = di*di%mod;
		ci >>= 1;
	}
	return ret;
}

void init() {
	mu[1] = 1;
	for (int i = 2;i <= maxn; i++) {
		if (!notp[i]) {
			prime[++nump] = i;
			mu[i] = -1;
		}
		for (int j = 1;j <= nump && prime[j]*i <= maxn; j++) {
			notp[i*prime[j]] = 1;
			if  (i%prime[j] == 0) {
				break;
			}
			mu[i*prime[j]] = mu[prime[j]]*mu[i];
		}
	}
}
int n,aa;
long long sumj[maxn+10],x[maxn+10];
int main() {
	init();
	scanf("%d",&n);
	for (int i = 1;i <= n; i++) {
		scanf("%d",&a[i]);
		t[a[i]]++;
	}
	for (int dg = 1;dg <= maxn; dg++) {
		for (int j = 1;j <= maxn/dg; j++)
			sumj[j] = (sumj[j-1]+j*t[j*dg])%mod;
		for (int i = 1;i <= maxn/dg; i++)
			(x[dg] += i*t[i*dg]%mod*(sumj[maxn/dg]-sumj[i])) %= mod;
	}
	long long ans = 0,tmp = 0;
	for (int i = 1;i <= maxn; i++) {
		tmp = 0;
		for (int j = 1;j <= maxn/i; j++)
			(tmp += mu[j]*x[i*j]*j%mod*j) %= mod;
		(ans += tmp*i) %= mod;
	}
	for (int i = 1;i <= maxn; i++)
		ans += t[i]*(t[i]-1)/2*i%mod;
	ans %= mod;
	if (ans < 0)
		ans += mod;
	//(ans *= pow(4,mod-2)) %= mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 29824
#include <bits/stdc++.h>
using namespace std;
/*struct edge{
  int to1;
  int to2;
};
*/

#define INF 1e+9
#define MAX_V 2*1000+10

struct edge {
    int to;
    int cost;
};

// <????, ?????>
using P = pair<int, int>;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main (){
  int i,n,x,y,j;
  cin>>n>>x>>y;
  vector <int>dp(n);
  for(i=1;i<=n;i++){
    for(j=i+1;j<=n;j++){
      dp[min(abs(j-i),min(abs(x-i)+1+abs(j-y),abs(x-i)+1+abs(j-y)))-1]++;
    }
    
  }
  for(i=0;i<n-1;i++){
      cout<<dp[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String t_input = sc.next();
		
		int count =0;
		for(int i = 0; i < t_input.length(); i++) {
			count+= Integer.parseInt(t_input.substring(i,i+1));
		}
		if(count % 9 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 49844
// In the name of Allah
// #Isart
// yedoone bashe, mashti bashe ...

#include<bits/stdc++.h>

#define pii pair<int, int>
#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double

using namespace std;

const int MAXN = 1e5 + 10;
int t[MAXN];

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	int n, c, k;
	cin >> n >> c >> k;
	for(int i = 0; i < n; i ++) cin >> t[i];
	sort(t, t + n);
	int last = -2e9, ans = 0, m = 0;
	for(int i = 0; i < n; i ++){
		if(m >= c){
			m = 0;
			last = -2e9;
		}
		if(last + k < t[i]){
			last = t[i];
			m = 1;
			ans = ans + 1;
		}
		else
			m ++;
	}	
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 640
#include<stdio.h>
 int main()
   {
   int n,m,i,j,sum=0;
   scanf("%d %d",&n,&m);
   if(n>1 || m>1){
     for(i=1;i<=n;i++){
       sum+=(n-i);
       }
       for(j=1;j<=m;j++){
       sum+=(m-j);
         }
       
     }
   
   printf("%d",sum);
   }


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

int main(){
  char b;
  cin >> b;
  if(b=='A'){
    cout << "T" <<endl;
  }
    if(b=='T'){
    cout << "A" <<endl;
    }
      if(b=='C'){
    cout << "G" <<endl;
      }
        if(b=='G'){
    cout << "C" <<endl;
        }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

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

		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		int z = stdIn.nextInt();

		System.out.println(z+" "+x+" "+y);





	}

}


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

using namespace std;

int main()
{
	int n;double sum=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		double x;string a;
		cin>>x>>a;
		if(a=="BTC")sum+=x*380000;
		else sum+=x;
	}
	printf("%.5lf",sum);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
	double s,a;
	while(scanf("%lf",&a)!=EOF){
		s=0;
		for(int i=1;i<=10;i++){
			s+=a;
			if(i&1)a*=2;
			else a/=3;
		}
		printf("%.6f\n",s);
	}
	return 0;
}

Measured memory_bytes: 1080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
	string s; cin>>s;
	if(s[5]=='0'&&(s[6]=='1'||s[6]=='2'||s[6]=='3'||s[6]=='4')){
		cout<<"Heisei"<<endl;
	}else{
		cout<<"TBD"<<endl;
	}
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int H,W;
LL d[10][10];
LL cc[10];
int main(){
    cin>>H>>W;
    REP(i,10){
        REP(j,10){
            cin>>d[i][j];
        }
    }
    REP(k,10){
        REP(i,10){
            REP(j,10){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    
    REP(i,10){
        cc[i]=0;
    }
    REP(i,H){
        REP(j,W){
            int a;
            cin>>a;
            if(a!=-1){
               cc[a]++;
            }
        }
    }
    LL ans=0;
    REP(i,10){
        ans+=(cc[i]*d[i][1]);
    }
    cout<<ans<<endl;
	return(0);
}

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

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

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int d,n;cin>>d>>n;
	string s="";
	rep(i,d*2){
		s+='0';
	}
	if(n==100)n++;
	string t=to_string(n);
	s=t+s;
	cout<<s<<endl;
}

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

#define int long long
int a[3001], b[3001], c[3001], x, y, z, k;
vector<int> sum1, sum2;

signed main(){
	ios_base::sync_with_stdio(0);
	cin >> x >> y >> z >> k;
	for(int i = 1; i <= x; i++) cin >> a[i];
	for(int i = 1; i <= y; i++) cin >> b[i];
	for(int i = 1; i <= z; i++) cin >> c[i];
	for(int i = 1; i <= x; i++){
		for(int j = 1; j <= y; j++){
			sum1.push_back(a[i] + b[j]);
		}
	}
	sort(sum1.begin(), sum1.end());
	for(int i = sum1.size() - 1; i >= max((long long)(sum1.size() - k), 0LL); i--){
		for(int j = 1; j <= z; j++){
			sum2.push_back(sum1[i] + c[j]);
		}
	}
	sort(sum2.begin(), sum2.end());
	for(int i = sum2.size() - 1; i >= (long long)(sum2.size() - k); i--) cout << sum2[i] << "\n";
}

Measured memory_bytes: 43364
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

string s[50], t[50];
signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(n, m);
    rep(i, n)cin >> s[i];
    rep(i, m)cin >> t[i];

    bool bl = false;
    rep(i, n)rep(j, n){
      int k = 0, l = 0;
      rep(k, m)rep(l, m){
        if(s[i + k][j + l] != t[k][l]){
          k = 100; l = 100;
          break;
        }
      }
      if(k < 100 && l < 100){
        puts("Yes");
        //printf("%d %d %d %d\n", i, j, k, l);
        return 0;
      }
    }
    puts("No");

/*/

//*/ break;
  }
  return 0;
}


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

int main()
{
  long long N,M,ans=0;scanf("%lld %lld",&N,&M);
  priority_queue<pair<int,int>> AB;
  for(int A,B,i=0;i<N;i++)
  {
    scanf("%d %d",&A,&B);
    AB.push(make_pair(0-A,0-B));
  }
  while(M!=0)
  {
    long long A=0-AB.top().first,B=0-AB.top().second;
    AB.pop();
    if(M-B<0)ans+=A*M,M=0;
    else ans+=A*B,M-=B;
  }
  printf("%lld",ans);
}

Measured memory_bytes: 4252
/*Code by Codercjh*/
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
ll ans,n,mp[200005],a[200005];
int main(){
    read(n);
    fr(i,1,n)read(a[i]),++mp[a[i]];
    fr(i,1,n)ans+=mp[i]*(mp[i]-1)/2;
    fr(i,1,n){
    	printf("%lld\n",ans-mp[a[i]]*(mp[a[i]]-1)/2+(mp[a[i]]-1)*(mp[a[i]]-2)/2);
	}
	return 0;
}


Measured memory_bytes: 4736
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

/* エラトステネスのふるい

   O(n log log n) だいたい線形。 10万とかは余裕
*/
template<typename T>
std::vector<T> sieve(T n)
{
    std::vector<T> primes;
    std::vector<bool> is_prime(n, true);
    is_prime[0] = is_prime[1] = false;

    for (T i = 2; i <= n; ++i) {
        if (is_prime[i]) {
            primes.push_back(i);
            for (T j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    return primes;
}


int main()
{
    int64_t N;
    std::cin >> N;

    auto primes = sieve<uint64_t>(55555);

    auto itr = primes.begin();
    while (N > 0) {
        if (*itr % 5 == 1) {
            std::cout << *itr << " ";
            N--;
        }
        ++itr;
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 384
n=int(input())
s=[input() for i in range(n)]

count_ac=0
count_wa=0
count_tle=0
count_re=0

for i in range(n):
    if s[i]=='AC':
        count_ac+=1
    elif s[i]=='WA':
        count_wa+=1
    elif s[i]=='TLE':
        count_tle+=1
    else:
        count_re+=1

print('AC x '+str(count_ac))
print('WA x '+str(count_wa))
print('TLE x '+str(count_tle))
print('RE x '+str(count_re))

Measured memory_bytes: 16324
#include<bits/stdc++.h>
using namespace std;
vector<long long int> v[100010];
int main()
{
	long long int n, m;
	cin >> n >> m;
	for(int i=0; i<n; i++)
	{
		long long int a, b;
		cin >> a >> b;
		v[a].push_back(b);
	}

	priority_queue<long long int> pq;
	long long int ans = 0;
	for(int i=1; i<=m; i++)
	{
		for(auto j : v[i])
		{
			pq.push(j);
		}

		if(!pq.empty())
		{
			ans += pq.top();
			pq.pop();
		}
	}

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

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

#ifdef DEBUG
#define debug(x) cout << #x << ": " << x << endl
#else
#define debug(x)
#endif

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPS(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;

const ll INF = 1e18;
const ll MOD = 1e9+7;

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a = b; return true;} return false; }

int N, M, Q;
vi a, b, c, d;
vi A;
int ans = 0;

void dfs(int n)
{
    if(n == N+1)
    {
        int tmp = 0;
        REPS(i, Q)
        {
            if(A[b[i]]-A[a[i]] == c[i]) tmp += d[i];
        }
        chmax(ans, tmp);
        return;
    }
    for(int i = A[n-1]; i <= M; i++)
    {
        A[n] = i;
        dfs(n+1);
    }
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    cin >> N >> M >> Q;
    a.resize(Q+1); b.resize(Q+1); c.resize(Q+1); d.resize(Q+1);
    A.resize(N+1); A[0] = 1;
    REPS(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];

    dfs(1);
    cout << ans << endl;
}

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

int main() {
  
  int N,X,T;
  
  cin >> N >> X >> T;
  
  if (N % X == 0) {
    cout << N / X * T << endl;
  }
  else 
    cout << (N / X + 1) * T << endl;
}  

Measured memory_bytes: 3596
#include <algorithm>
#include <cmath>

typedef long long ll;

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <deque>
#include <queue>
#include <stack>
using namespace std;
ll n;
string s;
ll ans;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> s;
    vector<int> t;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'A')
        {
            t.push_back(0);
        }
        else
        if (i + 1 < s.size() && s[i] == 'B' && s[i + 1] == 'C')
        {
            t.push_back(1);
            i++;
        }
        else
            t.push_back(2);
    }
    ll dp = 0;
    for (int i = 0; i < t.size(); i++)
    {
        //cout << t[i] << " ";
        if (t[i] == 2)
            dp = 0;
        if (t[i] == 0)
            dp++;
        else
            ans += dp;
    }
    cout << endl << ans;
}


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

int main() {
	int n;
	string s;
	cin>>n>>s;
	LL r = 0, g = 0, b =0;
	for(char c : s) {
		if(c=='R') r++;
		else if(c=='G') g++;
		else b++;
	}
	LL res = r*g*b;
	
	for(int i=0;i<n;i++) {
		for(int len = 1; len < n; len++) {
			int j = i+len;
			int k = j+len;
			if(k>=n) break;
			if(s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i]) res--;
		}
	}
	cout<<res;
	return 0;
}

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

#define rep(i,l,r) for(int i=l;i<=r;++i)
const int K=500+5;

int main()
{
	//freopen("1.in","r",stdin);
	int H,W,h,w;
	cin>>H>>W>>h>>w;
	if(H%h==0&&W%w==0)
	{
		puts("No");
		exit(0);
	}
	puts("Yes");
	int v=-(((h*w)-1)*K+1);
	rep(i,1,H)
	{
		rep(j,1,W)
		printf("%d ",(i%h==0&&j%w==0)?v:K);
		puts("");
	}
}

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

struct SegmentTree {
  int n;
  vector<int> data;
  SegmentTree(int size) {
    n = 1;
    while (n < size) n*=2;
    data.resize(2*n-1, INT_MAX);
  }
  // （0-indexed）k番目 を aに更新
  void update(int k, int a) {
    k += n - 1;
    data[k] = a;
    while(k>0){
      k = (k - 1) / 2;
      data[k] = min(data[k*2+1], data[k*2+2]);
    }
  }
  // [a, b)の最小値を求める
  int query(int a, int b) {
    return _query(a, b, 0, 0, n);
  }
  int _query(int a, int b, int k, int l, int r) {
    // [a, b) と [l, r)が交わらない
    if (r<= a || b <= l) return INT_MAX;
    // [a, b)が[l, r)を含んでいるので節点の値
    if (a <= l && r <= b) return data[k];
    int vl = _query(a, b, k * 2 + 1, l, (l + r) / 2);
    int vr = _query(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(vl, vr);
  }
};

int turn[100005];

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,m;cin>>n>>m;
  string s;cin>>s;

  SegmentTree st = SegmentTree(n+1);

  st.update(n, 0);
  turn[n]=0;
  for(int i=n-1;i>=0;i--){
    if(s[i]=='1'){
      st.update(i, 100005);
      turn[i]=100005;
      continue;
    }
    if(i+m>=n){
      st.update(i, 1);
      turn[i]=1;
      continue;
    }
    int d = st.query(i+1, i + m + 1);
    turn[i]=d+1;
    st.update(i, d+1);
  }

  // for(int i=0;i<=n;i++){
  //   cout<<"T: "<<turn[i]<<endl;
  // }

  if(turn[0]>=100005){
    cout<<-1<<endl;return 0;
  }

  int cur=turn[0];
  int pos=0;
  for(int i=0;i<=n;i++){
    if(cur>turn[i]){
      cur=turn[i];
      cout<<i-pos<<' ';
      pos=i;
    }
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 2128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
#define lint long long int
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/


int main() {
	vector<int>vec(3);
	for (int i = 0; i < 3; i++) {
		cin >> vec.at(i);
	}
	sort(vec.begin(), vec.end());
	cout << vec.at(0) + vec.at(1) << endl;
}

Measured memory_bytes: 256
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

# リストliから重複を削除したリストli_uniqを作成
#li_uniq = []
#for i in li:
#    if x not in li_uniq:
#        li_uniq.append(x)

# 複数行のinput - list版
#list = [list(map(int, input().split())) for i in range(N)]
# 複数行のinput - dictionary版
# key = a, value = b
#for i in range(N):
#    a, b = map(int, input().split())
#    dict[a] = b


N, H = map(int, input().split())

D = [list(map(int, input().split())) for i in range(N)]
B = [D[i][1] for i in range(N)] # bのリスト

a_max = 0 # 最大のa

for i in range(N):
    if D[i][0] >= a_max:
        a_max = D[i][0]

B_larger = [] # a_maxより大きいbのリスト

for i in range(N):
    if B[i] > a_max:
        B_larger.append(B[i])

B_larger.sort(reverse=True)

n = 0

for i in range(len(B_larger)):
    H = H - B_larger[i]
    n += 1    
    if H <= 0:
        print(n)
        break
    

if H > 0:
    n += math.ceil(H/a_max)
    print(n)


Measured memory_bytes: 38420
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = [list(map(int, readline().split())) for _ in range(n)]
    for i in range(n):
        for j in range(n - 1):
            a[i][j] -= 1
    ls = [0] * n
    ql = collections.deque()
    for i in range(n):
        ql.append([0, i])

    for i in range(10 ** 10):
        fq = collections.defaultdict(list)
        while True:
            if len(ql) != 0:
                d, ps = ql.popleft()
                if d == i:
                    if ps not in fq:
                        nw = a[ps][ls[ps]]
                        if nw not in fq:
                            rw = a[nw][ls[nw]]
                            if ps == rw:
                                fq[ps]
                                fq[nw]
                                ls[ps] += 1
                                ls[nw] += 1
                                if ls[ps] < n - 1:
                                    ql.append([d+1, ps])
                                if ls[nw] < n - 1:
                                    ql.append([d+1, nw])
                else:
                    ql.appendleft([d, ps])
                    break
            else:
                if sum(ls) == n * (n - 1):
                    print(i + 1)
                else:
                    print(-1)
                exit()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 67420
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

import itertools as it

N,M=input_int()

N=len(list(it.combinations([N]*N,2)))

M=len(list(it.combinations([M]*M,2)))

print(N+M)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
const int MOD = 998244353;
const int MX = 10000005;
int n;
ll ans = 1, f = 1, iv[MX];
ll exp(ll b, ll n){
	ll res = 1;
	for(; n; n/=2,(b*=b)%=MOD) if(n%2) (res *= b) %= MOD;
	return res;
}
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) f = f*i % MOD;
	iv[n] =  exp(f,MOD-2);
	for(int i = n; i > 0; i--) iv[i-1] = (iv[i] * i) % MOD;
	ans = exp(3,n);
	rep(i,n/2){
		f = f*2 % MOD;
		(ans -= f * iv[n-i] % MOD * iv[i]) %= MOD;
	}
	if(ans < 0) ans += MOD;
	printf("%lld\n", ans);
}

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

namespace Beg123D
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var X = read[0];
            var Y = read[1];
            var Z = read[2];
            var K = read[3];
            var YZ = Y * Z;
            var As = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
            var Bs = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var Cs = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            var delness = new List<long>();
            var memo = new List<long>();
            foreach (var b in Bs)
            {
                foreach (var c in Cs)
                {
                    memo.Add(b + c);
                }
            }

            As.Sort();
            As.Reverse();
            memo.Sort();
            memo.Reverse();

            foreach (var a in As)
            {
                for(int i =0; i<Math.Min(K, YZ);i++)
                {
                    delness.Add(a + memo[i]);
                }
            }
            delness.Sort();
            delness.Reverse();

            for (int i = 0; i < K; i++)
            {
                Console.WriteLine(delness[i]);
            }
        }
    }
}

Measured memory_bytes: 63384
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

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

    if(a==b || abs(a-b)==1 )
        cout<<a+b<<endl;
    else

    {
        int mx = max(a,b);
        cout<<mx+(mx-1)<<endl;
    }
}


Measured memory_bytes: 256
//                                      KiSmAt
#include "bits/stdc++.h"
using namespace std;
 
using ll = long long;
 
const ll inf = 1e18;
const int N = 3 * 1e3 + 10;

ll res;
ll a[N];

ll dp[N][N];

void solve(){
    string s, ss, ans;
    cin >> s >> ss;
    dp[0][0] = 0;
    for(int i = 1; i <= s.size(); ++i){
        for(int j = 1; j <= ss.size(); ++j){
            dp[i][j] = max({dp[i][j - 1], dp[i - 1][j - 1] + (s[i - 1] == ss[j - 1]), dp[i - 1][j]});
        }
    }
    res = dp[s.size()][ss.size()];
    ll n = s.size(), m = ss.size();
    for(int i = n; i > 0; --i){
        for(int j = 1; j <= m; ++j){
            if(res and dp[i][j] == res){
                while(s[i - 1] != ss[j - 1])    --i;
                ans += ss[j - 1];
                res -= 1;
                break;
            }
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}
 
int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
// nEro

Measured memory_bytes: 70784
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int n; cin >> n;
  int l; cin >> l;
  string data;
  vector <string> s;
  for(int i = 0; i < n; i++)
  {
    cin >> data;
    s.push_back(data);
  }
  sort(s.begin(), s.end());
  for(int i = 0; i < n; i++)
  {
    cout << s[i];
  }
  cout << endl;
}


Measured memory_bytes: 3648
#include <string.h>

int w,h;
int dir[4][2]={{-1,0},{0,1},{1,0},{0,-1}};
char map[22][22];

int solve(int i,int j){
  int k,total=1;

  map[i][j] = '#';
  for(k=0;k<4;k++){
    if(map[i+dir[k][0]][j+dir[k][1]]=='.'){total+=solve(i+dir[k][0],j+dir[k][1]);}
  }

  return total;
}

int main(void){
  int i,j,si,sj;

  while(1){
    scanf("%d%d",&w,&h);
    if(!w && !h) break;

    memset(map,'#',sizeof(map));
    for(i=1;i<=h;i++){
      scanf("%s",&map[i][1]);
      map[i][w+1] = '#';
      for(j=1;j<=w;j++){
        if(map[i][j]=='@'){si=i,sj=j;}
      }
    }

    printf("%d\n",solve(si,sj));
  }

  return 0;
}

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

int main() {
  int N,A;
  
  cin >> N >> A;
  
  if(N%500 == 0){
    cout << "Yes" << endl;
  } else if(N%500 <= A){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
#define REP(i,x)for(int i=0;i<x;i++)

string res;
int H,W,dx,dy,min_len;
char s[200];
string MAP[11];
bool visit[20][20];
vector<string> ss;
void dfs(int x,int y,int k){
  if(visit[y][x]){
    ss.push_back(string(s));
    return;
  }
  s[k]=MAP[y][x];  visit[y][x]=1;
  dfs((x + dx + W) % W, (y + dy + H) % H, k + 1);
  s[k]=0;  visit[y][x]=0;
}
int main() {
  while(cin>>H>>W,H){
    REP(i,H)cin>>MAP[i];
    ss.clear();
    min_len=1; res="0";
    REP(y,H)REP(x,W){
      for(dx=-1;dx<=1;dx++){
        for(dy=-1;dy<=1;dy++){
          if(dx|dy)dfs(x,y,0);
        }
      }
    }
    string res = "0";
    sort(ss.begin(),ss.end());
    REP(i,ss.size()-1){
      int len = 0;
      REP(k,min(ss[i].size(),ss[i+1].size())){
        if(ss[i][k]==ss[i+1][k])len++;
        else break;
      }
      if(len < res.size())continue;
      if(res.size() == len){
        res = min(res, ss[i].substr(0,len));
      }else{
        res = ss[i].substr(0, len);
      }
    }
    cout<<res<<endl;
  }
}

Measured memory_bytes: 1456
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //f
  int h, w;
  cin >> h >> w;
  multiset<int> st;
  map<int, int> mp;
  for (int i = 0; i < w; i++) {
    st.insert(0);
    mp[i] = 0;
  }
  for (int i = 1; i <= h; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    int last = -1;
    int d = 1 << 30;
    auto it = mp.lower_bound(a);
    while (it != mp.end() && it->first < b) {
      assert(st.find(it->second) != st.end());
      st.erase(st.find(it->second));
      last = it->first;
      d = min(d, it->second + b - it->first);
      it = mp.erase(it);
    }
    if (last != -1) {
      if (b < w) {
        if (mp.count(b)) {
          st.erase(st.find(mp[b]));
          mp[b] = min(d, mp[b]);
          st.insert(mp[b]);
        } else {
          mp[b] = d;
          st.insert(d);
        }
      }
    }
    int ans = (!st.empty() ? *st.begin() + i : -1);
    cout << ans << '\n';
  }
  return 0;
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MOD 1e9+7

int main(){
  vector<ll> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(ALL(a));
  cout << a[0] * a[1] / 2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
//ll mod=1000000007;
//ll mod=67280421310721;
ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int s,w;
		cin>>s>>w;
		if(s>w)
		cout<<"safe";
		else
		cout<<"unsafe";
	}
	return 0;
}

Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Problem().solve();
	}
}

class Problem {
	enum Mark {
		S(0), H(1), C(2), D(3);
		public final int id;
		Mark(int id) {
			this.id = id;
		}
		public static final int MARK_NUM = 4;
		public static int size() {
			return values().length;
		}
	}
	
	enum Rank {
		;
		public static final int MAX = 13;
	}
	
	public void solve() {
		List<List<Boolean>> cards = new ArrayList<>(Mark.MARK_NUM);
		for (int i = 0; i < Mark.MARK_NUM; i++) {
			List<Boolean> list = new ArrayList<>(Collections.nCopies(Rank.MAX,
					Boolean.valueOf(false)));
			cards.add(list);
		}
		
		Scanner sc = new Scanner(System.in);
		for (int i = 0, n = sc.nextInt(); i < n; i++) {
			Mark mark = Mark.valueOf(sc.next());
			int rank = sc.nextInt();
			cards.get(mark.id).set(rank - 1, true);
		}
		sc.close();
		
		for (Mark mark : Mark.values()) {
			for (int i = 0; i < Rank.MAX; i++) {
				if (!cards.get(mark.id).get(i)) {
					System.out.println(mark.name() + " " + (i + 1));
				}
			}
		}
	}
}

Measured memory_bytes: 26288
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
const int MOD = 1000000007;
//------------------------------------------------------------------------------
void _main()
{
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> dp(H + 1, vector<int>(W, 0));
    dp[0][0] = 1;
    rep(i, 0, H)
    {
        rep(j, 0, W)
        {
            rep(k, 0, 1 << (W - 1))
            {
                bool ok = true;
                rep(l, 0, W - 2)
                {
                    if (((k >> l) & 1) && ((k >> (l + 1)) & 1))
                    {
                        ok = false;
                    }
                }
                if (ok)
                {
                    if (j >= 1 && ((k >> (j - 1)) & 1))
                    {
                        dp[i + 1][j - 1] += dp[i][j];
                        dp[i + 1][j - 1] %= MOD;
                    }
                    else if (j <= W - 2 && ((k >> j) & 1))
                    {
                        dp[i + 1][j + 1] += dp[i][j];
                        dp[i + 1][j + 1] %= MOD;
                    }
                    else
                    {
                        dp[i + 1][j] += dp[i][j];
                        dp[i + 1][j] %= MOD;
                    }
                }
            }
        }
    }
    cout << dp[H][K - 1] << endl;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	h,w = readline() |> split |> parseMap
	a = ["" for i in 1:h]
	chk = -ones(Int,h,w)
	k = 0
	b = Tuple{Int,Int}[]
	for i in 1:h
		a[i] = readline() |> chomp
		for j in 1:w
			if a[i][j] == '#'
				chk[i,j] = 0
				k += 1
				push!(b,(i,j))
			end
		end
	end
	while k < h*w
		x,y = shift!(b)
		if x>1
			if chk[x-1,y] < 0
				push!(b,(x-1,y))
				chk[x-1,y] = chk[x,y]+1
				k += 1
			end
		end
		if x<h
			if chk[x+1,y] < 0
				push!(b,(x+1,y))
				chk[x+1,y] = chk[x,y]+1
				k += 1
			end
		end
		if y>1
			if chk[x,y-1] < 0
				push!(b,(x,y-1))
				chk[x,y-1] = chk[x,y]+1
				k += 1
			end
		end
		if y<w
			if chk[x,y+1] < 0
				push!(b,(x,y+1))
				chk[x,y+1] = chk[x,y]+1
				k += 1
			end
		end
	end
	println(maximum(chk))
end

main()

Measured memory_bytes: 157000
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,x,ans,s,a[3],b[3];
int main(){
  
  cin>>n;
  
  r(i,n){
    cin>>x;
    a[x%3]++;
  }
  
  if(a[1]||a[2]){
    
    b[2]=a[2],b[1]=a[1];
    
    int ans1=0,ans2=0,s1=0,s2=0;
    
    if(a[1]){
      
      s1++,a[1]--,ans1++;
      
      while(1){
	
	int f=0;
	if(s1%3==2&&a[2])s1+=2,a[2]--,ans1++,f++;
	if(s1%3==1&&a[1])s1++,a[1]--,ans1++,f++;
	if(!f)break;
	
      }
      
      if(a[2]||a[1])ans1++;
    }
    
    if(b[2]){
      s2+=2,b[2]--,ans2++;
      while(1){
	int f=0;
	if(s2%3==2&&b[2])s2+=2,b[2]--,ans2++,f++;
	if(s2%3==1&&b[1])s2++,b[1]--,ans2++,f++;
	if(!f)break;
      }
      if(b[2]||b[1])ans2++;
    }
    cout<<max(ans1,ans2)+a[0]<<endl;
  }
  
  else cout<<1<<endl;
}

Measured memory_bytes: 3096
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif


int main(void) {
    int num, k;
    cin >> num >> k;
    vector<int> arr(num);
    cins(arr);
    int sum = 0;
    int mmax = 0;
    for(int i = 0; i < num; i++) {
        sum += (arr[i]+1);
        if(i >= k) {
            sum -= (arr[i-k]+1);
        }
        mmax = max(sum, mmax);
    }
    double ans = (double)mmax / 2;
    printf("%.7lf\n", ans);
    return 0;
}

Measured memory_bytes: 4036
import math
def get_two_int():
    two_int = input().split()
    for i in range(2):
        two_int[i] = int(two_int[i])
    return two_int

def get_diff_set_between_cost_and_budget(walk_distance, budget): #一つの関数にまとめすぎか？
    diff_set = set()
    max_x = walk_distance // 2 + 1
    for x in range(max_x):
        y = walk_distance - x
        abs_diff = abs(calculate_cost(x, y) - budget)
        diff_set.add(abs_diff)
    return diff_set

def calculate_cost(x, y):
    cost = math.sqrt((x ** 2) + (y ** 2))
    return cost

if __name__ == "__main__":
    while True:
         walk_distance, budget = get_two_int()
         if walk_distance == 0:
             break
         diff_set = get_diff_set_between_cost_and_budget(walk_distance, budget)
         min_num = min(diff_set)
         print(min_num)




Measured memory_bytes: 5676
// g++ -std=c++11 temp.cpp
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3

#define MAX_N 1000

string s;
char res[100];
int ind=0;

int main(){
	cin>>s;
	REP(i,100)res[i]=0;
	REP(i,s.length()){
		if(s[i]=='B'){
			if(ind>0){ res[--ind]=0; }
		}else res[ind++]=s[i];
	}
	cout<<res<<endl;
	return 0;
}




Measured memory_bytes: 256
//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#pragma comment(linker,"/STACK:33554432") /*32Mb*/

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <sstream>
#include <fstream>
#include <sstream>
#include <iterator>
#include <math.h>
using namespace std;

typedef  long long LL;
typedef  unsigned long long ULL;
typedef  long double LD;
typedef  pair<int, int> PII;
typedef  pair<long long, long long> PLL;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i)) 
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i)) 
#define MP make_pair
#define MOD 1000000007
#define mod 1000000000
#define INF 1000000007
#define PB push_back
#define eps 1e-8
#define X first
#define Y second

int n;
PII arr[100010];

bool comp(PII p1, PII p2)
{
	return p1.X < p2.X;
}

int main()
{
	cout.setf(ios::fixed, ios::floatfield);
	cout.precision(9);

	scanf("%d", &n);
	For(i, 0, n)
	{
		scanf("%d", &arr[i].X);
		scanf("%d", &arr[i].Y);
	}

	sort(arr, arr + n, comp);
	int ans = arr[n - 1].X + arr[n - 1].Y;

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

Measured memory_bytes: 1024
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7

import fractions
def lcm(a,b):
    return a*b//fractions.gcd(a,b)

def power(a):
    T=[a]
    while 2**(len(T))<mod:
        T.append(T[-1]**2%mod)
    b=bin(mod-2)
    ans=1
    for i in range(len(b)-2):
        if int(b[-i-1])==1:
            ans=ans*T[i]%mod
    return ans   

l=A[0]
for i in range(n-1):
    l=lcm(l,A[i+1])
l%=mod
s=0
for i in range(n):
    s+=l*power(A[i])%mod
    s%=mod
print(s)

Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include<vector>
#include <set>
#define rep(i,n) for(i=0;i<n;i++)
#define P pair<int,int>
using namespace std;
int n;


int main()
{	
	int b=0, c=0, d, e=0, f=0, i, j, m=0, s, t;
	cin >> n;
	vector<int>a(n);
	vector<int>z(n);
	rep(i, n) {
		cin >> s;
		if (b >= s && c < s)c = s;
		if (b < s) {
			b = s;
			e = i;
		}
	}

	rep(i, n) {
		if (i == e)cout << c << "\n";
		else cout << b << "\n";
	}

	return 0;
}

Measured memory_bytes: 3200
def main():
    N = int(input())  # 文字列または整数(一変数)

    l = [1, 2, 3, 4, 5, 6, 7, 8, 9]


    for i in l:
        last_digit = i % 10
        num_str = str(i)
        if last_digit != 0: l.append(int(num_str + str((last_digit-1)%10)))
        l.append(int(num_str + str((last_digit)%10)))
        if last_digit != 9: l.append(int(num_str + str((last_digit+1)%10)))
        if len(l) > N: break

    print(l[N-1])

if __name__ == '__main__':
    main()


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

int main(){
  int N;
  cin >> N;
  
  vector<int> mochi(N);
  
  for (int i = 0; i < N; i++){
    cin >> mochi.at(i);
  }
  
  int a = 0;
  int b = 0;
  
  for (int i = 0; i < N; i++){
    a = 0;
    for (int j = 0; j < N; j++){
      if (mochi.at(j) > a){
        a = mochi.at(j);
      }
    }
    for (int j = 0; j < N; j++){
      if(mochi.at(j) == a){
        mochi.at(j) = 0;
      }
    }
    if (a != 0){
      b++;
    }
  }
  
  cout << b << endl;

}

Measured memory_bytes: 256