akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\01.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};


struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} combination(1001001);


int gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    if (y == 0) {
        return x;
    }
    return gcd(y, x % y);
}

vector<P> factorize(ll n) {
    vector<P> res;

    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) {
            continue;
        }
        res.emplace_back(i, 0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }

    if (n != 1) res.emplace_back(n, 1);
    return res;

}

int main() {
    ll n, m;

    cin >> n >> m;

    vector<P> facts = factorize(m);
    mint ans = 1;

    for (auto f : facts) {
        mint now = combination(n + f.second - 1, n - 1);
        ans *= now;
    }

    cout << ans.x << endl;

}


Measured memory_bytes: 15872
import java.io.*;
import java.util.*;
import java.util.stream.*;

class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int c = saori.saori_hayami();
		int d = saori.saori_hayami();
		int i = 0;
		while(true){
			if(i % 2 == 0){
				c = c - b;
				if(c <= 0){
					System.out.println("Yes");
					return;
				}
			} else {
				a = a-d;
				if(a <= 0){
					System.out.println("No");
					return;
				}
			}
			i++;
		}
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 32428
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	int t, n;
	int s, f;
	while (1) {
		cin >> t;
		if (t == 0)break;
		cin >> n;
		int sum=0;
		for (int i = 0; i < n; i++) {
			cin >> s >> f;
			sum += f - s;
		}
		if (sum >= t)cout << "OK" << endl;
		else cout << t - sum << endl;
	}
	return 0;
}

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

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

