akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
using namespace std;
long long n, ans, mx, a[55], b[55], v[55], x[55];

int f() {
	int i, j, k;
	for(i=0; i<n; i++) {
		memset(x, 0, sizeof(x));
		x[a[i]] = 1;
		for(j=a[i]; j; j--) if(x[j]) {
			for(k=1; k<=j; k++) if(v[k]) x[j%k] = 1;
		}
		if(!x[b[i]]) return 0;
	}
	return 1;
}

int main(){
	int i;
	cin>>n;
	for(i=0; i<n; i++) cin>>a[i], mx = max(mx, a[i]);
	for(i=0; i<n; i++) cin>>b[i];
	for(i=1; i<=mx; i++) v[i] = 1;
	if(!f()) {cout<<-1; return 0;}
	for(i=mx; i; i--) {
		v[i] = 0;
		if(!f()) v[i] = 1;
	}
	for(i=mx; i; i--) if(v[i]) ans += 1LL<<i;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  bool ok = false;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N;j++){
      if(4*i+7*j==N){
        ok = true;
        break;
      }
    }
    if(ok){
      break;
    }
  }
  if(ok){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

int main() {
	int N;
	cin >> N;
	deque<int> deq;
	rep(i, N)
	{
		int	a, b;
		cin >> a >> b;
		if (a == 0)
		{
			int	c;
			cin >> c;
			if (b == 0)
				deq.push_front(c);
			else 
				deq.push_back(c);
		}
		else if (a == 1)
			cout << deq.at(b) << endl;
		else if (a == 2)
		{
			if (b == 0)
				deq.pop_front();
			else 
				deq.pop_back();
		}
	}
}



Measured memory_bytes: 4520
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 


int main()
{
    LL N;
    cin >> N;

    LL ans = N * (N-1) / 2;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n,m;
int main(){
	scanf("%d",&n);m=n+!(n&1);
	printf("%d\n",(n*(n-1)>>1)-(n>>1));
	for (int i=1;i<=n;i++)
	for (int j=i+1;j<=n;j++)
	if(i+j!=m) printf("%d %d\n",i,j);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector <int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  
  sort(A.begin(), A.end());
  int ans = 0;
  int number = 0;
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (A[i]==number) {
      cnt++;
      continue;
    }
    if ((cnt%2)==1) {
      ans++;
    }
    cnt = 1;
    number = A[i];
  }
  if ((cnt%2)==1) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = 1000000007;
using namespace std;
using vec = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};

int n;
int res = 0;

int main(int argc, char *argv[]){
    cin >> n;
    vec W(n);
    int sum = 0;
    rep(i, n){
        cin >> W[i];
        sum += W[i];
    }
    // sort(all(W));
    // res = sum - W[i];
    int mid = sum / 2;
    // for(int i = n - 2; i >= 1; i--){
    //     if()
    // }
    // rep(i, n - 1){
    //     sum -= W[i];
    //     if()
    // }
    int sum1, sum2;
    sum1 = sum2 = 0;

    // rep(i, n){
    //     if(i % 2 == 0)
    //         sum1 += W[i];
    //     else
    //         sum2 += W[i];
    // }
    sum1 = 0;
    sum2 = 0;
    int l = 0; int r = n - 1;
    while(1){
        if(l > r) break;
        if(sum1 < sum2){
            sum1 += W[l];
            l++;
        }else{
            sum2 += W[r];
            r--;
        }
    }
    cout << abs(sum1 - sum2) << endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
priority_queue<int>p;//,vector<int>,greater<int>>p;
int n,m,a,b;
ll ans;
vector<P>v;
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end());
    int i=0,k=1;
    while(k<=m){
        int ok=1;
        while(ok){
            if(v[i].first==k){p.push(v[i].second);i++;}
            else ok=0;
        }
        if(!p.empty()){
            ans+=p.top();
            p.pop();
        }
        //cout<<ans<<endl;
        k++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    REV(s);
    ll ans = 0;
    string ss = "RGB";
    vector<map<char, int>> mp(n);
    rep(i,0,n-2){
        rep(j,0,2){
            if(s[i] == ss[j])mp[i+1][s[i]] = mp[i][s[i]] + 1;
            else mp[i+1][ss[j]] = mp[i][ss[j]];
        }
    }
    REV(s);
    REV(mp);
    rep(i,0,n-2){
        if(s[i] == 'R')ans += mp[i]['G'] * mp[i]['B'];
        if(s[i] == 'G')ans += mp[i]['B'] * mp[i]['R'];
        if(s[i] == 'B')ans += mp[i]['R'] * mp[i]['G'];
    }
    rep(j,1,n-2){
        rep(i,0,j-1){
            int w = j-i;
            if(j + w > n-1)continue;
            if(s[i] != s[j] && s[j] != s[j+w] && s[j+w] != s[i])ans--;
        }
    }
    // cout << mp[n-1]['R'] << " " << mp[n-1]['G'] << " " << mp[n-1]['B'] << endl;
    // cout << mp[1]['R'] << " " << mp[1]['G'] << " " << mp[1]['B'] << endl;


    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 4128
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define deb(x) cout << #x << " = " << x << ' ';
#define rep(i, a, b) for(int i=(int)(a); i<(int)(b); i++)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 998244353;
const int N = 5e5+2;


int main()
{
   int n, k;
   scn(n); scn(k);

   vector<int> a(n+1), dp(n+1, inf);

   rep(i, 1, n+1) {
      scn(a[i]);
   }

   dp[1] = 0; dp[2] = abs(a[1] - a[2]);

   rep(i, 3, n+1) {
      // I can make a max of j + k jump, so j = max(i - k, 1)

      for(int j=max(i-k, 1); j<i; j++) {
         dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
      }
   }

   prin(dp[n]);
   return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const ll MOD = 1000000007;
using pint = pair<ll, ll>;

int main() {
  ll L, R;
  cin >> L >> R;
  ll mod = 2019;
  ll out = INF;
  if (R - L >= 2019) {
    cout << 0 << endl;
  } else {
    for (ll i = L; i < R; i++){
      for(ll j = i + 1; j <= R; j++){
        out = min(out, (i * j) % mod);
      }
    }
    cout << out << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
//aoj0118
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0;i<int(n);i++)
int R,C;
char field[100][100];
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
void dfs(int row, int col, char c){
	if(row==-1||row>=R) return ;
	if(col==-1||col>=C) return ;
	if(field[row][col]!=c) return;
	field[row][col]=' ';
	forn(i,4){
		dfs(row+dx[i],col+dy[i],c);
	}
	return ;
}
int main(){
	cin>>R>>C;
	while(R>0&&C>0){
		forn(i,R){
			forn(j,C){
				cin>>field[i][j];
			}
		}
		int ans = 0;
		forn(i,R){
			forn(j,C){
				if(field[i][j]!=' '){
					dfs(i,j, field[i][j]);
					ans++;
				}
			}
		}
		cout<<ans<<endl;
		cin>>R>>C;
	}
	return 0;
}

Measured memory_bytes: 3452
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	int Q;
	int l;
	int r; 
	int[] c;
	boolean[] f;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		
		c = new int[100001];
		f = new boolean[100002];
		
		for(int i = 2; i <=100000; i++) {
			if((!f[i])) {
				for(int j = i + i; j <= 100000; j+=i) {
					f[j] = true;
				}
			}
		}
		for(int i = 3;i <=100000; i+=2) {
			if(!f[i] && !f[(i+1)/2]) c[i]++;
		}
		for(int i = 3; i <=100000; i++) {
			c[i] += c[i-1];
		}
		Q = sc.nextInt();
	
		for(int i = 0; i < Q; i++) {
			l = sc.nextInt();
			r = sc.nextInt();
			System.out.println(c[r] -c[l-1]);
		}

		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

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

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

int main(void)
{
  ll x, y; cin >> x >> y;
  if(x % y == 0) {cout << -1 << endl; return 0;}
  cout << x << endl;
}


Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
 
public class Main {
    static int H;
    static int W;
    static int N;
    static char[][] field=new char[1001][1001];
    static int[][] num=new int[1001][1001];
    static int sx=0, sy=0;
    static int INF=100000000;
    static int[][] d=new int[1001][1001];
    static int[] dx= {1, 0, -1, 0};
    static int[] dy= {0, 1, 0, -1};
    static int sum=0;
 
    static class State{
        int h, w;
        State(int h, int w){
            this.h=h;
            this.w=w;
        }
    }
 
    static int bfs(int sx, int sy, int c) {
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                d[i][j]=INF;
            }
        }
        d[sx][sy]=0;
        Queue<State> queue=new LinkedList<>();
        queue.add(new State(sx, sy));
 
 
        int minstep=0;
        int nextx=0, nexty=0;
        while(!queue.isEmpty()) {
            State state=queue.remove();
            //System.out.println(state.h+" "+state.w+" "+d[state.h][state.w]);
            if(num[state.h][state.w]==c) {
                minstep=d[state.h][state.w];
                nextx=state.h;
                nexty=state.w;
                //System.out.println(nextx+" "+nexty+" "+minstep);
                break;
            }
            for(int i=0; i<4; i++) {
                int nx=state.h+dx[i];
                int ny=state.w+dy[i];
                if(nx>=0 && nx<H && ny>=0 && ny<W && d[nx][ny]==INF) {
                    if(field[nx][ny]=='.') {
                        d[nx][ny]=d[state.h][state.w]+1;
                        queue.add(new State(nx, ny));
                    }
                    else if(field[nx][ny]=='X') {
                        continue;
                    }
                    else {
                        d[nx][ny]=d[state.h][state.w]+1;
                        queue.add(new State(nx, ny));
                    }
                }
            }
        }
        sum+= minstep;
        if(c!=N) {
            bfs(nextx, nexty, c+1);
        }
        return sum;
    }
 
    public static void main(String args[]){
        try(Scanner sc=new Scanner(System.in)){
            H=sc.nextInt();
            W=sc.nextInt();
            N=sc.nextInt();
 
            for(int i=0; i<H; i++) {
                String str=sc.next();
                for(int j=0; j<W; j++) {
                    field[i][j]=str.charAt(j);
                    if(field[i][j]=='S') {
                        sx=i; sy=j;
                        field[i][j]='.';
                    }
                    else if(field[i][j]!='X' && field[i][j]!='.') {
                        num[i][j]=str.charAt(j)-'0';
                    }
                }
            }
            System.out.println(bfs(sx, sy, 1));
 
 
 
        }
    }
}


Measured memory_bytes: 109920
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LLINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

string s;
ll ans = 0;

void dfs(ll k,ll l,ll sum) {
	if (k == s.length()) {
		ans += sum + l;
		return;
	}
	dfs(k + 1, s[k] - '0', sum + l);
	dfs(k + 1, (l * 10) + s[k] - '0', sum);
}

int main() {
	cin >> s;
	dfs(0, 0, 0);
	cout << ans / 2;
}

Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力

		string str = Console.ReadLine();
      	int a = 0;
      	int b = 10000;
      	for (int i = 0; i < str.Length - 2; i++)
        {
          a = int.Parse(str[i].ToString()) * 100 + int.Parse(str[i+1].ToString()) * 10 + int.Parse(str[i+2].ToString());
  //        Console.WriteLine(a);
          int c = Math.Abs(a - 753);
   //       Console.WriteLine(c);
          if (b > c){
            b = c;
          }
          c = 0;
        }
      Console.WriteLine(b);


	}
}

