akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		char c[] = sc.next().toCharArray();
		boolean bl = true;
		if(k >= c.length) {
			k = c.length;
			bl = false;
		}
		for(int i = 0; i < k; i++) {
			System.out.print(c[i]);
		}
		if(bl)
			System.out.println("...");
	}

}


Measured memory_bytes: 35772
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#define LL long long
#define rint register int
#define MAXN 3005
#define P 998244353
#define INF 0x3f3f3f3f
using namespace std;

int a, b, c, d, f[MAXN][MAXN];

int main()
{
    scanf("%d%d%d%d", &a, &b, &c, &d);
    f[a][b]=1;
    for(rint i=1; i<=c; ++i)
        for(rint j=1; j<=d; ++j)
        {
            f[i][j]=(f[i][j]+1LL*f[i-1][j]*j+1LL*f[i][j-1]*i)%P;
            f[i][j]=(f[i][j]-1LL*(i-1)*(j-1)*f[i-1][j-1]%P+P)%P;
        }
    printf("%d\n", f[c][d]);
    return 0;
}

Measured memory_bytes: 36872
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int N, M; cin >> N >> M;

  int ans = 1900 * M + 100 * (N - M);
  ans *= pow(2, M);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n;
    bool f = 1;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 2 == 0) {
            if (a % 5 != 0 && a % 3 != 0) f = 0;
        }
    }
    cout << (f? "APPROVED":"DENIED") << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}

	max := 0
	for i := 1; i < n; i++ {
		if h[i] > max {
			max = h[i]
		}
		if max-h[i] > 1 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if (N /10 % 111 == 0 || N %1000 %111 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

const int N = 2e5 + 7;

LL dp[N][2];

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

  for (auto &c : s) {
    if (c == '?') {
      c = 'D';
    }
  }

  cout << s << "\n";
  return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <vector>
using namespace std;
vector <vector <int> > adj;
vector <int> ans, visited;

void dfs (int cur)
{
	int amax = -1;
	visited[cur] = 1;
	for (int i: adj[cur])
	{
		if (!visited[i]) dfs(i);
		if (amax < ans[i]) amax = ans[i];
	}
	ans[cur] = amax + 1;
}

int main() 
{
	int n, m, x, y;
	cin >> n >> m;
	adj.resize(n + 1);
	ans.resize(n + 1);
	visited.resize(n + 1, 0);
	
	for (int i = 1; i <= m; i++)
	{
		cin >> x >> y;
		adj[x].push_back(y);
	}
	
	int amax = 0;
	for (int i = 1; i <= n; i++)
	{
		if (!visited[i]) dfs(i);
		if (amax < ans[i]) amax = ans[i];
	}
	cout << amax;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,x;
cin>>x>>n;
int a[n+1];
for(int i=0;i<n;i++)
{
	cin>>a[i];
}
int ans=110,diff=103;
for(int i=0;i<=104;i++)
{    int f=1;
		for(int j=0;j<n;j++)
		{
		if(i==a[j])
		{
			f=0;break;
		}
		}
		if(f)
		{
			if(diff>abs(i-x)){ans=i;diff=abs(i-x);}
		}

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

Measured memory_bytes: 3572
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Console.WriteLine(a[K-1]);
	}
	int[] a = {
		1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
	};
	int K;
	public Sol(){
		K = ri();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main() {

  string S;
  cin >> S;
  int N = S.size();
  bool ans = true;
  for (int i = 0; i < N; ++i) {
    if (i % 2 == 0 && S[i] == 'L') {
      ans = false;
      break;
    }
    if (i % 2 == 1 && S[i] == 'R') {
      ans = false;
      break;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
}


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

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

  cout <<s.at(0)<<s.at(1)<<s.at(2)<<s.at(3)<<s.at(4)<<" "<<s.at(6)<<
         s.at(7)<<s.at(8)<<s.at(9)<<s.at(10)<<s.at(11)<<s.at(12)<<" "<<
         s.at(14)<<s.at(15)<<s.at(16)<<s.at(17)<<s.at(18)<< endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define dish_index(n) n-1
using namespace std;

int main(){
    int N; cin >> N;
    int sum = 0;

    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N-1);

    for(int i=0; i<N; i++){
        cin >> A.at(i);
    }
    for(int i=0; i<N; i++){
        cin >> B.at(i);
    }
    for(int i=0; i<N-1; i++){
        cin >> C.at(i);
    }

    for(int i=0; i<A.size(); i++){
        sum += B.at(dish_index(A.at(i)));
        if(i < A.size()-1 && 1+A.at(i) == A.at(i+1)){
            sum += C.at(dish_index(A.at(i)));
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    string S;
    cin>>S;
    int N=sz(S);
    vector<int> A(N);
    rep(i,N){
        A.at(i)=S.at(i)-'0';
    }
    int ans=10000;
    rep(i,N-2){
        int v=A.at(i)*100+A.at(i+1)*10+A.at(i+2);
        chmin(ans,abs(753-v));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3524
#include <cstdio>
#include <algorithm>
using namespace std;
const int M = 128;
const int inf = (1<<25);

int d[M][M], p[M+2];
int path[M][M];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d %d", p+i, p+i+1);
	
	for (int i = 1; i <= n; ++i) d[i][i] = 0;
	for (int ln = 2; ln <= n; ++ln)	// 枚举矩阵链的长度 
	{
		int m = n - ln + 1; 		// 剩余矩阵的长度 
		
		for (int i = 1; i <= m; ++i)// len-ln = j-i+1 j = ln+i-1
		{
			int j = ln + i - 1;
			d[i][j] = inf;			
			for (int k = i; k < j; ++k)
				d[i][j] = min(d[i][j], d[i][k] + d[k+1][j] + p[i-1] * p[k] * p[j]);
		}		
	}
	
	printf("%d\n", d[1][n]);
	return 0;
}


Measured memory_bytes: 2784
#include<iostream>
#include<iomanip>
#include<stdio.h>

using namespace std;

int main()
{
    int n,i,j,b;
    char c;
    cin >> n;
    int a[4][13] = {{0,0,0,0,0,0,0,0,0,0,0,0,0},
                    {0,0,0,0,0,0,0,0,0,0,0,0,0},
                    {0,0,0,0,0,0,0,0,0,0,0,0,0},
                    {0,0,0,0,0,0,0,0,0,0,0,0,0}};
    for(i = 0;i < n;i++){
        cin >> c >> b;
        if(c == 'S')  a[0][b-1] = 1;
        else if(c == 'H')  a[1][b-1] = 1;
        else if(c == 'C')  a[2][b-1] = 1;
        else if(c == 'D')  a[3][b-1] = 1;
    }
    for(i = 0;i < 4;i++){
        for(int j = 0;j < 13;j++){
            if(a[i][j] != 1){
                switch(i){
                    case 0:
                    cout << "S " << j+1 << endl;
                    break;
                    case 1:
                    cout << "H " << j+1 << endl;
                    break;
                    case 2:
                    cout << "C " << j+1 << endl;
                    break;
                    case 3:
                    cout << "D " << j+1 << endl;
                    break;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9 + 7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}

vector<int>g[100010];
vector<int>level(100010,-1);
vector<int>col(100010,0);
vector<int>c(100010),d(100010),v(100010);

void dfs(int now,int x,int nowcol){
	if(level[now]>=x)return;
	if(col[now]==0)col[now] = nowcol;
	level[now] = x;
	for(auto e:g[now]){
		if(x)dfs(e,x-1,nowcol);
	}
}

signed main(){
	int N,M,Q;
	cin>>N>>M;
	REP(i,M){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	cin>>Q;
	REP(i,Q){
		cin>>v[i]>>d[i]>>c[i];
		v[i]--;
	}
	RREP(i,Q){
		dfs(v[i],d[i],c[i]);
	}
	REP(i,N){
		cout<<col[i]<<endl;
	}
}

Measured memory_bytes: 12404
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define int 		long long
#define vi 			vector<int>
#define vec(x) 		vector<x>
#define matrix 		vector<vector<int>>
#define pii 		pair<int,int>
#define repf(i,s,e)  for(int i=s;i<e;i++)
#define repb(i,e,s) for(int i=e;i>=s;i--)
#define MOD			1000000007
#define pb 			push_back
#define ff 			first
#define ss 			second		
#define w(x)		int x; cin>>x; while(x--)
const int INF=1e18;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k-1)  returns iterator to kth element starting from 0; Returns the kth smallest element
// order_of_key(k) returns count of elements strictly smaller than k;Returns the number of elements less than k
// erase,insert same as normal set


void solve(){
	int n;
	cin>>n;

	int ans=0;
	repf(i,1,n+1){
		repf(j,1,n+1){
			repf(k,1,n+1){
				ans+=__gcd(i,__gcd(j,k));
			}
		}
	}

	cout<<ans<<endl;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	if(fopen("input.txt", "r")){
	    freopen("input.txt", "r", stdin),
	    freopen("output.txt", "w", stdout);
	}
	
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

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

int decline(int c, int d) { return -c * ((d - 1) * d / 2); }

int main() {
  srand(0);

  constexpr int n = 26;
  int d;
  cin >> d;
  vector<int> c(n);
  for (auto &e : c) cin >> e;
  vector<vector<int>> s(d, vector<int>(n));
  for (auto &se : s) {
    for (auto &e : se) cin >> e;
  }

  int satisfaction = 0;
  vector<set<int>> v(n);
  for (auto &e : v) e.insert(-1);
  vector<int> t(d);
  for (int i = 0; i < d; i++) {
    t[i] = max_element(s[i].begin(), s[i].end()) - s[i].begin();
    satisfaction += s[i][t[i]];
    v[t[i]].insert(i);

    for (int j = 0; j < n; j++) {
      int last_i = *v[j].rbegin();
      satisfaction -= c[j] * (i - last_i);
    }
  }

  for (int iteration = 0; iteration < (int)1e6; iteration++) {
    int i = rand() % d, j = rand() % n;
    if (t[i] == j) continue;

    int difference = 0;
    difference -= s[i][t[i]];
    difference += s[i][j];

    auto it1_to = v[t[i]].upper_bound(i);
    auto it1_from = it1_to;
    it1_from--;
    it1_from--;
    int i1_to = it1_to == v[t[i]].end() ? d : *it1_to, i1_from = *it1_from;

    auto it2_to = v[j].upper_bound(i);
    auto it2_from = it2_to;
    it2_from--;
    int i2_to = it2_to == v[j].end() ? d : *it2_to, i2_from = *it2_from;

    difference -= decline(c[t[i]], i - i1_from) + decline(c[t[i]], i1_to - i);
    difference += decline(c[t[i]], i1_to - i1_from);

    difference -= decline(c[j], i2_to - i2_from);
    difference += decline(c[j], i - i2_from) + decline(c[j], i2_to - i);

    if (difference > 0) {
      satisfaction += difference;
      v[t[i]].erase(i);
      v[j].insert(i);
      t[i] = j;
    }

    // cerr << i << ' ' << j << endl;
    // cerr << i1_from << ' ' << i1_to << ' ' << i2_from << ' ' << i2_to << endl;
    // cerr << difference << endl;
  }

  cerr << "satisfaction: " << satisfaction << endl;
  cerr << "score: " << max((int)1e6 + satisfaction, 0) << endl;

  for (auto e : t) cout << e + 1 << endl;
}


Measured memory_bytes: 3680
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
long long int MOD = 1000000000 + 7;
using ll = long long;

int main() {
	ll n;
	cin >> n;
	vector<pair<ll, ll>> x(n);
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	for (ll i = 0; i < n; ++i) {
		cin >> x[i].first >> x[i].second;
	}
	sort(x.begin(), x.end());
	ll nn = n;
	for (ll i = 0; i < n - 1; ++i) {
		auto ic = x[i];
		auto xc = ic.first;
		auto ac = ic.second;
		auto& in = x[i + 1];
		auto xn = in.first;
		auto an = in.second;
		if (xn - an < xc + ac) { // どっちかを消す
			if (xc + ac < xn + an) {
				in = ic;
			}
			nn--;
		}
	}
	cout << nn << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
struct node
{
    int s=0;
    int num=0;
};
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        node a[6];
        int flag=1;
        map<int,node>p;
        int s[5];
        s[1]=-1;
        s[2]=-1;
        s[3]=-1;
        s[4]=-1;
        while(m--)
        {
            int x;
            cin>>x;
            cin>>p[x].s;
            p[x].num++;
            if(p[x].num>1)
            {
                if(p[x].s!=s[x])
                    flag=0;
            }
            s[x]=p[x].s;
            if(x==1&&p[x].s==0&&n!=1)
                flag=0;
        }
        if(n==1&&m==0)
        {
            cout<<0<<endl;
            continue;
        }
        if(flag==0)
        {
            cout<<-1<<endl;
            continue;
        }
        if(n==1&&p[1].s==0)
        {
            cout<<0<<endl;
            continue;
        }
        for(int i=1; i<=n; i++)
        {
            if(s[i]==-1&&i==1)
                cout<<1;
            else if(s[i]==-1)
                cout<<0;
            else
                cout<<s[i];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
 	string s;
  cin>>s;
  for(int i=0; i<s.size(); i++)
  {
   	if(i%2==0)
    {
      if(s[i]=='R' || s[i]=='U' || s[i]=='D')continue;
      else
      {
       	cout<<"No"<<endl;
        return 0;
      }
    }
    else
    {
      if(s[i]=='L' || s[i]=='U' || s[i]=='D')continue;
      else
      {
       	cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll A, B, C;

    cin >> A >> B >> C;

    cout << max(ll(0), C - (A - B)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int W, H, x, y, r;
	scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
	if (x - r >= 0 && x + r <= W&&y - r >= 0 && y + r <= H)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 2684
#include<stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(){
  int n;
  scanf("%d",&n);
  int s[n];
  for(int i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  qsort(s, n, sizeof(int), compare_int);
  /*for(int i=0;i<n;i++){
    printf("%d ",s[i]);
  }*/
  for(int i=1;i<n;i++){
    if(s[i-1]==s[i]){
      printf("NO");
      return 0;
    }
  }
  printf("YES");
}



Measured memory_bytes: 1788
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;

int n,a[200010],cnt[200010];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	int sum=0ll;
	for(int i=1;i<=n;i++){
		cin>>a[i];cnt[a[i]]++;
		sum+=cnt[a[i]]-1ll;
	}
	for(int i=1;i<=n;i++){
		cout<<sum-(cnt[a[i]]-1ll)<<'\n';
	}
	return 0;
}

Measured memory_bytes: 4736
#include<stdio.h>
int tate,yoko;
int dx[2][6] = {{-1,0,1,0,-1,-1},{0,1,1,1,0,-1}};
int dy[6] = {1,1,0,-1,-1,0,};
int field[110][110] = {0};
int drow(int x,int y)
{
    int sum = 0;
    field[x][y] = 2;
    for(int i = 0; i < 6; i++)
    {
        if(0 > x + dx[y % 2][i] || x + dx[y % 2][i] > yoko + 1 || 0 > y + dy[i] || y + dy[i] > tate + 1);
        else if(field[x + dx[y % 2][i]][y + dy[i]] == 1)sum++;
        else if(field[x + dx[y % 2][i]][y + dy[i]] == 0)
            sum = sum + drow(x + dx[y % 2][i],y + dy[i]);
    }
    return sum;
}
int main()
{
    scanf("%d%d",&yoko,&tate);
    for(int i = 1; i <= tate; i++)
        for(int j = 1; j <= yoko; j++)
            scanf("%d",&field[j][i]);
    printf("%d\n",drow(0,0));
    return 0;
}

Measured memory_bytes: 2960
#include<cstdio>
#include<cstring>
#include<iostream>

#define nn 2110
#define ll long long
using namespace std;

ll as,d[nn];
struct Edge{int to,old,w,c;}e[nn*10];
int tot,n,fm[nn],q[nn*100],S,T,l[nn],v[nn];

inline void Lnk(int x,int y,int w,int c){
    e[++tot].to=y,e[tot].old=l[x],l[x]=tot,e[tot].w=w,e[tot].c=c;
    e[++tot].to=x,e[tot].old=l[y],l[y]=tot,e[tot].w=-w,e[tot].c=0;
}
inline int Spfa(){
    //memset(d,-1,8*(T+1));
    for (int i=1;i<=T;i++) d[i]=-1e18;
    memset(v,0,4*(T+1));
    memset(fm,0,4*(T+1));
    int h=1,t=1;
    q[1]=S,d[S]=0,v[S]=1;
    while (h<=t){
        int nw=q[h];
        for (int i=l[nw];i;i=e[i].old)if(d[e[i].to]<d[nw]+e[i].w&&e[i].c){
            fm[e[i].to]=i;
            d[e[i].to]=d[nw]+e[i].w;
            if (!v[e[i].to]) q[++t]=e[i].to,v[e[i].to]=1;
        }
        h++,v[nw]=0;
    }
    return(fm[T]);
}
int flow=0;
inline ll Get(){
    int a=110;ll rs=0;
    for (int i=T;i!=S;i=e[fm[i]^1].to) 
        a=min(a,e[fm[i]].c);
    for (int i=T;i!=S;i=e[fm[i]^1].to)
        rs+=a*1ll*e[fm[i]].w,e[fm[i]].c-=a,e[fm[i]^1].c+=a;
    flow+=a;
    return(rs);
}

int main()
{
    scanf("%d",&n);
    S=n*2+6,T=n*2+7,tot=1;
    for (int i=1;i<=n;i++){
        int x,y,z;scanf("%d%d%d",&x,&y,&z);
        Lnk(S,i,0,z);
        Lnk(i,n*2+1,x+y,z);
        Lnk(i,n*2+2,x-y,z);
        Lnk(i,n*2+3,-x+y,z);
        Lnk(i,n*2+4,-x-y,z);
    }
    for (int i=1;i<=n;i++){
        int x,y,z;scanf("%d%d%d",&x,&y,&z);
        Lnk(i+n,T,0,z);
        Lnk(n*2+1,i+n,-x-y,z);
        Lnk(n*2+2,i+n,-x+y,z);
        Lnk(n*2+3,i+n,x-y,z);
        Lnk(n*2+4,i+n,x+y,z);
    }

    while (Spfa())
        as+=Get();
    printf("%lld\n",as);
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/operators.hpp>
#include <boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	template<class T>constexpr T pow(T val, std::uint64_t p)
	{
		auto ret = T(1);
		for (auto i : boost::irange(0, 63))
		{
			if (p & (1ULL << i))
			{
				ret *= val;
			}
			val *= val;
		}
		return ret;
	}
	template<std::uint64_t Mod>class modnum :
		private boost::addable<modnum<Mod>>,
		private boost::subtractable<modnum<Mod>>,
		private boost::multipliable<modnum<Mod>>,
		private boost::dividable<modnum<Mod>>
	{
		std::uint64_t val;
		void clamp()
		{
			val %= Mod;
		}
	public:
		modnum() = default;
		modnum(std::int64_t v) :val()
		{
			if (v < 0)
			{
				v += (std::abs(v) / Mod + 1) * Mod;
			}
			val = v;
			clamp();
		}
		modnum(std::uint64_t v) :val(v)
		{
			clamp();
		}
		modnum(std::int32_t v) :modnum(static_cast<std::int64_t>(v))
		{

		}
		modnum(std::uint32_t v) :modnum(static_cast<std::uint64_t>(v))
		{

		}
		friend std::ostream& operator<<(std::ostream& os, modnum const& num)
		{
			return os << num.val;
		}
		auto& operator+=(modnum const& rhs)
		{
			val += rhs.val;
			clamp();
			return *this;
		}
		auto& operator-=(modnum const& rhs)
		{
			val += Mod - rhs.val;
			clamp();
			return *this;
		}
		auto& operator*=(modnum const& rhs)
		{
			val *= rhs.val;
			clamp();
			return *this;
		}
		auto& operator/=(modnum const& rhs)
		{
			val *= pow(rhs, Mod - 2).val;
			clamp();
			return *this;
		}
		auto const& operator*()const
		{
			return val;
		}
	};
}
using mod_t = lib::modnum<1000000007>;

template<class T>auto set_factorial(std::size_t N)
{
	std::vector<T> ret(N + 1);
	ret[0] = 1;
	for (auto i : boost::irange<index_t>(0, N))
	{
		ret[i + 1] = ret[i] * (i + 1);
	}
	return ret;
}
template<class T>auto set_inverted(std::vector<T>const& vec)
{
	std::vector<T> ret(vec.size());
	for (auto i : boost::irange<index_t>(0, vec.size()))
	{
		ret[i] = 1 / vec[i];
	}
	return ret;
}

void Main()
{
	int N, K;
	std::cin >> N >> K;
	K = std::min(N, K + 1);
	auto fac = set_factorial<mod_t>(N + K);
	auto inv = set_inverted(fac);
	auto comb = [&](int n, int k)
	{
		return fac[n] * inv[k] * inv[n - k];
	};
	auto combR = [&](int n, int k)
	{
		return fac[n + k - 1] * inv[n - 1] * inv[k];
	};
	mod_t ret = 0;
	for (auto i : boost::irange(0, K))
	{
		ret += comb(N, i) * combR(N - i, i);
	}
	std::cout << ret << std::endl;
}

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

Measured memory_bytes: 6528
#include <iostream>
#include <map>
using namespace std;
const int N = 2e5 + 10;
int a[N] , n;
map <int,int> mp;
int main(){
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    long long ans = 0;
    for (int i = 1; i <= n; i++){
        ans = ans + mp[i - a[i]]; // get result at [i]
        mp[a[i] + i]++; // update result at [i]
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 21428
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll n;
  cin >> n;
  ll a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  ll dp[n];
  if(a[0] != 0){
    cout << 0 << endl;
    return 0;
  }
  dp[0] = 3;
  ll hat[3];
  hat[0] = 0;
  hat[1] = 0;
  hat[2] = 1;
  ll temp,count;
  for(int i=1;i<n;i++){
    temp = a[i];
    count = 0;
    for(int j=0;j<3;j++){
      if(temp == hat[j]){
        if(count == 0) hat[j] += 1;
        count += 1;
      }
    }
    dp[i] = dp[i-1]*count;
    dp[i] %= MOD;
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
N = gets.chomp.to_i
data = gets.chomp.split(" ").map(&:to_i)
counter = 0
while true
    break if data.map { |n| n % 2 }.select { |n| n != 0 }.size != 0
    data.map! { |n| n / 2 }
    counter += 1
end
puts counter

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

#define pb push_back
#define ll long long int
#define mpi map<int, int>
#define vi vector<int>
#define si set<int>
#define pii pair<int, int>
#define vpi vector<pii>
#define vs vector<string>
#define pri priority_queue<int>
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define For(i, n) for (int i = 0; i < n; i++)
#define Ford(i, a, b) for (int i = a; i >= b; i--)
#define Rep(i, x, y) for (int i = x; i <= y; i++)
#define mem(a, b) memset(a, b, sizeof(a))
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

double tick()
{
    static clock_t oldt, newt = clock();
    double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC;
    oldt = newt;
    return diff;
}

int main()
{
    int n;
    cin >> n;
    ll s = 0;
    Rep(i, 1, n)
    {
        if (i % 3 != 0 && i % 5 != 0)
            s += i;
    }
    cout << s << endl;
    cerr << "execution time is: " << tick() << "\n";
}


Measured memory_bytes: 3784
#include <stdio.h>
#include <set>
#include <utility>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
  ll t;
  while(b) t = a % b, a = b, b = t;
  return a;
}

ll mabs(ll a) {
  return a > 0 ? a : -a;
}

int main(void) {
  ll i, j, k, n, x, d, m, ans = 0;
  scanf("%lld%lld%lld", &n, &x, &d);
  ll sum[n + 1];
  sum[0] = 0;
  for(i = 1; i <= n; ++i) sum[i] = sum[i - 1] + i;
  if(d < 0) {
    x += d * (n - 1);
    d = -d;
  }
  if(!d) {
    printf("%lld", x ? n + 1 : 1);
    return 0;
  }
  x -= d;
  m = d / gcd(mabs(x), d);
  if(m > n) m = n;
  set< pair<ll, ll> > s;
  pair<ll, ll> p;
  set< pair<ll, ll> >::iterator it, it2;
  for(i = 0; i < m; ++i) {
    for(j = 0; i + j * m <= n; ++j) {
      p = make_pair(x * (i + j * m) + sum[i + j * m] * d, x * (i + j * m) + (sum[n] - sum[n - i - j * m]) * d);
      while(1) {
        it = s.lower_bound(p);
        if(it == s.end() || (*it).first > p.second) break;
        p.second = (*it).second > p.second ? (*it).second : p.second;
        s.erase(it);
      }
      while(1) {
        it = s.lower_bound(p);
        if(it == s.begin() || (*(--it)).second < p.first) break;
        p.first = (*it).first;
        p.second = (*it).second > p.second ? (*it).second : p.second;
        s.erase(it);
      }
      s.insert(p);
    }
    for(it = s.begin(); it != s.end(); ) {
      ans += ((*it).second - (*it).first) / d + 1;
      it2 = it;
      it2++;
      s.erase(it);
      it = it2;
    }
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 1792
n = int(input())
from itertools import product
ans = 0
for i in range(1, 11):
  for p in product("357", repeat=i):
    v = "".join(p)
    if "3" in v and "5" in v and "7" in v and int("".join(p)) <= n:
      ans += 1
print(ans)


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll inf = 1 << 30;
const ll mod = 1000000000 + 7;

int main()
{
	int n, m, c;
	cin >> n >> m >> c;

	vector<int> b(m);
	for (int i = 0; i < m; i++)
	{
		cin >> b.at(i);
	}

	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		int s = 0;
		for (int j = 0; j < m; j++)
		{
			int a;
			cin >> a;
			s += a * b.at(j);
		}
		s += c;
		if (s > 0)
		{
			cnt++;
		}
	}

	cout << cnt << endl;
}

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

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s,t;
	cin>>s>>t;
	int i,l1=s.length(),l2=t.length();
	int j;
	int dp[l1+1][l2+1];
	for(i=0;i<=l1;i++)
		dp[i][0]=0;
	for(i=0;i<=l2;i++)
		dp[0][i]=0;
	for(i=1;i<=l1;i++)
	{
		for(j=1;j<=l2;j++)
		{
			if(s[i-1]==t[j-1])
				dp[i][j]=1+dp[i-1][j-1];
			else
				dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
		}
	}
	i=l1;
	j=l2;
	string ans="";
	while(i && j)
	{
		if(s[i-1]==t[j-1])
		{
			ans=s[i-1]+ans;
			i--;
			j--;
		}
		else if(dp[i][j]==dp[i-1][j])
			i--;
		else
			j--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 38776
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

bool is_prime(int n) {
    for (int i = 2; i*i <= n; ++i) {
        if (n % i == 0) return false;
    }
    if(n==1) return false;
    return true;
}

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll n;
    ll a,b;
    ll k,t;
    string str;
    cin>>str;
    vector<ll> l(str.length()+1);
    vector<ll> r(str.length()+1);
    for(ll i=1;i<=str.length();i++){
        if(str[i-1]=='<') l[i]=l[i-1]+1;
    }
    reverse(all(str));
    for(ll i=1;i<=str.length();i++){
        if(str[i-1]=='>') r[i]=r[i-1]+1;
    }
    reverse(all(str));
    ll sum=0;
    reverse(all(r));
   // rep(i,str.length()) cout<<" "<<str[i]<<" ";
    //ln;
   // rep(i,str.length()+1){
   //     cout<<l[i]<<"  ";
   //         }ln;
    rep(i,str.length()+1){
     //   cout<<r[i]<<"  ";
        sum+=max(l[i],r[i]);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 11564
#define KAKUSUKO
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll N;

int main() {
    cin >> N;

    ll ans = INFLL;
    for (ll i = 1; i*i <= N; ++i) {
        if (N%i == 0) {
            ans = min(ans, i+(N/i) - 2);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
	int n;
	cin >> n;
	ll a[n];
	ll t[n];
	ll fa[n];
	ll ft[n];
	memset(fa, 0, sizeof fa);
	memset(ft, 0, sizeof ft);
	fa[0] = 1;
	ft[n-1] = 1;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i > 0) {
			if (a[i] != a[i-1]) {
				fa[i] = 1;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		if (i > 0) {
			if (t[i] != t[i-1]) {
				ft[i-1] = 1;
			}
		}
	}
	ll ans = 1ll;
	for (int i = 0; i < n; i++) {
		if (fa[i] || ft[i]) {
			if (fa[i] && ft[i] && a[i] != t[i]) {
				cout << "0\n";
				return 0;
			} else if (fa[i] && a[i] > t[i]) {
				cout << "0\n";
				return 0;
			} else if (ft[i] && t[i] > a[i]) {
				cout << "0\n";
				return 0;
			}
		} else {
			ans *= min(a[i], t[i]);
			ans %= 1000000007ll;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3328
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    double ans = 0;
    int tmp;
    double a, b, x;
    cin >> a >> b >> x;
    double s = x/a;
    //cout << s << endl;
    double ata;
    if(s <= a*b/2){
        ata = s * 2 / b / b;
        ans = 90 - atan(ata) *2 / M_PI *90;
    }
    else {
        s = a * b - s;
        ata = s * 2 / a / a;
        ans = atan(ata) *2 / M_PI *90;
    }
    
    cout << std::setprecision(15) <<  ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
 
long long mod = 1000000007;
 
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}
int power(long long x, long long y, long long p) {
    long long res = 1;  // Initialize result
 
    x = x % p;  // Update x if it is more than or
                // equal to p
 
    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1) res = (res * x) % p;
 
        // y must be even now
        y = y >> 1;  // y = y/2
        x = (x * x) % p;
    }
    return res;
}
 
long long modInverse(long long n, long long p) { return power(n, p - 2, p); }
 
long long nCrModPFermat(long long n, long long r, long long p) {
    if (r == 0) return 1;
    long long fac[n + 1];
    fac[0] = 1;
    for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;
 
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
}
 
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)
 
signed main() {
    long long n, a, b;
    cin >> a;
    double pi = 3.141592653589793238;
    cout << 2 * a * pi << endl;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,k;
int main() {
	scanf("%lld%lld%lld",&a,&b,&k);
	if(k<=a) a-=k;
	else {
		k-=a,a=0;
		if(k<=b) b-=k;
		else b=0;
	}
	printf("%lld %lld\n",a,b);
	return 0;
}

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;



int main(){
    ll n,k;
    cin>>n>>k;
    ll p=1;
    for(int i=0;i<n;i++){
        p*=k;
        p%=MOD;
    }
    cout<<p<<endl;
    
    
    return 0;
}


Measured memory_bytes: 3104
using System;
using System.Linq;

namespace Number
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            double[] n = s.Split(' ')
                       .Select(e => double.Parse(e))
                       .ToArray();
            double a = n[0];
            double b = n[1];
            Console.WriteLine("{0} {1} {2}",
              (int)(a / b),
              (int)(a % b),
              (a / b).ToString("0.000000"));
        }
    }
}

Measured memory_bytes: 9784
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i=1;
  while(++i<=n){
    int x=i;
    if(x%3==0){
      cout << " " << i;
      continue;
    }
    while(x){
      if(x%10==3){
    cout << " " << i;
    break;
      }
      x/=10;
    }
  }
  cout << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define pb push_back
#define odd(x) ((x)&1)
#define even(x) (!odd(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(auto i=0;i<n;++i)
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define TEST_CASE int tc;cin>>tc;while(tc--)

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

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

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define JD



int main(int argv, char* argc[])
{
    FASTIO

    #ifndef JD
        freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif

    ll n,sum=0;
    cin>>n;
    vll v(2*n);
    rep(i,n) {cin>>v[i];v[n+i]=v[i];}

    sort(all(v),greater<int>());
    rep(i,n)
    {
        if(i)
        sum+=v[i];
    }
    cout<<sum;

    return 0;
}


Measured memory_bytes: 6360
from collections import deque, Counter
from functools import reduce


H, W = map(int, input().split(" "))
area_info = [input() for _ in range(H)]

is_visit = [[False for _ in range(W)] for _ in range(H)]

next_search = deque([[0, 0, 0], ])


def get_shortest_step():
    shortest_step = -1
    while len(next_search) > 0:
        nowx, nowy, now_step = next_search.pop()
        if is_visit[nowx][nowy]:
            continue
        is_visit[nowx][nowy] = True

        for stepx, stepy in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
            nextx = nowx + stepx
            nexty = nowy + stepy
            if nextx == H-1 and nexty == W-1:
                shortest_step = now_step + 1
                return shortest_step
            if 0 <= nextx < H and 0 <= nexty < W:
                if is_visit[nextx][nexty] or area_info[nextx][nexty] == "#":
                    continue
                next_search.appendleft([nextx, nexty, now_step+1])
    return shortest_step


shortest_step = get_shortest_step()
c = Counter("".join(area_info))
if shortest_step == -1:
    print("-1")
else:
    print(c['.'] - shortest_step - 1)


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

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

using namespace std;

typedef long long ll;

ll a[4005][2005];
ll x;
int n;

int main() {
    scanf("%d %lld", &n, &x);
    FO(i,0,n) {
        scanf("%lld", &a[i][0]);
        a[i+n][0] = a[i][0];
    }
    FO(i,0,2*n) FO(j,1,n) {
        if (i != 0) a[i][j] = min(a[i][j-1], a[i-1][j-1]);
        else a[i][j] = a[i][j-1];
    }
    ll ans = 1e18;
    FO(j,0,n) {
        ll cr = j*x;
        FO(i,n,2*n) cr += a[i][j];
        ans = min(ans, cr);
    }
    printf("%lld\n", ans);
}



Measured memory_bytes: 62848
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
lint H, W;

lint solve(lint H, lint W)
{
    if (H % 3 == 0) return 0;
    lint ans = W;

    for (lint h = 1; h <= H / 2; h++)
    {
        lint hr = H - h;
        lint r1 = h * W;
        lint r2 = hr * (W / 2);
        lint r3 = hr * (W - W / 2);
        lint diff = max(abs(r1 - r2), max(abs(r2 - r3), abs(r1 - r3)));
        ans = min(ans, diff);
    }
    return ans;
}

int main()
{
    cin >> H >> W;
    cout << min(solve(H, W), solve(W, H)) << endl;
}


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

const int N = 100000;

int c[N], v[2], ok;
std::vector<int> g[N];

void dfs(int u, int cur)
{
    c[u] = cur;
    v[cur] ++;
    for (auto v : g[u]) {
        if (c[v] == -1) {
            dfs(v, cur ^ 1);
        } else {
            ok &= c[u] != c[v];
        }
    }
}

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; ++ i) {
        int a, b;
        scanf("%d%d", &a, &b);
        a --;
        b --;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    memset(c, -1, sizeof(c));
    long long result = 0;
    for (int s = 0; s < n; ++ s) {
        if (c[s] == -1) {
            v[0] = v[1] = 0;
            ok = true;
            dfs(s, 0);
            if (ok) {
                result += 1LL * v[0] * v[1];
            } else {
                int vv = v[0] + v[1];
                result += 1LL * vv * (vv - 1) / 2;
            }
        }
    }
    printf("%lld\n", result - m);
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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);}

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}

ll n;



    vector<pair<ll,ll>>p;
void fs(ll a){
    for(ll i=2;i*i<=n;i++){
        ll cnt=0;
        while(n%i==0){
            n/=i;
            cnt++;
        }
        p.emplace_back(i,cnt);
    }
    return;
}

const int m=2019;
int main()
{
string s;
cin>> s;
int n=s.size();
reverse(s.begin(),s.end());
int x=1,tot=0;
vector<int> cnt(m);
ll ans=0;
rep(i,n){
    cnt[tot]++;
    tot+=(s[i]-'0')*x;
    tot%=m;
    ans+=cnt[tot];
    x=x*10%m;
}
cout<<ans<<endl;
}



Measured memory_bytes: 3736
#素因数分解
# order O(log(N)*N**0.5)?
def fact(A): #fact(int A)
    c0 = A
    r = 2
    lis = []
    count = 1
    while A != 1:
        if A%r == 0:
            A = A//r
            lis.append(r)
            r = 2
        else:
            r += 1
        if r > int(pow(c0,0.5))+1:
            lis.append(A)
            break
    return(lis)

n = int(input())

lis = fact(n)
lis = list(set(lis))
z = min(len(lis),10)
for i in range(z):
    for j in range(2,1000):
        if lis[i]**j < n:
            lis.append(lis[i]**j)
        else:
            break
lis = sorted(lis)
c = 0
i = 0
while n != 1:
    if i > len(lis) -1:
        break
    if n%lis[i] == 0:
        n = n/lis[i]
        c += 1
    i += 1
print(c)

Measured memory_bytes: 9496
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  int ans=0;
  vector<int>A(N);
  vector<int>B(N);
  vector<int>C(N);
  rep(i,N){
    cin>>A[i];
  }
  rep(i,N){
    cin>>B[i];
    ans+=B[i];
  }
  rep(i,N-1){
    cin>>C[i];
  }
  rep(i,N-1){
    if(A[i]+1==A[i+1]){
      ans+=C[A[i]-1];
    }
  }
 
    
  
  cout<< ans <<endl;
}

Measured memory_bytes: 256