int main() {
    long n, m;
    scanf("%ld %ld", &n, &m);
    char s[n + 1], t[m + 1];
    scanf("%s", s);
    scanf("%s", t);

    long n_gcd = gcd(n, m);
    long n_lcm = n * m / n_gcd;
    long interval = n_lcm / n_gcd;

    long s_int = n_lcm / n, t_int = n_lcm / m;
    for (long i = 0; i < n_lcm; i += interval) {
        if (s[i / s_int] != t[i / t_int]) {
            printf("-1\n");
            return 0;
        }
    }

    printf("%ld\n", n_lcm);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
//void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

int main(){fastio
    
    ll m,k;cin>>m>>k;
    string s;cin>>s;
    s[k-1]=(s[k-1]-'A'+'a');
    
    cout<<s<<endl;
    
    return 0;
    
    ll n;cin>>n;
    ll a[n],b[n];rep(i,0,n-1)cin>>a[i]>>b[i];
    ////////////////////////////////////
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<long long,long long> m;
long long a[100005],ans=1,mod=998244353;
long long qpow(long long a,long long b){
	long long res=1;
	while(b){
		if(b&1) res=res*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return res%mod;
}
int main(){
	long long n,num=0;
	cin>>n;
	for(long long i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]==0) num++;
		m[a[i]]++;
	}
	if(a[1]!=0||num>1){
		cout<<0<<endl;
		return 0;
	}
	for(auto x:m){
		if(x.first==0) continue;
		ans=ans%mod*qpow(m[x.first-1],x.second)%mod;
	}
	cout<<ans%mod<<endl;
}

Measured memory_bytes: 7296
import numpy as np
a,b,x=map(int,input().split())

V=a**2*b
if x==V:
    print('{:.10f}'.format(0))
elif x<=V/2:
    alpha=np.arctan(2*x/a/b**2)
    angle=90-alpha/np.pi*180
    print('{:.10f}'.format(angle))
else:
    angle=90-np.arctan(a**3/2/(a**2*b-x))/np.pi*180
    print('{:.10f}'.format(angle))

Measured memory_bytes: 14428
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > > 
#define pii pair<int,int> 
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define SZ(x) ((int)x.size())
using namespace std;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
const int BufferSize=1<<16;
char buffer[BufferSize],*Bufferhead,*Buffertail;
bool Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T>inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){rev|=c=='-';c=Getchar();if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	if(c=='.'){
		c=Getchar();double t=0.1;
		while(c>='0'&&c<='9') x=x+(c-'0')*t,c=Getchar(),t=t/10;
	}
	x=rev?-x:x;
	return 1;
}
template<class T1,class T2> inline bool read(T1 &x,T2 &y){return read(x)&read(y);}
template<class T1,class T2,class T3> inline bool read(T1 &x,T2 &y,T3 &z){return read(x)&read(y)&read(z);}
template<class T1,class T2,class T3,class T4> inline bool read(T1 &x,T2 &y,T3 &z,T4 &w){return read(x)&read(y)&read(z)&read(w);}
inline bool reads(char *x){
	char c=Getchar();
	while(c<33||c>126){c=Getchar();if(Terminal)return 0;}
	while(c>=33&&c<=126) (*x++)=c,c=Getchar();
	*x=0;return 1;
}
template<class T>inline void print(T x,const char c='\n'){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[20];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
//--------------------------------head---------------------------------------------

const int inf=0x3f3f3f3f;
const int N=200005,M=100005,mod=1e9+7;
template<class T,class S> inline void ch(T &x,const S y){x=(x+y)%mod;}
inline int exp(int x,int y,const int mod=::mod){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,dp[N],sum[26];
char str[N];
map<int,int> mn;

inline void ins(int x,int y){
	if(!mn.count(x)) mn[x]=y; else gmin(mn[x],y);
}
inline int calc(int x){
	if(!mn.count(x)) return inf;
	return mn[x];
}

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%s",str+1);n=strlen(str+1);
	ins(0,0);
	for(int i=1;i<=n;i++){
		int st=0;
		for(int j=0;j<26;j++){
			sum[j]+=(str[i]==j+'a');
			st|=(sum[j]&1)<<j;
		}
		dp[i]=calc(st)+1;
		for(int j=0;j<26;j++)
			if(sum[j]) gmin(dp[i],calc(st^(1<<j))+1);
		ins(st,dp[i]);
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
//const int MOD = (1000000007);
const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60) - 1;
const double EPS = (1 >> 30);

ll mod_pow(ll x, ll y)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
        {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        y >>= 1;
    }
    return res;
}

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

    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    int dame=0;
    if(d[0]!=0){
        dame++;
    }

    sort(all(d));
    vector<P> a(n);
    int c = 0;
    a[0]=make_pair(d[0],1);
    for (int i = 1; i < n; i++) // 距離ｘがそれぞれいくつあるか
    {
        if (d[i - 1] == d[i])
        {
            a[c].sc++;
        }
        else
        {
            c++;
            a[c].fs = d[i];
            a[c].sc++;
        }
    }
    c++;

    //int dame = 0;
    rep(i, c) //　距離がれんぞくになってないとだめ
    {
        if (a[i].fs != i)
        {
            dame++;
        }
    }

    ll ans = 1;
    Rep(i, 1, c) // 距離ｘは距離ｘ－１に繋ぐことになる
    {
        ans *= mod_pow(a[i - 1].sc, a[i].sc);
        ans %= MOD;
    }

    if (n == 1) // n==1の処理
    {
        if (d[0] == 0)
        {
            cout << 1 << endl;
        }
        else
        {
            cout << 0 << endl;
        }
    }
    else if (dame > 0) // 距離が飛んでいてつくれない
    {
        cout << 0 << endl;
    }
    else
    {
        if(d[1]!=1){ // 1は必ずいる
            cout<<0<<endl;
        }
        else{
            cout<<ans<<endl;
        }
    }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
double b[200010];	
int main() {
	long int n,k;
	cin>>n>>k;
	vector<long long int> a(n+1);
	for(int i=1;i<=n;i++) {
		cin>>a[i];
	}
	for(int i=1;i<=n;i++) {
		b[i] = b[i-1] + log10(a[i]); 
	}
	vector<double> ans(n+1);
	for(int i=k;i<=n;i++) {
		ans[i] = b[i]-b[i-k];
	}
	for(int i=k+1;i<=n;i++) {
		if(ans[i-1]+1e-10<ans[i]) cout<<"Yes\n";
		else cout<<"No\n";
	}
	
}



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

int k, n, s;
string a;

int C(int p, int q) {
	int i, re = 1;
	if (p < q || q < 0) return 0;
	for (i = p; i > p - q; i--) re *= i;
	for (i = q; i > 1; i--) re /= i;
	return re;
}

int pow(int p) {
	int re = 1;
	while (p > 0) re *= 9, p--;
	return re;
}

int main()
{
	int i;
	cin >> a >> k;
	n = a.size();
	for (i = 0; i < n && k >= 0; i++) {
		if (a[i] > '0') {
			s += C(n - i - 1, k) * pow(k) + (a[i] - '1') * C(n - i - 1, k - 1) * pow(k - 1);
			k--;
		}
	}
	if (k == 0) s++;
    cout << s << endl;
    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);
}

