akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int const MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dp[1001][1001];

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

    string s1,s2; cin>>s1>>s2;
    fill(dp[0],dp[1001],MOD);
    for (int i = 0; i < s1.size(); i++)dp[i][0]=i;
    for (int i = 0; i < s2.size(); i++)dp[0][i]=i;
    for (int i = 0; i < s1.size(); i++){
        for (int j = 0; j < s2.size(); j++){
            chmin(dp[i+1][j+1],min(dp[i][j]+(s1[i]!=s2[j]?1:0),min(dp[i+1][j]+1,dp[i][j+1]+1)));
        }
    }
    cout<<dp[s1.size()][s2.size()]<<'\n';
}


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

//template
typedef long long int ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define repr(i,n) for(ll i=n;i>0;i--)
#define all(v) v.begin(),v.end()
#define in cin>>
#define out cout<<
#define en <<endl
const ll INF = 10000000000000;

int main()
{
	string S;
	in S;
	if (S.at(0) != S.at(1) || S.at(0) != S.at(2) || S.at(1) != S.at(2))
	{
		out "Yes" en;
	}
	else
		out "No" en;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){

	int p,q,start,end;
	int* table = new int[1000000];
	bool FLG;

	while(scanf("%d %d",&p,&q)!=EOF){
		for(int i=0; i < q;i++)table[i] = -1;

		FLG = false;

		table[p] = 0;

		for(int i=1;i<=80;i++){
			p = 10*p;
			printf("%d",p/q);
			p = p%q;
			if(p == 0)break;
			if(table[p] == -1){
				table[p] = i;
			}else{
				FLG = true;
				start = table[p];
				end = i-1;
				break;
			}
		}

		printf("\n");
		if(FLG){
			for(int i=0; i < start; i++)printf(" ");
			for(int i=start; i <= end; i++)printf("^");
			printf("\n");
		}

	}

    return 0;
}

Measured memory_bytes: 6468
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		sc.close();
		
		String s = "" + a + b;
		int sn = Integer.valueOf(s);
		double sq = Math.sqrt(sn);
		int  sqi = (int) sq; 
		
		if (sn == sqi*sqi) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}

}

Measured memory_bytes: 21716
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstdlib>
#include <ctime>
#include <deque>
using namespace std;

int n, m, a[210000], b[210000], c[210000];
int ans;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		int x;
		scanf("%d", &x);
		a[x] += 1;
	}
	for (int i = 1; i <= 100000; i++) {
		b[i % m] += a[i] % 2;
		c[i % m] += a[i] / 2;
	}
	// for (int i = 0; i < m; i++)
	// printf("%d %d\n", b[i], c[i]);
	for (int i = 0; i <= m - i && i < m; i++)
		if (i != (m - i) % m) {
			int k = min(b[i], b[m - i]);
			ans += k;
			b[i] -= k;
			b[m - i] -= k;
			// printf("kk %d\n", k);
			if (b[i]) {
				k = min(b[i] / 2, c[m - i]);
				ans += k * 2;
				c[m - i] -= k;
			}else {
				// printf("xx %d %d\n", b[m - i], c[i]);
				k = min(b[m - i] / 2, c[i]);
				ans += k * 2;
				c[i] -= k;
			}
			ans += c[i] + c[m - i];
		}else {
			ans += c[i] + b[i] / 2;
		}
	printf("%d\n", ans);
}

Measured memory_bytes: 1408
# 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;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int main () {
	SpeedForce;
		
	ll n, x;
	cin >> n >> x;
	ll ans = 0;

	while (x != 0) {
		ans += ((n - x) / x) * 3 * x;
		n = (n % x + x);
		x = n - x;
	}

	cout << ans << '\n';
	return Accepted;
}

// B...a

Measured memory_bytes: 256
import sys

readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]

n, c = readIntN()
ds = [readIntN() for _ in range(c)]
cs = [readIntN() for _ in range(n)]

acc = [[0] * c for _ in range(3)]
for i in range(n):
    for j in range(n):
        a = (i + j) % 3
        acc[a][cs[i][j] - 1] += 1

ret = float('inf')
for i in range(c):
    for j in range(c):
        if i == j:
            continue
        for k in range(c):
            if i == k or j == k:
                continue
            cur = 0
            for l in range(c):
                cur += ds[l][i] * acc[0][l]
                cur += ds[l][j] * acc[1][l]
                cur += ds[l][k] * acc[2][l]
            ret = min(ret, cur)