Measured memory_bytes: 13140
#include "bits/stdc++.h" //STL loaded
typedef long long ll;
using namespace std; //class or something but required for almost everything

main()
{
	ios::sync_with_stdio(0); 
    cin.tie(0); 
    string S,T; 
    getline(cin,S);
  	getline(cin,T);
  int nS = S.size(),nT = T.size(),count,ans=0;
  for(int i=0; i<=nS-nT;i++){
    int k = i,count=0;
  	for(int j=0;j<nT;j++){
    	if(S[k]==T[j]) count++;
      k++;
    }
    ans = max(ans,count);
  }
    
  cout<<nT-ans<<endl;  
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Globalization;

namespace cswork
{
    class Program
    {
        public Program() { }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        void Omame()
        {
            cin = new Scanner();
            double a = cin.nextInt();
            double b = cin.nextInt();
            double h = cin.nextInt();
            double m = cin.nextInt();

            double hKakudo = 90 + 30 * (h + m / 60);
            double mKakudo = 90 + 6 * m;
            double hx = a * Math.Cos(hKakudo * (Math.PI / 180));
            double hy = a * Math.Sin(hKakudo * (Math.PI / 180));

            double mx = b * Math.Cos(mKakudo * (Math.PI / 180));
            double my = b * Math.Sin(mKakudo * (Math.PI / 180));

            double d = Math.Pow(mx - hx, 2) + Math.Pow(my - hy, 2);
            d = Math.Pow(d, 0.5);

            Console.WriteLine(d);
        }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();

            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next();
        }

        public int nextInt()
        {
            return int.Parse(next());
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }
    }
}