vector<vector<pair<int, int>>>edge;
vector<int>ans;
void dfs(int i = 0, int par = 0, int num = 1) {
	int cnt = 1;
	for (auto e : edge[i]) {
		if (e.first == par)continue;
		if (ans[e.second] != 0) {
			dfs(e.first, i, ans[e.second]);
			continue;
		}
		if (cnt == num)++cnt;
		ans[e.second] = cnt;
		++cnt;
		dfs(e.first, i, ans[e.second]);
	}
	return;
}
int main() {
	init();

	int N; cin >> N;
	edge.resize(N);
	ans.resize(N - 1, 0);
	rep(i, 0, N - 1) {
		int a, b; cin >> a >> b;
		--a; --b;
		edge[a].emplace_back(b,i);
		edge[b].emplace_back(a, i);
	}
	ans[edge[0][0].second] = 1;
	dfs();
	int mx = ans[max_element(all(ans)) - ans.begin()];
	cout << mx << "\n";
	rep(i, 0, ans.size())cout << ans[i] << "\n";
	

	return 0;
}

Measured memory_bytes: 8320
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define MAXN 20
int a[MAXN+5];
int ans;
int main()
{
    for(int i=1;i<=3;i++)scanf("%d",&a[i]);
    sort(a+1,a+3+1);
    ans=a[2]-a[1]+a[3]-a[2];
    printf("%d",ans);
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector<vector<int>> X(N, vector <int> (D, 0));
	for (int ii = 0; ii < N; ++ii){
		for (int jj = 0; jj < D; ++jj){
			cin >> X[ii][jj];
		}
	}

	int cnt = 0;
	const int MAX = 16010;
	for (int ii = 0; ii < N-1; ++ii){
		for (int jj = ii + 1; jj < N; ++jj){
			int dist = 0;
			for (int kk = 0; kk < D; ++kk){
				dist += (X[ii][kk] - X[jj][kk]) * (X[ii][kk] - X[jj][kk]);
			}

			for (int tmp = 0; tmp < MAX; ++tmp){
				if (tmp * tmp == dist){
					cnt++;
					break;
				} else if (tmp * tmp > dist) {
					break;	
				}
			}

		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=5e5;

  int n,A;
  char s[N],t[N];
int che()
{
  for (int i=0;++i<=A;)
    if (t[i]^s[n-A+i])
      return 0;
  return 1;
}

int main()
{
  cin>>n;
  scanf("%s%s",s+1,t+1);
  A=n;
  while (!che()&&A) --A;
  cout<<n+n-A;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int dp[105][4][2];

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

    dp[0][0][0] = 1;
    rep(i,n) rep(j,4) rep(k,2){
        int nd = s[i]-'0';
        rep(d,10){
            int ni = i+1, nj = j, nk = k;
            if(d != 0) nj++;
            if(nj > K) continue;
            if(k == 0){
                if(d>nd) continue;
                if(d<nd) nk = 1;
            }
            dp[ni][nj][nk] += dp[i][j][k];
        }
    }
    int ans = dp[n][K][0] + dp[n][K][1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Collections;
import java.util.Arrays;
import java.lang.Math;

public class Main {
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int N = reader.nextInt();
		// count MARCH heads
		long[] cnt = new long[5];
		for (int i=0; i<N; i++) {
		    String s = reader.next();
		    switch (s.charAt(0)) {
		        case 'M':
		            cnt[0]++;
		            break;
		        case 'A':
		            cnt[1]++;
		            break;
		        case 'R':
		            cnt[2]++;
		            break;
		        case 'C':
		            cnt[3]++;
		            break;
		        case 'H':
		            cnt[4]++;
		            break;
		        default:
		    }
		}

		long ans = 0;
		for(int i=0; i<5; i++) {
		    for(int j=i+1; j<5; j++) {
		        for(int k=j+1; k<5; k++) {
		            ans += cnt[i]*cnt[j]*cnt[k];
		        }
		    }
		}
		System.out.println(ans);
	}
	
	public static void solver() {
		// write logic
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 35272
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        List<Integer> A = new ArrayList<>();
        List<Integer> B = new ArrayList<>();
        int t = 0;
        while(true){
            A.add(sc.nextInt());
            B.add(sc.nextInt());
            if(A.get(A.size()-1) == 0) break;
            if(B.get(A.size()-1) == 0) break;
            t++;
        }
        for(int n=0;n<t;n++){
            for(int i=0; i < A.get(n); i++){
                for(int j=0; j < B.get(n); j++){
                    System.out.print("#");
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
        sc.close();
    }
}


Measured memory_bytes: 37688
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int n, w;
	cin >> n >> w;
	int dp[100001];
	for (int i = 0; i < 100001; i++) dp[i] = 0;
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		int v, w;
		cin >> v >> w;
		for (int j = 0; j+w < 100001; j++) {
			dp[j + w] = max(dp[j + w], dp[j]+v);
		}
	}
/*	for (int i = 0; i < 100001; i++) cout << dp[i] << " ";
	cout << endl;*/
	for (int i = 1; i < 100001; i++) dp[i] = max(dp[i], dp[i - 1]);
	cout << dp[w] << endl;
	return 0;
}

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

const int INF = 1e9+7;
int dp[4097];

int main() {
  int N,M,i,j,t;
  cin >> N >> M;
  vector<int> a(M), b(M);
  vector<vector<bool>> c(M, vector<bool>(N,0));

  for(i=0; i<M; i++) {
    cin >> a.at(i) >> b.at(i);
    for(j=0; j<b.at(i); j++) {
      cin >> t;
      c.at(i).at(t-1) = 1;
    }
  }

  for(i=0; i<(1<<N); i++)
    dp[i] = INF;
  dp[0] = 0;
  
  for(i=0; i<M; i++) {
    t = 0;
    for(j=0; j<N; j++)
      if(c.at(i).at(j))
        t |= (1 << j);
    for(j=0; j<(1<<N); j++)
      dp[j|t] = min(dp[j|t], dp[j]+a.at(i));
  }

  cout << ((dp[(1<<N)-1]==INF) ? -1 : dp[(1<<N)-1]);
}

Measured memory_bytes: 384
#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];
  }

  a.erase(unique(a.begin(), a.end()), a.end());

  int ans = 1;
  for(int i = 2; i < a.size(); i++){
    if((a[i-2] < a[i-1] and a[i-1] > a[i]) or
      (a[i-2] > a[i-1] and a[i-1] < a[i])){
      ans++; i++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		String c[]=new String[100];
		int h=stdIn.nextInt(),w=stdIn.nextInt(),i,j;
		for(i=0;i<h;i++) c[i]=stdIn.next();
		for(i=0;i<h;i++) for(j=0;j<2;j++) System.out.println(c[i]);
	}
}

Measured memory_bytes: 23980
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (long long int i = f; i < t; i++)
#define pr(i, f, t) for (long long int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    ll s, w;
    cin >> s >> w;
    if (s <= w)
        ce("unsafe");
    else
        ce("safe");
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// DON'T USE THESE MACROS DURING ICPC PRACTICE
#define For(i,n) for (int i=0; i<n; i++)
#define FOR(i,a,b) for (int i=a; i<=b; i++)
#define Down(i,n) for (int i=n-1; i>=0; i--)
#define DOWN(i,a,b) for (int i=b; i>=a; i--)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef complex<ld> pt;
typedef vector<pt> pol;
typedef vector<int> vi;

const char nl = '\n';
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9+7;
const ld EPS = 1e-10;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());



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

	int n;
	cin >> n;
	int a[n];
	For(i,n) {
		cin >> a[i];
	}

	ll dp[n][n][2];
	For(d,n) {
		For(i,n-d) {
			if (d == 0) {
				dp[i][i][0] = a[i];
				dp[i][i][1] = -a[i];
			} else {
				dp[i][i+d][0] = max(dp[i][i+d-1][1] + a[i+d], dp[i+1][i+d][1] + a[i]);
				dp[i][i+d][1] = min(dp[i][i+d-1][0] - a[i+d], dp[i+1][i+d][0] - a[i]);
			}
		}
	}
	cout << dp[0][n-1][0] << nl;

	return 0;
}


Measured memory_bytes: 140288
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Map<String, Integer> map = new HashMap<>();

        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            map.putIfAbsent(s, 0);
            map.put(s, map.get(s) + 1);
        }

        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            String s = sc.next();
            map.putIfAbsent(s, 0);
            map.put(s, map.get(s) - 1);
        }

        int max = 0;
        for (String s : map.keySet()) {
            if (map.get(s) > max) {
                max = map.get(s);
            }
        }

        System.out.println(max);
    }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
	int n;cin>>n;
	vector<int> v(n);
	rep(i,n) cin>>v[i];
	sort(all(v));
	cout << v[n/2] - v[n/2-1] << endl;
}