print(ret)

Measured memory_bytes: 45020
import sys
import math
input = sys.stdin.readline

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

mod = 10**9 + 7

x, y = map(int, input().split())

x_ = max(x, y)
y = min(x, y)
x = x_

cnt_x = 0
while 2*x > y and x > 0 and y>0:
    x -= 2
    y -= 1
    cnt_x += 1

if x==-1:
    x += 2
    y += 1

if 2*x == y:
    cnt_y = x

    n = cnt_x + cnt_y 
    k = cnt_y
    print(comb(n, k, mod))

else:
    print(0) 

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

int main(void){
    int a,b,c,d,e;
  	cin >> a >> b;
    c = a + b;
    d = a - b;
    e = a * b;
    if(c >= d && c >= e){
    	cout << c << endl;
    }else if(d >= e){
    	cout << d << endl;
    }else{
    	cout << e << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
     ll k;cin >> k;
     ll pre = 0;bool ok = 1;
     for(int i = 0;i<=1e6+10;i++){
        pre = (modpow(10,i,k)*7+pre)%k;
        if(pre==0){
            cout << i+1;ok = 0;break;
        }
     }
     if(ok) cout << -1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 3632
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
A, B, C, K = M()
ans = 0
if A < K:
    ans += A
    K -= A
    if B < K:
        K -= B
        ans -= K
else:
    ans = K
print(ans)

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

#define MAX_N 200000
int a[MAX_N+1];
int cnt[MAX_N+1];
int N;

void solve() {
  for(int i=N; i>0; i--) {
    int c=0;
    for(int j=2*i; j<=N; j+=i) {
      if(cnt[j]==1) {
        c++;
      }
    }
    cnt[i] = (c + a[i])%2;
  }
  int c=0;
  for(int i=1; i<=N; i++) {
    c+=cnt[i];
  }
  printf("%d\n", c);
  bool flag=false;
  for(int i=1; i<=N; i++) {
    if(cnt[i]==1) {
      printf("%d ", i);
      flag=true;
    }
  }
  if(flag) printf("\n");
}

int main() {
  cin >> N;
  for(int i=1; i<=N; i++) {
    scanf("%d", &a[i]);
  }
  for(int i=1; i<=N; i++) {
    cnt[i] = 0;
  }
  solve();
  return 0;
}



Measured memory_bytes: 2432
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

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

city = []
for i in range(M):
    p,y = map(int, input().split())
    city.append([i,p,y,0])

city = sorted(city, key=lambda x:(x[1],x[2]))

city[0][3] = 1
no = 2
for i in range(1,M):
    if city[i][1] != city[i-1][1]:
        no = 1
    city[i][3] = no
    no += 1

city = sorted(city, key=lambda x:x[0])

for c in city:
    print('{0:06d}{1:06d}'.format(c[1],c[3]))

Measured memory_bytes: 43292
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
ll dp[3333][3333];
signed main() {
	string s, t, ans;
	cin >> s >> t;
	ll n = s.size();
	ll m = t.size();
	rep(i, n) {
		rep(j, m) {
			if (s[i] == t[j])dp[i + 1][j + 1] = dp[i][j] + 1;
			else dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
		}
	}
	for (int i = n, j = m; i > 0 && j > 0;) {
		if (dp[i][j] == dp[i - 1][j])i--;
		else if (dp[i][j] == dp[i][j - 1])j--;
		else {
			i--; j--;
			ans = s[i] + ans;
		}
	}
	cout << ans << endl;
	ggr
}



Measured memory_bytes: 80128
#include<iostream>

#include<string>
#include <algorithm> 
using namespace std;

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

    string s = "Impossible";
    if(a%3==0)          s="Possible";
    else if(b%3==0)     s="Possible";
    else if((a+b)%3==0) s="Possible";
    cout << s << endl; 
}

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

using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

const int N = 300;

int n, k;
char S[N + 5];
int dp[N + 5][N + 5][N + 5];

int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    scanf("%s", S + 1);
    read(k), n = strlen(S + 1);

    if(n == 1) return !puts("1");

    for (int i = 1; i <= n; ++ i) dp[i][i][0] = 1, dp[i][i+1][S[i] != S[i+1]] = 2;
    for (int l = 2; l <= n; ++ l) {
        for (int i = 1; i + l - 1 <= n; ++ i) {
            int j = i + l - 1;

            for (int t = 0; t <= k; ++ t) {
                chkmax(dp[i][j][t], dp[i+1][j][t]);
                chkmax(dp[i][j][t], dp[i][j-1][t]);

                if(i<j-1) 
                    chkmax(dp[i][j][t], dp[i+1][j-1][t] + (S[i] == S[j]) *2);
                if(t) 
                    chkmax(dp[i][j][t], dp[i+1][j-1][t-1] + 2);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i <= k; ++ i) {
        chkmax(ans, dp[1][n][i]);
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 110464
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), greater<type>())
#define SORTF(a, comp) sort(ALL(a), comp)
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) (lower_bound(ALL(a), (x)) - a.begin())
#define bisect_right(a, x) (upper_bound(ALL(a), (x)) - a.begin())
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUT2(a) REPx(&x, a) INPUT(x);
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define ENDL cout << endl;

const int INF = 2e9;
// const LL INF = 9e18;
const LL MOD = 1e9+7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
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;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k, s, x;
  cin >> n >> k >> s;
  x = s < 1e9 ? s+1 : 1;
  REP(int, i, n)
  {
    if (i < k) cout << s << " ";
    else cout << x << " ";
  }

  return 0;
}


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