Measured memory_bytes: 28420
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int M = 1e9 + 7;
ll factorial(ll n) {
	ll ans = 1;
	FOR(i, 1, n+1) {
		ans *= i;
		ans %= M;
		//cout << ans << endl;
    }
	return ans;
}
int main() {
	int n, m;
	cin >> n >> m;
	bool bi = false;
	bool flag = false;
	if (n - m == 0) {
		bi = true;
		flag = true;
	}
	else if (abs(n - m) == 1) {
		flag = true;
	}
	ll ans = 1;
	if (flag) {
		ans *= factorial(n)*factorial(m)%M;
	if (bi) {
			ans *= 2;
	}
		ans %= M;
		cout << ans << endl;

	}
	else {
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll X;
  cin >> X;
  REP(i, 1000 + 1) {
    if (X >= i * 100 && (X - (i * 100)) <= 5 * i) {
      cout << '1' << endl;
      return 0;
    }
  }
  cout << '0' << endl;
  return 0;
}


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

int main(){
    string S, T;
    cin >> S;
    cin >> T;
    int s=0;
    for(int i=0; i<(int)S.size(); ++i){
        if(S[i]!=T[i]) s++;
    }
    cout << s << endl;
}

Measured memory_bytes: 3916
# get line input split by space
def getLnInput():
    return input().split()


# ceil(a / b) for a > b
def ceilDivision(a, b):
    return (a - 1) // b + 1


def call(n):
    i = 1
    while i < n:
        i += 1
        x = i
        if not x % 3:
            print(" " + str(i), end="")
        else:
            while True:
                if x % 10 == 3:
                    print(" " + str(i), end="")
                    break
                x //= 10
                if not x:
                    break
    print()


def main():
    n = int(getLnInput()[0])
    call(n)
    return


main()

Measured memory_bytes: 7928
#include<bits/stdc++.h>
using namespace std;
int main() {
  auto M = 1000000;
  vector<bool> prime(M, true);
  prime[0] = prime[1] = false;
  for(auto i=2; i*i<M; ++i) if(prime[i]) for(auto j=i+i; j<M; j+=i) prime[j] = false;
  int N;
  cin >> N;
  vector<int> a;
  for(auto i=1; a.size()<N && i<M; i += 5) if(prime[i]) a.emplace_back(i);
  for(auto i=0; i<a.size(); ++i) cout << (i ? " " : "") << a[i];
  cout << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
    string s,s1;
    while(cin>>s>>s1)
    {
        string ss;
        cin>>ss;
        cout<<char(s[0]-32)<<char(s1[0]-32)<<char(ss[0]-32)<<"\n";

    }
    return 0;
}


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

using namespace std;

int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (k == i * (m - j) + j * (n - i)) {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 256
# Aizu Problem 0052: Factorial II
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def factorial_trailing_zeros(N):
    ans = 0
    k = 5
    while k <= N:
        ans += N // k
        k *= 5
    return ans

    
while True:
    N = int(input())
    if N == 0:
        break
    print(factorial_trailing_zeros(N))

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

int main() {
  	int k, n;
  	scanf("%d%d", &k, &n);
  	int mx, first, x, prev;
  	scanf("%d", &first);
  	mx = prev = first;
  for (int i=1; i<n; i++) {
  	scanf("%d", &x);
    if (x-prev > mx) mx = x - prev;
    prev = x;
  }
  if (k-prev+first > mx) mx = k - prev + first;
  cout << k - mx << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 3010

ll power(ll k, ll n, int M){
  ll res = 1;
  while(n > 0) {
    if (n & 1) res = res * k % M;
    k = k * k % M;
    n /= 2;
  }
  return res;
}

/* ラグランジュ補間 */
// y[i] = f(x[i]) mod P
// 0 <= x[i], y[i] < P
vector<int> lagrangeInterpolation(const vector<int> &x, const vector<int> &y, int P) {
  int N = x.size();
  vector<ll> Q(N+1);
  vector<int> res(N);

  Q[0] = 1;
  for (int i=0; i<N; i++) {
    for (int j=i; j>=0; j--) {
      Q[j+1] = (Q[j+1] + Q[j] * (P-1)) % P;
      Q[j] = Q[j] * x[i] % P;
    }
  }

  for (int i=0; i<N; i++) {
    ll ainv = power(x[i], P-2, P), c = 1;

    for (int j=0; j<N; j++)
      if (i != j) c = c * (x[j] - x[i] + P) % P;

    ll prev = Q[0], p = (ll)y[i] * power(c, P-2, P) % P;
    for (int j=0; j<N; j++) {
      ll v = x[i] ? prev * ainv % P : P - Q[j+1]; //Q[j+1] / (P-1) % P;
      res[j] = (v * p + res[j]) % P;
      prev = (Q[j+1] + v) % P; //prev = (Q[j+1] - v * (P-1) % P + P) % P;
    }
  }

  return res;
}

int main() {
  int P;

  cin >> P;

  vector<int> y(P), x(P);

  for(int i=0; i<P; i++) {
    cin >> y[i];
    x[i] = i;
  }

  auto res = lagrangeInterpolation(x, y, P);

  for (int i=0; i<P; i++) {
    printf("%d%c", res[i], " \n"[i==P-1]);
  }
}


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

int main()
{
    int num, g, h, i, j;
    bool ok = true;
    cin >> num;
    g = num/1000;
    num = num% 1000;
    h = num/100;
    num = num%100;
    i = num/10;
    num = num%10;
    j = num;
    if((g+h+i+j)==7 && ok==true){
        cout << g << "+" << h << "+"<< i << "+"<< j << "=" << "7" << endl;
        ok=false;
    }
    if((g+h+i-j)==7 && ok==true){
        cout << g << "+" << h << "+"<< i << "-"<< j << "=" << "7" << endl;
        ok=false;
    }
    if((g+h-i+j)==7 && ok==true){
        cout << g << "+" << h << "-"<< i << "+"<< j << "=" << "7" << endl;
        ok=false;
    }
    if((g+h-i-j)==7 && ok==true){
        cout << g << "+" << h << "-"<< i << "-"<< j << "=" << "7" << endl;
        ok=false;
    }
    if((g-h+i+j)==7 && ok==true){
        cout << g << "-" << h << "+"<< i << "+"<< j << "=" << "7" << endl;
        ok=false;
    }
    if((g-h+i-j)==7 && ok==true){
        cout << g << "-" << h << "+"<< i << "-"<< j << "=" << "7" << endl;
        ok=false;
    }
    if((g-h-i+j)==7 && ok==true){
        cout << g << "-" << h << "-"<< i << "+"<< j << "=" << "7" << endl;
        ok=false;
    }
    if((g-h-i-j)==7 && ok==true){
        cout << g << "-" << h << "-"<< i << "-"<< j << "=" << "7" << endl;
        ok=false;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define MOD 1000000007
#define mod 998244353
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 2000009
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define umap unordered_map<int, int>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
#define int long long
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}
 

vector<pair<int,int> > arr(10);

map<pair<int,int>,ld> mp;
ld ans = 0;
int n;
void fun(vector<int> temp, ld curr) {
    if(temp.size() == n) {
        ans+= curr;
        // for(auto it : temp) {
        //     cout<<it<<" ";
        // }
        // cout<<endl;
        return;
    }
    for(int i=0; i<n; i++) {
        if(find(all(temp),i) == temp.end()) {
            int prev = temp.back();
            temp.push_back(i);
            fun(temp,curr + mp[mpr(i,prev)]);
            temp.pop_back();
        }
    }
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
 

void test_case() {
    
    
    cin>>n;

    COMinit();

    
    rep(i,n) {
        int x,y;
        cin>>x>>y;
        arr[i] = mpr(x,y);
    }

    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            ld  d= pow(arr[i].first - arr[j].first,2) + pow(arr[i].second -arr[j].second,2);
            d = sqrt(d);
            // cout<<d<<endl;
            mp[mpr(i,j)] = d;
            mp[mpr(j,i)] = d;
        }
    }
    

    vec temp;
    for(int i=0; i<n; i++) {
        temp.push_back(i);
        fun(temp,0.0);
        temp.pop_back();

    }

    ld fin = ans/fac[n];

    // cout<<ans<<endl;

    cout<<fin<<endl;


}
    

signed main ()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

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

int main(){
    int n, m;
    cin >> n >> m;
    cout << (n+m) * (n+m+-1) / 2 - n * m << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>
#include <iterator>
#include <iomanip>
#define rep(i,n) for(int i = 0; i < (n); i++) 
using namespace std;

int main() {
    long long n;
    string str;
    char word;
    int offset;

    cin >> n;
    cin >> str;

    rep(i,str.size()) {
        offset = str[i] + n;
        if(offset > 90) {
            offset = (offset - 90) + 64;
            word = offset;
        } else {
            word = offset;
        }
        str[i] = word;
    }
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

A, B = map(int, input().split())
l = prime_decomposition(gcd(A, B))

print(len(set(l))+1)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int a,b,c;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	if (a>c) swap(a,c);
	if (b>c) swap(b,c);
	a=c-a;b=c-b;
	if (a%2==0&&b%2==0) printf("%d\n",a/2+b/2);
	else if (a%2==1&&b%2==0) printf("%d",a/2+b/2+2);
	else if (a%2==0&&b%2==1) printf("%d",a/2+b/2+2);
	else if (a%2==1&&b%2==1) printf("%d",a/2+b/2+1);
	return 0;
}

Measured memory_bytes: 256
N, M =map(int, input().split())
mi = 0
ma = N
for i in range(M):
    l, r = map(int, input().split())
    if mi < l:
        mi = l
    if ma > r:
        ma = r
if ma < mi:
    print(0)
else:
    print(ma-mi+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
template <typename T>
using V = std::vector<T>;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  V<int> L(n);
  REP(i, n) cin >> L[i];
  i64 count = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (L[i] == L[j]) continue;
      for (int k = j + 1; k < n; ++k) {
        if (L[k] == L[i] || L[k] == L[j]) continue;
        V<int> x = {L[i], L[j], L[k]};
        sort(x.begin(), x.end());
        if (x[0] + x[1] > x[2]) {
          ++count;
        }
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3636
# Your code here!
s=gets.chomp()
ss=s.unpack("C*")
l=s.length()
ans=0
a=200000
z=0

#for i in 0..l-1
#    if ss[i]==65
#        j=i
#        while ss[j]<90
#            j=j+1
#        end
#        b=j-i+1
#        #puts(i,j)
#        if ans<b
#           ans=b
#end
#    end
#end

for i in 0..l-1
    if ss[i]==65&&a>i
        a=i
    end
    if ss[i]==90&&z<i
        z=i
    end
end

puts(z-a+1)

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 55;
const int MAX_M = 2555;

ll dp[MAX_N][MAX_N][MAX_M]; // dp[j][k][s]:= j 枚目をみて、k 枚選んで xi の合計を s にするような選び方の総数

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, A; cin >> N >> A;
	vector<int> x(N, 0);
	rep (i, N){
		cin >> x[i];
	} // end rep

	sort(ALL(x));
	int X = max(A, x[N-1]);

	dp[0][0][0] = 1LL;
	rep (j, N){
		for (int k = 0; k <= j; ++k){
			for (int s = 0; s <= X*N; ++s){
				dp[j + 1][k + 1][s + x[j]] += dp[j][k][s];
				dp[j + 1][k][s] += dp[j][k][s];
			} // end for
		} // end for
	} // end rep

	ll res = 0LL;
	for (int k = 1; k <= N; ++k){
		res += dp[N][k][k*A];
	} // end for

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 55552
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var word = Console.ReadLine().Split(' ');

            char A_End = word[0].ToCharArray()[word[0].Length - 1];
            char B_Start = word[1].ToCharArray()[0];
            char B_End = word[1].ToCharArray()[word[1].Length -1];
            char C_Start = word[2].ToCharArray()[0];

            if (A_End==B_Start && B_End==C_Start) 
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 11092
//#define _GLIBCXX_DEBUG
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,M; cin>>N>>M;
  scc_graph graph(N);
  rep(i,M){
    ll a,b; cin>>a>>b;
    graph.add_edge(a,b);
  }
  
  cout<<graph.scc().size()<<'\n';
  for(auto scc:graph.scc()){
    cout<<scc.size();
    for(auto v:scc) cout<<" "<<v;
    cout<<'\n';
  }
  
  return 0;
}

Measured memory_bytes: 40112
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> Qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> Qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int ans=a*x+b*y,temp;
  REP1(i,max(x,y)) {
    if(i<=min(x,y)) {
      ans=min(ans,ans-a-b+2*c);
    } else {
      if(x>y) {
        ans=min(ans,ans-a+2*c);
      } else {
        ans=min(ans,ans-b+2*c);
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var t = new Test();
            var input = t.ParseIntList(t.ReadInput());
            var a = t.ParseIntList(t.ReadInput());
            var sum = 0;

            foreach(var val in a)
            {
                sum += val; 
            }

            var ans = input[0] - sum;
            if (ans < 0)
            {
                Console.WriteLine("-1");
            }
            else
            {
                Console.WriteLine(ans);
            }
            
        }


        public int ReadInputOneLine()
        {
            return int.Parse(Console.ReadLine());
        }

        public string[] ReadInput()
        {
            return Console.ReadLine().Split(' ');
        }

        public List<int> ParseIntList(string[] x)
        {
            var convertedList = new List<int>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(int.Parse(x[i]));
            }

            return convertedList;
        }


        public List<double> ParseDoubleList(string[] x)
        {
            var convertedList = new List<double>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(double.Parse(x[i]));
            }

            return convertedList;
        }

        public List<long> ParseLongList(string[] x)
        {
            var convertedList = new List<long>(x.Length);
            for (var i = 0; i < x.Length; i++)
            {
                convertedList.Add(long.Parse(x[i]));
            }

            return convertedList;
        }

        public int CountContainWords(string source, string word)
        {
            var count = 0;
            var loopCount = source.Length - (word.Length - 1);
            for (var i = 0; i < loopCount; i++)
            {
                if (source.Substring(i, word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 19392
s = str(input())
cnt = 0
cnt_max = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
        cnt += 1
        if cnt > cnt_max:
            cnt_max = cnt
    else:
        cnt = 0
print(cnt_max)

Measured memory_bytes: 3060
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare #.OPT
           #-swank (sb-kernel:ansi-stream in))
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((result (loop (let ((byte (%read-byte)))
                           (when (<= 48 byte)
                             (return (- byte 48)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte)
              (setq result (+ (- byte 48) (* 10 (the (integer 0 #.(floor most-positive-fixnum 10)) result))))
              (return result)))))))

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

;; Body

(define-modify-macro minf (new-value)
  (lambda (x y) (min x y)))

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (k (read))
         (hs (make-array n :element-type '(unsigned-byte 32)))
         (dp (make-array n :element-type '(unsigned-byte 32) :initial-element #xffffffff)))
    (declare ((unsigned-byte 31) n k))
    (setf (aref dp 0) 0)
    (dotimes (i n)
      (setf (aref hs i) (read-fixnum)))
    (dotimes (i n)
      (let ((h (aref hs i))
            (d (aref dp i)))
        (loop for dest from (+ i 1) to (min (+ i k) (- n 1))
              do (minf (aref dp dest) (+ d (abs (- h (aref hs dest))))))))
    (println (aref dp (- n 1)))))

#-swank (main)


Measured memory_bytes: 22752
//Daniel Grzegorzewski
#include <bits/stdc++.h>

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios()
{
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

int a, b, k;
VI v;

int main()
{
	init_ios();
	cin >> a >> b >> k;
	for (int i = a; i < min(b+1, a+k); ++i)
		v.PB(i);
	for (int i = max(a, b-k+1); i <= b; ++i)
		v.PB(i);
	sort(v.begin(), v.end());
	for (int i = 0; i < v.size(); ++i)
		if (i == 0 || v[i] != v[i-1])
			cout<<v[i]<<"\n";
}

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

typedef long long int ll;
typedef pair<ll,ll> P;
//cout<<fixed<<setprecision(15);

int fx[11234567];

int main(){
    int n;
    cin>>n;
    for(int i=0;i<=n;i++){
        fx[i]=0;
    }
    for(int i=n;i>0;i--){
        for(int k=i;k<=n;){
            fx[k]++;
            k+=i;
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=i*fx[i];
        //cout<<i<<":"<<fx[i]<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
    int N, M;
    cin >> N >> M;
    const int NMMAX = 50;
    int A[NMMAX], B[NMMAX], C[NMMAX], D[NMMAX];

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

    for (int i = 0; i < M; ++i)
    {
        cin >> C[i] >> D[i];
    }
    for (int i = 0; i < N; ++i){
        int min_dist = abs(A[i] - C[0]) + abs(B[i] - D[0]);
        int checkpoint = 1;

        for (int j = 1; j < M;++j){
            const int cur_dist = abs(A[i] - C[j]) + abs(B[i] - D[j]);
            if( min_dist > cur_dist ){
                min_dist = cur_dist;
                checkpoint = j + 1;
            }
        }

        cout << checkpoint << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,a,b = inpm()

def pow_k(x, n):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x % mod
        x *= x % mod
        n = n // 2 % mod

    return K * x

ret = (pow_k(2,n) - 1) % mod

modinv_table = [-1] * (max(a,b)+1)
modinv_table[1] = 1
for i in range(2, max(a,b)+1):
    modinv_table[i] = (-modinv_table[mod % i] * (mod // i)) % mod

def binomial_coefficients(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
        ans *= modinv_table[i + 1]
        ans %= mod
    return ans

aa = binomial_coefficients(n,a) % mod
bb = binomial_coefficients(n,b) % mod

ret = (ret - aa - bb) % mod

print(ret)

Measured memory_bytes: 38084
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 1000005
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define P pair<int,int> 
#define INF 1000000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    char a;
    cin>>a;
    a=a+1;
    OUT(a);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string N; cin >> N;
	if (N[N.size() - 1] == '3') {
		cout << "bon" << "\n";
	}
	else if (N[N.size() - 1] == '0' || N[N.size() - 1] == '1' || N[N.size() - 1] == '6' || N[N.size() - 1] == '8') {
		cout << "pon" << "\n";
	}
	else cout << "hon" << "\n";

	return 0;
}

Measured memory_bytes: 3648
MOD = 10**9 + 7

n, k = map(int, input().split())

c = 0

d = [0] * (k + 1)

for i in range(k, 0, -1):

        # temp_c = 0
    if d[i] == 0:

        
        t1 = k // i    
        c1 = pow(t1, n, MOD)

        j = i
        while j + i <= k:
            j += i
            c1 -= d[j]
            if c1 < 0:
                c1 += MOD

        d[i] = c1

        # print (i, d[i])

        c += i * c1
        c %= MOD

print (c)

Measured memory_bytes: 11244
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
#include<algorithm> 
using namespace std;

bool c[26];
signed main() {
	string a, b; cin >> a >> b;
	for (int i = 0; i < a.length(); i++) {
		if (!c[a[i] - 'a']) {
			c[a[i] - 'a'] = true;
			for (int j = 0; j < a.length(); j++) {
				if (a[j] == a[i] && b[j] != b[i]) {
					puts("No");
					return 0;
				}
			}
		}
	}
	memset(c, false, sizeof(c));
	for (int i = 0; i < a.length(); i++) {
		if (!c[b[i] - 'a']) {
			c[b[i] - 'a'] = true;
			for (int j = 0; j < b.length(); j++) {
				if (b[j] == b[i] && a[j] != a[i]) {
					puts("No");
					return 0;
				}
			}
		}
	}
	puts("Yes");
}

Measured memory_bytes: 900
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	c := nextStr()

	fmt.Printf("%c\n", c[0]+1)
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 640