Measured memory_bytes: 640
a,b=map(int,input().split())
if b==100:
  s=a*1000+b
elif b>=10:
  s=a*100+b
else:
  s=a*10+b
j=1
temp=0
while j**2<=s:
  if j**2==s:
    print("Yes")
    temp=1
    break
  j=j+1
if temp==0:
  print("No")

Measured memory_bytes: 3064
H,W = map(int,input().split())
black_count = 0
board = []
got_start = False
ans = "Yes"
start_point = None
for h in range(H):
  row = tuple(input())
  if "#" in row:
    index = row.index("#")
    if got_start == False:
      start_point = (h,index)
      got_start = True
  board.append(row)

def check(y,x):
  if y >= H or y < 0 or x >= W or x < 0:
    return 0
  if board[y][x] == "#":
    return 1

for i in range(H):
  for j in range(W):
    y,x = i,j
    if board[i][j] == ".":
      continue
    is_adjacent = False
    if check(y + 1,x):
      is_adjacent = True
    if check(y - 1,x):
      is_adjacent = True
    if check(y, x + 1):
      is_adjacent = True
    if check(y,x - 1):
      is_adjacent = True
    if is_adjacent == False:
      ans = "No"
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
//#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,k;
string s;
vector<P> ans;
signed main(){
	cin>>n>>k;
	rep(i,n-1){
		ans.push_back(P(1,i+2));
	}//この時点で(n-2+1)(n-2)/2=(n-1)(n-2)/2個
	int nowcnt=(n-1)*(n-2)/2;
	if(nowcnt==k){
		cout<<ans.size()<<endl;
		for(auto x:ans){
			cout<<x.first<<" "<<x.second<<endl;
		}
		return 0;
	}
	for(int i=2;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			ans.push_back(P(i,j));
			nowcnt--;
			if(nowcnt==k){
				cout<<ans.size()<<endl;
				for(auto x:ans){
					cout<<x.first<<" "<<x.second<<endl;
				}
				return 0;
			}
		}
	}
	cout<<-1<<endl;
	
}