int main() {
  // 入力は以下の形式で標準入力から与えられる.
  // N
  // A
  // Nは 1 以上 10000
  // Aは 0 以上 1000以下の整数
  int N, A;
  cin >> N >> A;
  
  // 1 円硬貨を A 枚と 500 円硬貨を無限枚持っています.
  // これらの硬貨だけを使うことによって, ちょうど N円を支払うことができるかを判定しなさい.
  int amari = (N + 500) % 500;
  string message;
  if(amari > A) message = "No";
  else          message = "Yes";
 
  cout << message << endl; 
}

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

int main() {
  int n,a,b;
  1<=n<=20;
  1<=a<=100;
  1<=b<=2000;
  cin >> n>>a>>b;

  if (n*a>=b) {
    cout <<b<< endl;
  }
  else {
    cout << n*a << endl;
  }
}


Measured memory_bytes: 256
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 3010;
const int SIZE3 = 330;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;

#define endl "\n" //インタラクティブでは消す
ut N, M, K, L, Q, D, H, W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL DP[101][SIZE];
LL DP2[101][SIZE];
bool finished[101][SIZE];
bool finished2[101][SIZE];
LL A[SIZE];
string s, t;
LL solve2(LL, LL);
LL sum(LL n, LL x) {
	if (x < 0) return 0;
	if (finished2[n][x]) return DP2[n][x];
	finished2[n][x] = true;
	return DP2[n][x] = (sum(n, x - 1) + solve2(n, x))%p;
}
LL sum(LL n, LL a, LL b) {
	return (sum(n, b) - sum(n, a - 1)+p)%p;
}
LL solve2(LL n,LL k) {
	if (k < 0) return 0;
	if (n==0) return k==0;
	if (finished[n][k]) return DP[n][k];
	finished[n][k] = true;
	DP[n][k] = sum(n - 1, k - A[n], k);
//	cout << n << " " << k << " " << DP[n][k] << endl;
	return DP[n][k]%p;
}
LL solve() {
	cin >> N >>K;
	EFOR(i,1, N) cin >> A[i];
	REP(i, N) REP(j, K) sum(i, j);
	cout << solve2(N,K) << endl;
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(12);
	solve();
	cin >> N;
	return 0;

}

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

int main(){
  long long N,P,j;
  cin >> N >> P;
  long long Q=P;
  long long A=1;
  if(N==1){cout << P << endl;}
  else if(N>=40){cout << 1 << endl;}
  else if(N==2){
    for(long long i=1000000;i>=2;i--){
      if(P%(i*i)==0){cout << i << endl; return 0;}
    }
    cout << 1 << endl; 
  }
  else{
    for(long long i=10000;i>=2;i--){
      P=Q;
      for(j=0;j<N;j++){
        if(P%i==0){P=P/i;}
        else{break;}
      }
      if(j==N){cout << i << endl; return 0;}
    }
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int ans = 0;
	for(int i=0;i<s1.length();i++)
	{
		string s = s1.substr(i,s2.length());
		if(s.length()==s2.length())
		{
	        int count = 0;
			for(int j=0;j<s.length();j++)
			{
				if(s[j]==s2[j])
				count++;
			}
			ans = max(ans,count);
		}
	}
	cout<<s2.length()-ans<<endl;
	 return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int n, mi=1999999999, sig=0;
	long long int su=0;
	vector<int> v;

	cin>> n;
	v.resize(n);

	for(int i=0;i<n;i++){
		cin>> v[i];
		if(v[i]<0) sig++;
		v[i]=abs(v[i]);
		mi=min(mi, v[i]);
		su+=v[i];
	}

	if(sig%2==1) su=su-2*mi;

	cout<< su << endl;

}

Measured memory_bytes: 640
n, m, d = map(int, input().split())

if d == 0 :
  print('{:.8f}'.format(max(0, (n - d)) * (m - 1) / (n * n)))
else :
  print('{:.8f}'.format(max(0, (n - d)) * 2 * (m - 1) / (n * n)))

Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;
vector<ll> a, b, c, d;
ll n, m, q;
ll ans  = 0;

void dfs(vector<ll> A) {
  if (ll(A.size()) == n+1) {
    ll sum = 0;
    rep(i, q) {
      if (A[b[i]] - A[a[i]] == c[i])
        sum += d[i];
    }
    chmax(ans, sum);
    return;
  }

  A.push_back(A.back());
  while(A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];

  dfs(vector<ll>(1, 1));

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3612
var a,count,c,i,j:integer;
begin 
  read(a);
  if a<105 then begin write('0'); exit; end;
  count:=0;
  for i:=105 to a do
  begin 
    c:=0;
    if i mod 2=1 then 
    begin 
      for j:=1 to trunc(sqrt(i)) do if i mod j=0 then c:=c+2;
    end;
    if c=8 then inc(count);
  end;
  write(count);
end.
  

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
	int n;
	bool f[50010];
	memset(f,true,sizeof(f));
	f[1]=false;f[0]=false;
	for(int i=2;i<300;i++){
		if(f[i]){
			for(int j=i*i;j<50001;j+=i)f[j]=false;
		}
	}
	while(cin>>n,n){
		int ans=0;
		for(int i=2;i<=n/2;i++){
			if(f[i]&&f[n-i])ans++;
		}
		cout<<ans<<endl;
	}
}

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

struct RURM {
	using t1 = int;
	using t2 = int;
	static t1 id1() { return INT_MAX; }
	static t2 id2() { return -1; }
	static t1 op1(const t1& l, const t1& r) { return min(l, r); }
	static t1 op2(const t1& l, const t2& r) { return r != id2() ? r : l; }
	static t2 op3(const t2& l, const t2& r) { return r != id2() ? r : l; }
};

template <typename M>
class LazySegmentTree {
	using T1 = typename M::t1;
	using T2 = typename M::t2;
	const int h, n;
	vector<T1> data;
	vector<T2> lazy;
	void push(int node) {
		if (lazy[node] == M::id2()) return;
		if (node < n) {
			lazy[node * 2] = M::op3(lazy[node * 2], lazy[node]);
			lazy[node * 2 + 1] = M::op3(lazy[node * 2 + 1], lazy[node]);
		}
		data[node] = M::op2(data[node], lazy[node]);
		lazy[node] = M::id2();
	}
	void update(int node) {
		data[node] = M::op1(M::op2(data[node * 2], lazy[node * 2]), M::op2(data[node * 2 + 1], lazy[node * 2 + 1]));
	}
public:
	LazySegmentTree(int n_)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2, M::id1()), lazy(n * 2, M::id2()) {}
	LazySegmentTree(int n_, T1 v1, T2 v2)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2, v1), lazy(n * 2, v2) {}
	LazySegmentTree(const vector<T1>& data_)
		: h(ceil(log2(data_.size()))), n(1 << h), data(n * 2, M::id1()), lazy(n * 2, M::id2()) {
		init(data_);
	}
	void init() {
		for (int i = n - 1; i >= 1; i--) data[i] = M::op1(data[i * 2], data[i * 2 + 1]);
	}
	void init(const vector<T1>& data_) {
		for (int i = 0; i < (int)data_.size(); i++) data[i + n] = data_[i];
		init();
	}
	void update(int l, int r, T2 val) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		int tl = l, tr = r;
		r++;
		while (l < r) {
			if (l & 1) lazy[l] = M::op3(lazy[l], val), l++;
			if (r & 1) r--, lazy[r] = M::op3(lazy[r], val);
			l >>= 1; r >>= 1;
		}
		while (tl >>= 1, tr >>= 1, tl) {
			if (lazy[tl] == M::id2()) update(tl);
			if (lazy[tr] == M::id2()) update(tr);
		}
	}
	T1 find(int l, int r) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		r++;
		T1 res1 = M::id1(), res2 = M::id1();
		while (l < r) {
			if (l & 1) res1 = M::op1(res1, M::op2(data[l], lazy[l])), l++;
			if (r & 1) r--, res2 = M::op1(M::op2(data[r], lazy[r]), res2);
			l >>= 1; r >>= 1;
		}
		return M::op1(res1, res2);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, com, x, y, val;
	cin >> n >> q;
	LazySegmentTree<RURM> st(n);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(x, y));
		}
		else {
			cin >> val;
			st.update(x, y, val);
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<ld> vld;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); ++i)
#define TS to_string
#define ALL(v) (v).begin(), (v).end()
#define endl "\n"

ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "YES" << endl;}
void no(){ cout << "NO" << endl;}