Measured memory_bytes: 384
function main(_stdin) {
    const stdin = _stdin.split(' ').map(Number);
    let max = Math.max.apply(null, stdin);
    let min = Math.min.apply(null, stdin);

    while (min !== 0) {
        let _min = min;
        min = max % min;
        max = _min;
    }
    console.log(max);
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));



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

typedef map<int,int>mpii;

#define fast ios_base::sync_with_stdio(0)

int main()
{
    fast;
    // let odd = b1, even not divisible by 4 = b2, divisible by 4 = b4
    int x, i , N , b4=0 , b2=0, b1=0;
    cin >> N;
    for(i=0; i<N; i++)
    {
        cin >> x;

        if(x % 4 == 0) b4++;
        else if(x % 2 == 0) b2+=1;
        else if(x % 2 != 0) b1+=1;
    }

    if(b2 == 0)
    {
        if(b1 <= b4+1) cout << "Yes\n";
        else cout << "No\n";
    }

    if(b2 > 0)
    {
        if(b1 <= b4) cout << "Yes\n";
        else cout << "No\n";
    }

    return 0;
}


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

int main(){
    int n,k; cin>>n>>k;
    vector<int> h(n),dp(100005,1e9);
    rep(i,n) cin>>h[i];
    dp[0] = 0;
    rep(i,n)rep(j,k){
            if(i-j>0){
                chmin(dp[i], dp[i-(j+1)]+abs(h[i]-h[i-(j+1)]));
            }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    ll n,ans = 0;
    cin >> n;
    vector<ll> a1(n + 1,0),a2(n + 1,0);
    rep1(i, n + 1){
        cin >> a1[i];
        a1[i] += a1[i - 1];
    }
    rep1(i, n + 1){
        cin >> a2[i];
        a2[i] += a2[i - 1];
    }
    rep1(i, n + 1)ans = max(ans, a1[i] + a2[n] - a2[i - 1]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int n = Integer.parseInt(br.readLine());

		for (int i = 1; i <= n; i++) {
			if (i % 3 == 0) {
				sb.append(" ").append(i);
				continue;
			}
			int tmp = i;
			do {
				if (tmp % 10 == 3) {
					sb.append(" ").append(i);
					break;
				}
				tmp /= 10;
			} while (tmp != 0);
		}
		System.out.println(sb);
	}
}

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

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()
{   
    int n,m; cin >> n >> m;
    vector<int> p(m);
    vector<string> s(m);
    for(int i=0;i<m;i++) cin >> p[i] >> s[i];
    set<int> ac;
    int wa=0;
    vector<int> w(n+1,0);
    for(int i=0;i<m;i++){
        if(ac.count(p[i])==1)continue;
        if(s[i]=="AC"){
            ac.insert(p[i]);
            wa += w[p[i]];
        }
        else{
            if(ac.count(p[i])==0)
                w[p[i]]++;
        }
    }

    cout << ac.size() << " " << wa << endl;
}
    

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  map<char,int>a;
  map<char,int>lp;
  set<char>st;
  
  for(int i=0;i<s.length();i++)
  {
    
    a[s[i]]=max((i-lp[s[i]]-1*(a[s[i]]!=0)),a[s[i]]);
    
    lp[s[i]]=i;
    st.insert(s[i]);
  }
  if(st.size()==1)
  {
    cout<<0<<endl;
    return 0;
  }
  //cout<<a['r']<<endl;
  
  int maxm=0;
  char maxc;
  int cur=100;
  vector<int>v(26);
  for(int i=s.length()-1;i>=0;i--)
  {
   	if(v[s[i]-'a'])continue;
    v[s[i]-'a']=1;
    int t=a[s[i]];
    if(a[s[i]]<(s.length()-i-1))t=s.length()-i-1;
    if(cur>t)cur=t;
  }
  cout<<cur<<endl;
  return 0;
}
    
    
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
vector<int64> a, p;
int64 f(int64 N, int64 X) {
	if (N == 0) {
		if (X <= 0) return 0;
		else return 1;
	} else if (X <= 1 + a[N - 1]) {
		return f(N - 1, X - 1);
	} else {
		return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1]);
	}
}
void solve() {
	int64 N, X; cin >> N >> X;
	a.push_back(1); p.push_back(1);
	for(int i = 0; i < 50; ++i) {
		a.push_back(2 * a[i] + 3);
		p.push_back(2 * p[i] + 1);
	}
	int64 ans = f(N, X);
	cout << ans << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 10000000;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;


/** Problem0130 : Train **/
int main()
{
	string s; int n;
	cin>>n;
	rep(k, n) {
		cin>>s;
		int d=0, i=1;
		string ans;
		bool ahead;
		string t;
		
		ans = s[0]; t = s[0];
		for (; i<s.size(); i++) {
			if (s[i]=='>') {
				ahead=true;
			} else if (s[i]=='<') {
				ahead=false;
				i++;
			} else if ('a'<= s[i] && s[i] <= 'z') {
				int pos = (int)ans.find(t, 0);
				if (string::npos == ans.find(s[i], 0)) {
					if (ahead) {
						ans.insert(pos+1, 1, s[i]);
					} else {
						ans.insert(pos, 1, s[i]);
					}
				}
				t=s[i];
			}
		}
		cout << ans << endl;
	}
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll a, b;
  cin >> a >> b;

  if (b % a) {
    cout << b - a << endl;
  } else {
    cout << a + b << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int n;
int main(){
while(1){
scanf("%d",&n);
if(!n) break;
int sum=0,mini=1000000,maxi=0;
for(int i=0;i<n;i++){
int g;
scanf("%d",&g);
sum+=g;
mini=mini>g?g:mini;
maxi=maxi<g?g:maxi;
}
printf("%d\n",(sum-maxi-mini)/(n-2));
}
return 0;
}

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

int main() {
  
  long long X, K, D;
  cin >> X >> K >> D;
  
  
  if(X<0){
    X = X*(-1);
  }
  
  if(K>10000000000 && D<10000){
    long long S=K*D;
    if(S<=X){
      cout << X-S << endl;
    }
    else{
      long long idou=0;
      long long count = 0;
  
     for(int i=0; i<K ;i++){
      idou = idou + D;
      if(idou>=X){
        count = i+1;
        break;
      }
     }
    
    if(count == 0){
    }
    else if(count%2==K%2){
      cout << idou-X << endl;
    }
    else{
      cout << X-idou+D << endl;
    }
   }
  }
  
  else{
  
  long long idou=0;
  long long count = 0;
  
  for(int i=0; i<K ;i++){
      idou = idou + D;
      if(idou>=X){
        count = i+1;
        break;
      }
    }
    
    if(count == 0){
      cout << X-idou << endl;
    }
    else if(count%2==K%2){
      cout << idou-X << endl;
    }
    else{
      cout << X-idou+D << endl;
    }
          
  }
}

Measured memory_bytes: 3600
import sys

def multiply(M, N, memo):
    for i in range(1, N):
        for s in range(N - i):
            l, r = s, s + i
            mincost = 1000000
            for j in range(l, r):
                mincost = min(mincost, memo[l][j] + memo[j + 1][r] + M[l][0] * M[j + 1][0] * M[r][1])
            memo[l][r] = mincost

lines = sys.stdin.readlines()
N = int(lines[0])
del lines[0]
memo = [[0 for i in range(N)] for j in range(N)]
M = []
for line in lines:
    M.append(map(int, line.split()))
multiply(M, N, memo)
print memo[0][N - 1]

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

//Coding below.
int main (){
    string s;
    cin >> s;
    int ans=0;
    for(int i=0;i< s.length()/2;i++){
        int a = 0; 
        if(s[i] != s[s.length()-i-1]){
            s[s.length()-i] = s[i];
            ans ++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
	int i;
	char s[13];
	char ss[14];
	scanf("%s", s);
	strcpy(ss,s);
	ss[4]=' ';
	strcpy(ss+5, s+4);
	ss[13]='\0';
	printf("%s\n", ss);
	return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <iostream>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
using namespace std;
using D = double;
using P = complex<D>;
using L = pair<P,P>;
using Poly = vector<P>;

const D EPS = 1e-8;

#define X real()
#define Y imag()

D dot(const P &A, const P &B){ return A.X*B.X + A.Y*B.Y; }
D cross(const P &A, const P &B){ return A.X*B.Y - A.Y*B.X; }

int ccw(P a, P b, P c){
  b -= a;c -= a;
  if(cross(b,c) > EPS) return +1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < -EPS) return 2;
  if(norm(b) < norm(c)-EPS) return -2;
  return 0;
}

D ps_dist(P a, L s){
  P sf = s.first, ss = s.second;
  if(dot(ss-sf,a-sf) >= 0 and dot(sf-ss,a-ss) >= 0)
    return abs(cross(sf-ss,a-ss))/abs(sf-ss);
  return min(abs(a-sf),abs(a-ss));
}


int in_poly(P a, const Poly &p){
  int n = p.size(), c = 0;
  for(int i = 0; i< n; ++i){
    P s = p[i] -a, t = p[(i+1)%n] - a;
    if(!ccw(s,t,P(0,0))) return 1;
    if(s.Y > t.Y+EPS) swap(s,t);
    if((s.Y*t.Y < 0 || (s.Y*t.Y < EPS && t.Y > EPS)) && cross(s,t) < EPS) ++c;
  }
  if (c%2) return 2;
  return 0;
}


int main(){
  int x, y;
  while(cin >> x >> y){
    if(x == 0 and y == 0) break;
    vector<P> V;
    V.emplace_back(x,y);
    for(int i =0 ; i < 2; ++i){
      cin >> x >> y;
      V.emplace_back(x,y);
    }
    cin >> x >> y;
    P c(x,y);
    D r;
    cin >> r;
    int a = 0, b = 0, e = 0;
    for(int i = 0; i < 3; ++i){
      if(abs(c-V[i]) < r + EPS) ++a;
      if(ps_dist(c,L(V[i],V[(i+1)%3])) < r + EPS) ++b;
      if(ps_dist(c,L(V[i],V[(i+1)%3])) < r - EPS) ++e;
    }
    if(a == 3){
      puts("b");
      continue;
    }
    int k = in_poly(c,V);
    if(!k){
      if(a > 0 or b > 0) puts("c");
      else puts("d");
      continue;
    }
    if(a > 0 or e > 0) puts("c");
    else puts("a");
  }
}



Measured memory_bytes: 3052
#include <bits/stdc++.h>
//??????URL http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2311&lang=jp

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

char board[8][8];

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

char memo[2] = {'o', 'x'};
//player 0:mami 1:magi
int dfs(int x, int y, int cnt, int idx, int player)
{
    int nx = x + dx[idx], ny = y + dy[idx];
    if (0 <= nx && nx <= 7 && 0 <= ny && ny <= 7 && board[nx][ny] == memo[1 - player])
    {
        cnt++;
        return dfs(nx, ny, cnt, idx, player);
    }
    else if (0 <= nx && nx <= 7 && 0 <= ny && ny <= 7 && board[nx][ny] == memo[player])
    {
        return cnt;
    }
    else if (0 <= nx && nx <= 7 && 0 <= ny && ny <= 7 && board[nx][ny] == '.')
    {
        return 0;
    }
    return 0;
}

int count(int x, int y, int player)
{
    int res = 0;
    for (int i = 0; i < 8; i++)
        res += dfs(x, y, 0, i, player);
    return res;
}

int solve(int player)
{
    int ma = -1, x, y;
    if (player == 1)
    {
        for (int i = 7; i >= 0; i--)
            for (int j = 7; j >= 0; j--)
            {
                if (board[i][j] == '.' && count(i, j, player) > ma)
                {
                    ma = count(i, j, player);
                    x = i;
                    y = j;
                }
            }
    }
    if (player == 0)
    {
        for (int i = 0; i < 8; i++)
            for (int j = 0; j < 8; j++)
            {
                if (board[i][j] == '.' && count(i, j, player) > ma)
                {
                    ma = count(i, j, player);
                    x = i;
                    y = j;
                }
            } //?????§?????????????????´???
    }
    if (ma < 1)
        return 0;
    board[x][y] = memo[player];
    for (int i = 0; i < 8; i++)
    {
        int tmp = dfs(x, y, 0, i, player);
        for (int j = 1; j <= tmp; j++)
        {
            board[x + dx[i] * j][y + dy[i] * j] = memo[player];
        }
    }
    return 1;
}

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

    for (int i = 0; i < 8; i++)
        for (int j = 0; j < 8; j++)
            cin >> board[i][j];
    bool mami_flag = true, magi_flag = true;
    while (mami_flag || magi_flag)
    {
        mami_flag = solve(0);
        magi_flag = solve(1);
    }
    for (int i = 0; i < 8; i++)
    {
        for (int j = 0; j < 8; j++)
        {
            cout << board[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  map<int, int> mp;
  rep(i, n) {
    int tmp;
    cin >> tmp;
    mp[tmp]++;
  }
  int ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    int key = itr->first, value = itr->second;
    if (key > value) ans += value;
    if (key < value) ans += (value - key);
  }
  cout << ans << endl;
  return 0;
}

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

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define sz(c) int(c.size())
#define clr(v, d)   memset(v, d, sizeof(v))
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF             INT64_MAX
#define NINF            INT64_MIN
#define ROW 1001
#define COL 1001

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<pll> vll;
typedef vector<ll> vl;

int main(void){
    ll A[100005];
    ll x[100005];
    int n;
    cin>>n;
    loop(i,n)
            cin>>A[i];
    range(i,0,n-2)
    {
        x[0]+=pow(-1,i+1)*A[i];
    }
    x[0]=(A[n-1]-x[0])/2;
    cout<<2*x[0]<<" ";
    range(i,1,n-1)
    {
        x[i]=A[i-1]-x[i-1];
        cout<<2*x[i]<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	bool flag=0;
 t.erase(t.begin()+t.size()-1);
 if(s==t){
 	cout<<"Yes";
 }
 else{
 	cout<<"No";
 }
}

Measured memory_bytes: 3628