//-----------------------------------------
//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll n;
  cin >> n;
  vll p(n);
  REP(i,n) {cin >> p[i]; p[i]--;}

  vll tmp(n);
  REP(i,n){
    tmp[p[i]] = i;
  }

  ll ans = n;

  ll t = 0;
  for(ll i = 0; i < n; i++){
    if(i == n - 1){
      ans = min(ans, n - t - 1);
      break;
    }
    if(tmp[i] < tmp[i + 1]){
      t++;
    }
    else{
      ans = min(ans, n - t - 1);
      t = 0;
    }
  }

  cout << ans <<endl;



  return 0;
}



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

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

    std::string s;
    int cnt[n][26] = {0};
    for (int i = 0; i < n; ++i) {
        std::string s;
        std::cin >> s;

        for (size_t j = 0; j < s.size(); ++j) {
            const int c = s[j] - 'a';
            cnt[i][c] += 1;
        }
    }

    
    std::ostringstream oss;
    for (int i = 0; i < 26; ++i) {
        const char c = 'a' + i;
        int min = INT32_MAX;
        for (int j = 0; j < n; ++j) {
            min = std::min(min, cnt[j][i]);
        }

        for (int j = 0; j < min; ++j) {
            oss << c;
        }
    }

    std::cout << oss.str() << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int MAX_D = 60;
// dp[桁][未満フラグ]
ll dp[100][2];
int main() {
  int n;
  ll k;
  cin >> n >> k;
  vl A(n);
  rep(i, n) cin >> A[i];
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  rep(d, MAX_D) {
    ll mask = 1LL << (MAX_D - d - 1);
    int num = 0;
    rep(i, n) if (A[i] & mask) num++;

    ll score0 = mask * num;
    ll score1 = mask * (n - num);
    if (dp[d][1] != -1) maxs(dp[d + 1][1], dp[d][1] + max(score0, score1));
    if (dp[d][0] != -1) {
      if (k & mask) {
        maxs(dp[d + 1][0], dp[d][0] + score1);
        maxs(dp[d + 1][1], dp[d][0] + score0);
      } else {
        maxs(dp[d + 1][0], dp[d][0] + score0);
      }
    }
  }
  cout << max(dp[MAX_D][0], dp[MAX_D][1]) << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
	int s[3];
	while(~scanf("%d %d %d",&s[0],&s[1],&s[2]))
	{
		sort(s,s+3);
		printf("%d\n",s[0]+s[1]);
	}
	return 0;
}


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

using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	
	while(1){
		char s;
		cin >> s;
		if(s == '='){
			printf("%d\n",n);
			return 0;
		}else{
			int p;
			cin >> p;
			switch(s){
				case '+':
					n += p;
					break;
				case '-':
					n -= p;
					break;
				case '*':
					n *= p;
					break;
				case '/':
					n /= p;
					break;
			}
		}
	}
	return 0;
}		


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

char eval(int m, int f, int r){
    if(m == -1 || f == -1) return 'F';
    
    int sum = m + f;
    if(80 <= sum) return 'A';
    if(65 <= sum) return 'B';
    if(50 <= sum) return 'C';
    if(30 <= sum) return (50 <= r)? 'C': 'D';
    
    return 'F';
}

int main(){
    int m, f, r;
    while(true){
        cin >> m >> f >> r;
        if(m == -1 && f == -1 && r == -1)
            break;
        cout << eval(m, f, r) << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3088
N, A = map(int, input().split())  # N枚数のカード, 平均をAにしたい
X = tuple(map(int, input().split()))  # N枚のカードの中身

dp = [[[0]*(50*N+1) for _ in range(N+1)] for _ in range(N+1)]

dp[0][0][0] = 1  # 0枚の中から0枚選んで合計が0になる選び方が1通りある

for i in range(N):
    for j in range(N+1):
        for k in range(50*N+1):
            if dp[i][j][k]:  # そのパターン数が0になっている場所からの遷移はありえない！！！
                dp[i+1][j][k] += dp[i][j][k]
                dp[i+1][j+1][k+X[i]] += dp[i][j][k]
ans = 0
for i in range(1, N+1):
    ans += dp[N][i][i*A]
print(ans)


Measured memory_bytes: 62952
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
ll dp[51][51][2505];
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

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

    dp[0][0][0] = 1;
    rep(i, n) {
        rep(j, i + 1) {
            rep(k, 2505) {
                dp[i + 1][j][k] += dp[i][j][k];
                if (k + x[i] < 2505) dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
            }
        }
    }
    ll ans = 0;
    rep(i, n) ans += dp[n][i + 1][a * (i + 1)];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 29744
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String[] args) {
		int x;
		int number = 1;
		sc = new Scanner(System.in);
		while(sc.hasNext()) {
			while((x = sc.nextInt()) < 0 || 10000 < x);
			if(x == 0) {
				break;
			}
			System.out.println("Case "+ number +": "+ x);
			number++;
		}
	}
}



Measured memory_bytes: 43496
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input! {
        s: chars,
        t: chars,
    }

    let mut dp = vec![vec![0; t.len()+1]; s.len()+1];

    for i in 1..s.len()+1 {
        for j in 1..t.len()+1 {
            if s[i-1] == t[j-1] {
                dp[i][j] = dp[i-1][j-1] + 1;
            } else {
                dp[i][j] = cmp::max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    //println!("{}", dp[s.len()][t.len()]);

    //復元
    let mut ans = String::new();
    let mut i = s.len();
    let mut j = t.len();
    while i > 0 && j > 0 {
        if dp[i][j] == dp[i-1][j] {
            i = i - 1;
        } else if dp[i][j] == dp[i][j-1] {
            j = j - 1;
        } else  {
            ans.push(s[i-1]);
            i = i - 1;
            j = j - 1;
        } 
    }

    for a in ans.chars().rev() {
        print!("{}", a);
    }
    println!("");
}



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

int main(void){
  char b;
  cin >> b;
  switch(b){
  case 'A':
    cout << "T" << endl;
    break;
  case 'C':
    cout << "G" << endl;
    break;
  case 'G':
    cout << "C" << endl;
    break;
  case 'T':
    cout << "A" << endl;
    break;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

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

    int threes = 0, fours = 0, twos;
    for (int i = 0; i < n; i++) {
        if (a[i] % 2 == 1)
            threes++;
        else if (a[i] % 4 == 0)
            fours++;
    }
    twos = n - threes - fours;

    if (twos == 0) {
        cout << ((fours >= threes - 1) ? "Yes" : "No") << endl;
    } else {
        cout << ((fours >= threes) ? "Yes" : "No") << endl;
    }
    return 0;
}

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

#define PI 4*atan(1)
#define INF 1e8

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

int W, H;

int ans = 0;

void bfs(int x, int y, vector<vector<int>> &M){
  M[x][y] = INF;
  ans++;

  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 4; j++){
      if(dx[i] == 0 || dy[j] == 0){
        int nx = x + dx[i], ny = y + dy[j];
        if(0 <= nx && nx < H && 0 <= ny && ny < W && M[nx][ny] == -1)bfs(nx, ny, M);
      }
    }
  }
  return;
}

int main(){
  while(cin >> W >> H, W||H){
    ans = 0;
    vector<string> S(H);
    vector<vector<int>> M(H, vector<int>(W, -1));
    for(int i = 0; i < H; i++){
      cin >> S[i];
    }
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(S[i][j] == '#')M[i][j] = INF;
      }
    }

    pair<int, int> start;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if(S[i][j] == '@'){
          start.first = i; start.second = j;
        }
      }
    }
    bfs(start.first, start.second, M);
    cout << ans << endl;
  }
}

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

using namespace std;
string s,t,ans;
int a[3009][30009];
int x;
int main()
{
    cin>>s>>t;
if(s.size()>t.size())
    swap(s,t);
 for(int i=0;i<=s.size();i++ )
 {
    a[i][0]=0;
 }
for(int i=0;i<=t.size();i++ )
 {
     a[0][i]=0;
 }
 for(int i=1;i<=s.size();i++)
    for(int j=1;j<=t.size();j++)
 {
    if(s[i-1]!=t[j-1])
        a[i][j]=max(a[i-1][j],a[i][j-1]);
    else
        a[i][j]=a[i-1][j-1]+1;
 }
x=a[s.size()][t.size()];
if(x==0)
{
    cout<<"";
    exit(0);
}
int y=x;
int i=s.size(),j=t.size();
while(x>0)
{
    if(a[i][j]> a[i][j-1] && a[i][j]>a[i-1][j-1] &&s[i-1]==t[j-1])
    {
        ans+=s[i-1];
        i--;
        j--;
        x--;
    }
    else
    {
        if(a[i][j]==a[i-1][j])
            i--;
        else
            j--;
    }
}
string anss;
for(int i=ans.size()-1;i>=0;i--)
{
    anss+=ans[i];
}
cout<<anss;
    return 0;
}


Measured memory_bytes: 350720
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


void solve(long long N, std::vector<long long> h){
    ll dp[100010];
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);
    
    REP(i, 2, N) {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }

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

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> h(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&h[i]);
    }
    solve(N, std::move(h));
    // return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstring>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()
#define pb push_back

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

// 最小公約数
long lcm(long a, long b) {
	return a / gcd(a, b) * b;
}

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

	ll n;
	cin >> n;
	vector<ll> v(n);
	rep(i, n) cin >> v[i];

	// 奇数番目の文字で一番多い文字に合わせる 偶数番目も同じ
	typedef map<ll, ll> M; // map<key の型, valueの型>
	M oddNum;
	M evenNum;

	rep(i, n) {
		if (i % 2) {
			oddNum[v[i]]++;
		}
		else {
			evenNum[v[i]]++;
		}
	}

	ll oddMax = -1;
	ll odd = 0;
	ll evenMax = -1;
	ll even = 0;

	for (M::iterator iter = oddNum.begin(); iter != oddNum.end(); ++iter) {
		if (oddMax < iter->second) {
			oddMax = iter->second;
			odd = iter->first;
		}
	}

	for (M::iterator iter = evenNum.begin(); iter != evenNum.end(); ++iter) {
		if (evenMax < iter->second) {
			evenMax = iter->second;
			even = iter->first;
		}
	}

	if (odd == even) {
		ll _even = 0;
		ll _odd = 0;
		ll _evenMax = -1;
		ll _oddMax = -1;

		for (M::iterator iter = oddNum.begin(); iter != oddNum.end(); ++iter) {
			if (_oddMax < iter->second && iter->first != odd) {
				_oddMax = iter->second;
				_odd = iter->first;
			}
		}

		for (M::iterator iter = evenNum.begin(); iter != evenNum.end(); ++iter) {
			if (_evenMax < iter->second && iter->first != even) {
				_evenMax = iter->second;
				_even = iter->first;
			}
		}

		// 変えても影響力が少ない方を新しい統一する数値とする
		if (oddMax - _oddMax >= evenMax - _evenMax) {
			even = _even;
		}
		else {
			odd = _odd;
		}
	}

	ll ans = 0;

	//cout << odd << " " << even << endl;

	rep(i, n) {
		if (i % 2) {
			if (v[i] != odd) ans++;
		}
		else {
			if (v[i] != even) ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

void solve(){
	constexpr int MAXN = 1e6;

	int n;
	cin >> n;

	vector<int> arr(n);
	for(auto& i : arr) cin >> i;

	bool pairwise = true;

	vector<int> present(MAXN + 1, 0);
	for(auto i : arr) ++present[i];

	for(int i = 2; i <= MAXN; ++i){
		int cnt = 0;
		for(int j = i; j <= MAXN; j += i) cnt += present[j];
		if(cnt > 1) pairwise = false;
	}

	int g = 0;
	for(auto i : arr) g = gcd(g, i);

	if(pairwise) cout << "pairwise coprime\n";
	else if(g == 1) cout << "setwise coprime\n";
	else cout << "not coprime\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 11068
#include <bits/stdc++.h>
using namespace std;
const int N = 100000+5;
int main () {
    // L_i = gcd(A_1, A_2, A_3, ... A_i)
    // R_i = gcd(A_i, A_{i+1}, A_{i+1}, ..., A_n)
    int n;
    int A[N];
    int R[N];
    int L[N];

    cin >> n;
    for (int i=1; i<=n; i++) {
        cin >> A[i];
        L[i] = A[i];
        R[i] = A[i];
    }

    // precomputing L[i]
    for (int i=1; i<=n; i++) {
        L[i] = __gcd(L[i], L[i-1]);
    }
    // precomputing R[i]
    for (int i=n; i>0; i--) {
        R[i] = __gcd(R[i], R[i+1]);
    }

    // computing each m_i and the max value
    int res = 0;
    for (int i=1; i<=n; i++) {
        int m = __gcd(L[i-1], R[i+1]);
        if (m > res) {
            res = m;
        }
    }

    cout << res;
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,  int>;

const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

ll dp[100010][3][101];

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

    dp[0][0][0] = 1;
    for(int i = 0; i < n; i++) {
        int c = s[i] - '0';
        for (int j = 0; j < d; j++) {
            for (int ki = 0; ki < 10; ki++) {
                (dp[i + 1][1][(j+ki)%d] += dp[i][1][j])%=MOD;
            }
            for (int ki = 0; ki < c; ki++) {
                (dp[i + 1][1][(j+ki)%d] += dp[i][0][j])%=MOD;
            }
            (dp[i + 1][0][(j+c)%d] += dp[i][0][j])%=MOD;
        }
    }
    cout << (dp[n][1][0]+dp[n][0][0]-1+MOD)% MOD << endl;
    return 0;
}


Measured memory_bytes: 24832
def floor_sum(n,m,a,b):
    ans = 0
    if a >= m:
        ans += (n-1)*n*(a//m)//2
        a %= m
    if b >= m:
        ans += n*(b//m)
        b %= m
    y_max = (a*n+b)//m
    x_max = m*y_max-b
    if y_max == 0:
        return ans
    ans += (n-(x_max+a-1)//a)*y_max
    ans += floor_sum(y_max,a,m,(a-x_max%a)%a)    
    return ans

t = int(input())
for i in range(t):
    n,m,a,b = map(int,input().split())
    print(floor_sum(n,m,a,b))

Measured memory_bytes: 9236
#include <iostream>
using namespace std;
 
int main(){
    string s;
    string t;
    cin >> s;
    cin >> t;
    bool ok = false;
    if( s == t.erase(t.size()-1) ){
        ok = true;
    }
    if(ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 3632
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

pub trait CharToNum {
    fn to_i32(&self) -> i32;
    fn to_i64(&self) -> i64;
    fn to_u64(&self) -> u64;
    fn to_usize(&self) -> usize;
}

impl CharToNum for char {
    /// 1, 2, 3, ... の数字の文字型をもとにi32を返す
    fn to_i32(&self) -> i32 {
        *self as i32 - 48
    }

    /// 1, 2, 3, ... の数字の文字型をもとにi64を返す
    fn to_i64(&self) -> i64 {
        *self as i64 - 48
    }

    /// 1, 2, 3, ... の数字の文字型をもとにi64を返す
    fn to_u64(&self) -> u64 {
        *self as u64 - 48
    }

    /// 1, 2, 3, ... の数字の文字型をもとにusizeを返す
    fn to_usize(&self) -> usize {
        *self as usize - 48
    }
}

fn main() {
    let s = read!(String);
    let sc: Vec<char> = s.chars().collect::<Vec<char>>();
    let num = sc.iter().map(|&x| x.to_i32()).collect::<Vec<_>>();

    for i in 0..2usize.pow(3) {
        let mut ops = vec![];
        for j in 0..3 {
            if 1 << j & i != 0 {
                ops.push('+');
            } else {
                ops.push('-');
            }
        }
        let mut s = num[0];
        for k in 0..ops.len() {
            if ops[k] == '+' {
                s += num[k + 1];
            } else {
                s -= num[k + 1];
            }
        }
        if s == 7 {
            println!(
                "{}{}{}{}{}{}{}=7",
                num[0], ops[0], num[1], ops[1], num[2], ops[2], num[3]
            );
            return;
        }
    }
}


Measured memory_bytes: 4352