akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define COUT(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SIZE(v); i++) {a = lcm(a, v[i]);} return a;}


void Main()
{
	ll n=0; string s="";
	ll res=0; string sres="Yes";
	cin>>n;
	cin>>s;

	REP(i,n){
		string t=s.substr(0,i);
		string u=s.substr(i,n-i);
		map<char,ll> mp;
		REP(j,SIZE(t)){
			if(mp.count(t[j])){}
			else mp[t[j]]=1;	//ｔを格納
		}
		ll tmp=0;
		SORT(u);
		REP(j,SIZE(u)){
			if(j!=0) {
				if (u[j] == u[j - 1]) continue;
			}
			if(mp.count(u[j])) tmp++;//tを格納したのでuと比較
		}
		res=max(res,tmp);
	}
	cout << res << "\n";
	return;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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(){
ll n,m;
cin >> n >> m;
vector<ll> a(n);
for (ll i = 0; i < n; i++) cin >> a[i];
priority_queue<ll, vector<ll>> pq;
for (ll i = 0; i < n;i++){
    pq.push(a[i]);
}
while(m--){
    ll t=pq.top();
    pq.pop();
    pq.push(t / 2);
}
ll ans = 0;
while(!pq.empty()){
	ans+=pq.top();
    pq.pop();
}
cout << ans << endl;
}

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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

int main(void){
    #ifdef ccsnoopy
        freopen("D:/Code/in.txt","r",stdin);
    #endif

    int n,x;
    ll arr[100010];
    sc(n);
    sc(x);
    ll total = 0;
    FOR(i,n){
    	cin >> arr[i];
    }

    for(int i = 1;i<n;i++){
    	ll t = arr[i-1] + arr[i];
    	if(t > x){
    		int get = min(arr[i], t - x);
    		total += get;
    		arr[i] -= get;
    		t = arr[i-1] + arr[i];
    		if(t > x){
    			get = min(arr[i-1], t - x);
    			total += get;
    			arr[i-1] -= get;
    		}
    	}
    }

    cout << total << endl;


    return 0;
}




Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
set<int>s;
int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	
	int n,input;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>input;
		s.insert(input);
	}
	if(s.size()==n)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 9600
//ROADTOBLUE
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <cstring>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


#define ull unsigned ll
// #define endl '\n'
#define mp make_pair
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define DO(x) for(int i = 1; i <= x; i++){ solve(i); }
#define form(i, n) for (size_t i = 0; i < size_t(n); ++i)
#define forn(i, n) for (size_t i = 1; i <= size_t(n); ++i)
#define M_PI 3.14159265358979323846
template<class T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long mod(long long a, long long b) { return (a%b+b)%b; }
long long gcd(long long x, long long y) { return __gcd(x, y); }
long long lcm(long long x, long long y) { return x * 1ll * y / gcd(x, y); }


const long long MAXN = 1e9;
const long long LMAXN = 5e18;
const int SIZE = 2e5 + 5;  //are u sure ?
const int MOD = 1e9 + 7;
int n, a[SIZE], used[1000100], res;

void solve(int CASE) {
	cin >> n;
	forn(i, n) cin >> a[i], used[a[i]]++;
	forn(i, n) {
		int temp = a[i];
		used[temp]--;
		bool ok = false;
		for(int div = 1; div * div <= temp; div++) {
			if(temp % div == 0) {
				int a = div;
				int b = temp / a;
				if(used[a] || used[b]) {
					ok = true;
					break;
				}
			}
		}
		if(ok == false) ++res;
		used[temp]++;
	}	cout << res << endl;
}


int main(){
	speedhack()
	// int IT; cin >> IT;
	int IT = 1;
	DO(IT);
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> AB(N);
    for(int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        AB[i] = make_pair(b, a);
    }
    sort(AB.begin(), AB.end());
    int now = 0;
    for(int i = 0; i < N; i++) {
        if(now + AB[i].second > AB[i].first) {
            cout << "No" << endl;
            return 0;
        }
        now += AB[i].second;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    for(;;){
        int r,c;
        scanf("%d%d",&r,&c);
        if(r==0&&c==0)break;
        vector<vector<bool> > sens(r,vector<bool>(c));
        int ins;
        for(int i=0;i<r;i++){
            for(int j=0;j<c;j++){
                scanf("%d",&ins);
                if(ins)sens[i][j]=false;
                else sens[i][j]=true;
            }
        }
        vector<vector<bool> > temp;
        int ma=0;
        for(int i=0;i<(1<<r);i++){
            temp=vector<vector<bool> >(sens);
            for(int j=0;j<r;j++){
                if(i&(1<<j)){
                    for(int k=0;k<c;k++)temp[j][k]=!temp[j][k];
                }
            }
            int sum=0;
            for(int j=0;j<c;j++){
                int whs=0;
                for(int k=0;k<r;k++)if(temp[k][j])whs++;
                sum+=max(whs,r-whs);
            }
            ma=max(ma,sum);
        }
        printf("%d\n",ma);
    }
}

Measured memory_bytes: 860
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

ll powmod(ll n, ll k) {
    ll r = 1, t = n % P;
    for (; k != 0; k /= 2) {
        if (k & 1) r = r * t % P;
        t = t * t % P;
    }
    return r;
}

ll inv(int n) {
    int m = P, y = 0, v = 1;
    while (1) {
        int q = m / n;
        int r = m % n;
        if (r == 0) return v < 0 ? v + P : v;
        y -= v * q;
        swap(y, v);
        m = n;
        n = r;
    }
}

int comb(int n, int k) {
    if (n < k || k < 0) return 0;
    ll t = 1;
    k = min(k, n - k);
    for (int i = 2; i <= k; i++) {
        t = (t * i) % P;
    }
    t = inv(t);
    for (int i = n - k + 1; i <= n; i++) {
        t = (t * i) % P;
    }
    return t;
}

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

    ll r = powmod(2, n);
    r -= 1;
    r -= comb(n, b);
    r -= comb(n, a);

    r %= P;
    if (r < 0) r += P;

    cout << r << endl;

    return 0;
}

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

int main(void) {
	int a, b, c, x; cin >> a >> b >> c >> x;
	int i, j, k, sum = 0;

	for (i = 0; i <= c; i++) {
		for (j = 0; j <= b; j++) {
			for (k = 0; k <= a; k++) {
				if (i * 50 + j * 100 + k * 500 == x) {
					sum += 1;
				}
			}
		}
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

int N;
int x[8], y[8];
int main(void){
    cin >> N;
    REP(i,N){
        cin >> x[i] >> y[i];
    }

    double res = 0;
    double a = 1;
    for(int i = 1;i <= N;i++) a*=i;

    REP(i,N) {
        REP(j,N){
            if(i==j) continue;
            res += sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j])) * (a/N);
        }
    }

    printf("%.10f\n", res/a);
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;
    int money = 100000; 

    cin >> n;
    while(n-- > 0){
        money *= 1.05;
        
        if(money % 1000 == 0) money += 0;
        if(money % 1000 != 0) money += (1000 - money % 1000);        
    }
    cout << money << endl;
}


Measured memory_bytes: 3036
/*g++ main.cpp -o main.out*/
/*./main.out*/
/*std::ios::sync_with_stdio(false);cin.tie(0);*/

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

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define ree(n,a) memset(n,a,sizeof(n));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

LL x[100005],y[100005];

int main()
{
    //std::ios::sync_with_stdio(false);
    int n,m;
    scanf("%d%d",&n,&m);
    rer(i,1,n)scanf("%lld",&x[i]);
    rer(i,1,m)scanf("%lld",&y[i]);
    LL a=0,b=0;
    rer(i,1,n)
    {
        a+=((2*i-1-n)*x[i])%Mod;
        a%=Mod;
    }
    rer(i,1,m)
    {
        b+=((2*i-1-m)*y[i])%Mod;
        b%=Mod;
    }
    printf("%lld\n",(a*b)%Mod);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
const ll MOD=1e9+7;
using namespace std;

int num[100005]={};
int main(){
  int N;
  cin >> N;
  rep(i,N){
    int a;
    cin >> a;
    num[a]++;
  }
  int sum=0;
  for(int i=0;i<=100000-2;i++){
    sum=max(sum,num[i]+num[i+1]+num[i+2]);
  }
  cout << sum << endl;
}

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

#define ll long long
#define pb push_back

using namespace std;
const int N = 2e5 + 5;
int a[N];


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n, k; cin >> n >> k;
    for(int i = 0; i < n; i++)cin >> a[i];
    sort(a, a + n);
    ll sum = 0;
    for(int i = 0; i < k; i++)sum += a[i];
    cout << sum << endl;
    return 0;
}




Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
#define min(a,b)	( (a) < (b) ? (a) : (b) )
#define max(a,b)	( (a) > (b) ? (a) : (b) )

char a[64],b[64];

int main(void){
	register int i,l1,l2;
	scanf("%s%s",a,b);
	l1=min(strlen(a),strlen(b)),l2=max(strlen(a),strlen(b));
	for(i=0;i<l1;i++)
		putchar(a[i]),putchar(b[i]);
	if(strlen(a)>strlen(b))
		for(i=l1;i<l2;i++)
			putchar(a[i]);
	else
		for(i=l1;i<l2;i++)
			putchar(b[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

#define INF 1<<29

using namespace std;

//全探索でよかった。模範解答パクリ

int main(void) {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 1; i < n; i++) {
		int cnt = 0;
		for (char c = 'a'; c <= 'z'; c++) {
			bool left = false, right = false;
			for (int j = 0; j < i; j++) {
				if (s[j] == c) {
					left = true;
				}
			}
			for (int j = i; j < n; j++) {
				if (s[j] == c) {
					right = true;
				}
			}
			if (left&&right) {
				cnt++;
			}

		}
		ans = max(ans, cnt);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define sz 10002
using namespace std;
int main()
{
    ll int n,m,k,test,i,j,res,x,y,z;

    cin>>n>>m>>k;
    x=n-k;
    if(x<0)
    {
        x=0;
        m=m-(k-n);
       if(m<0)m=0;
       cout<<x<<" "<<m<<endl;
    }
    else cout<<x<<" "<<m<<endl;
   
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd
readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]

def main():
    n, m = readIntN()
    res = set(readIntN()[1:])
    for i in range(n-1):
        res = res.intersection(set(readIntN()[1:]))
    print(len(res))

if __name__ == '__main__':
    main()


Measured memory_bytes: 5140
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
#include<sstream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
int dx[5] = {0, 1, 0, -1, 0}, dy[5] = {0, 0, 1, 0, -1};
int fld[10][10];

void Reverse(int x, int y, int cnt[10][10])
{
	for(int i = 0; i < 5; i++)
	{
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(0 <= nx && nx < 10 && 0 <= ny && ny < 10) cnt[ny][nx]++;
	}
}

int main(){
	int N;
	cin >> N;
	for(int c = 0; c < N; c++)
	{
		for(int i = 0; i < 10; i++)
		{
			for(int j = 0; j < 10; j++)
			{
				cin >> fld[i][j];
			}
		}

		bool ans = false;
		int out[10][10];
		for(int p = 0; p < (1 << 10); p++)
		{
			int cnt[10][10] = {};
			for(int i = 0; i < 10; i++)
			{
				out[0][i] = ((p >> i) & 1);
				if(out[0][i] == 1) Reverse(i, 0, cnt);
			}
			for(int i = 0; i < 9; i++)
			{
				for(int j = 0; j < 10; j++)
				{
					if(((fld[i][j] + cnt[i][j]) & 1) == 1)
					{
						out[i + 1][j] = 1;
						Reverse(j, i + 1, cnt);
					}
					else
					{
						out[i + 1][j] = 0;
					}
				}
			}

			ans = true;
			for(int i = 0; i < 10; i++)
			{
				if(((fld[9][i] + cnt[9][i]) & 1) == 1) ans = false;
			}
			if(ans) break;
		}

		for(int i = 0; i < 10; i++)
		{
			printf("%d", out[i][0]);
			for(int j = 1; j < 10; j++)
			{
				printf(" %d", out[i][j]);
			}
			puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 1148
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
using namespace __gnu_pbds;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> order_set;

const LL MOD = 998244353;
const int MAXN = 234567;
LL offs[MAXN * 2];
LL dp[MAXN];
int l[20], r[20];

LL sub(LL a, LL b) {
    return (a - b + MOD) % MOD;
}

LL add(LL a, LL b) {
    return (a + b) % MOD;
}

int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    for (int i = 0; i < K; i++)
        scanf("%d %d", &l[i], &r[i]);
    LL sum = 1;
    offs[2] = 998244352;
    for (int i = 1; i <= N; i++) {
        sum = add(sum, offs[i]);
        for (int j = 0; j < K; j++) {
            int x1 = l[j], x2 = r[j] + 1;
            offs[i + x1] = add(offs[i + x1], sum);
            offs[i + x2] = sub(offs[i + x2], sum);
        }
    }
    printf("%lld\n", sum);
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 6784
N = gets.to_i
p = Array.new
N.times do |i|
 p[i] = gets.to_i
end

max = 0
k = 0
for i in 0..(N-1)
 if max < p[i]
  max = p[i]
  k = i
 end
end

p.delete_at(k)
sum = 0
for i in 0..(N-2)
 sum = sum + p[i]
end

puts(sum+(max/2))

Measured memory_bytes: 1916
<?php
  list($a, $b, $c) = sscanf(fgets(STDIN), "%d %d %d");
  $magic = (int)fgets(STDIN);
  
  while($b <= $a && $magic > 0){
    $b = $b * 2;
    $magic--;
  }
  while($c <= $b && $magic > 0){
    $c = $c * 2;
    $magic--;
  }
  
  if($a < $b && $b < $c){
    printf("Yes");
  }
  else{
    printf("No");
  }
?>


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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end



int main(){
   int a,b,h,m; cin>>a>>b>>h>>m;
   double x=m*6.0,y=h*30.0+m*0.5;
   double d=min(abs(x-y),360-abs(x-y));
   double c=sqrt(a*a+b*b-2*a*b*cos(d*M_PI/180.0));
   printf("%.12f\n",c);
   return 0;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    if(s.size() % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    int x = s.size() / 2;
    rep(i, x) {
        if(s[i] != s[i + x]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3588
n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
check = [2]
ans = [0,0]
count = 0
for i in range(3,10**5+1):
    if i % 2 == 0:
        ans.append(count)
    else:
        a = True
        for j in check:
            if j > i**0.5+1:
                break
            if i % j == 0:
                a = False
                break
        if a:
            check.append(i)
            
            if (i+1)//2 in check:  
                count += 1
        ans.append(count)

for i,j in l:
    print(ans[j-1]-ans[max(0,i-2)])
                
    


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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10E9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)


typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;

             
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}

                                                           
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;  

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif

  int r; cin >> r;
  int g; cin >> g;
  int b; cin >> b;
  int n; cin >> n;
  int k = 0; 
  nestedforn(i , 0 , n + 1 , j , 0 , n + 1){
    int val = (n - (i * r + j * g)); 
    if(val >= 0 && val % b == 0) k++;
  }
  cout << k << endl;      

#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;

  int data[100010];
  for(int i = 0;i < n;i++){
    cin >> data[i];
  }

  bool ans[100010] = {};
  bool finish[100010] = {};
  for(int p = 0;p < n;p++){
    if(finish[p]) continue;
    bool used[100010] = {};
    int now = p;
    stack<int> dfs;
    while(!used[now] && !finish[now]){
      dfs.push(now);
      used[now] = true;
      now = (now + data[now]) % n;
    }
    bool ok = true;
    if(finish[now]){
      ok = false;
    }
    while(!dfs.empty()){
      int tmp = dfs.top();
      dfs.pop();
      ans[tmp] = ok;
      finish[tmp] = true;
      if(tmp == now) ok = false;
    }
  }
  int anss = 0;
  for(int i = 0;i < n;i++){
    if(ans[i]) anss++;
  }
  cout << anss << endl;
  return 0;
}


Measured memory_bytes: 4008
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int a, b;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b;
    if (a > b) swap(a, b);
    for (int i = 0; i < b; i++) {
        cout << a;
    }
    cout << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n;
    cin >> n;
    vector<int> cnt(n+1);
    for(int x=1;x<=200;x++){
        for(int y=1;y<=200;y++){
            for(int z=1;z<=200;z++){
                int res = x*x + y*y + z*z + z*y + z*x + y*x;
                if(res > n) continue;
                cnt[res] ++;
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout << cnt[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3576
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

def main():
    N = int(input())
    An = list(map(int, input().split(' ')))


    An = sorted(An)
    An = [gcd(a_n, An[0]) for a_n in An]
    print(min(An))

main()

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
  /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P
        
        IT ALWAYS SEEMS IMPOSSIBLE
        UNTIL ITS DONE ->WILLIAM LIN


        */

fast();
//ll t;cin>>t>>while(t--)
{
	 unsigned ll h,w;
	cin>>h>>w;
	if(h==1||w==1)
	{
		cout<<1<<endl;
	}
	else{
	unsigned ll x=ceil(double(h)/double(2.0));
	unsigned ll y=ceil(double(w)/double(2.0));
	if(w%2!=0)
	 {
	 	cout<<(x*y)+(h-x)*(y-1)<<endl;}
	else
	{
		cout<<(x*y)+(h-x)*(y)<<endl;
	}
}

    
}
return 0;
}

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

using namespace std;

using ll = long long;

int main(){
	int n;

	cin >> n;

	vector<int> w(n);
	for (size_t i = 0; i < n; ++i) {
		int tmp;
		cin >> tmp;
		w.at(i) = tmp;
	}
	
	int return_value;
	for (size_t t = 1; t < n; ++t) {
		int s1 = 0;
		int s2 = 0;

		for (size_t i = 0; i < t + 1; ++i) {
			s1 += w.at(i);
		}
		for (size_t j = t + 1; j < n; ++j) {
			s2 += w.at(j);
		}
		return_value = min(return_value, abs(s1 - s2));
	}

	cout << return_value << endl;
	
	return 0;
}

Measured memory_bytes: 256
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll a;
    string b;
    cin >> a >> b;
    b.erase(b.find('.'), 1);
    ll c = stoll(b);
    cout << (a * c) / 100;
}

Measured memory_bytes: 3664
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	N := nextInt()
	m := make([]int, N+1)
	var n, ANS int
	for i := 0; i <= N; i++ {
		n = nextInt()
		m[i] = n
	}
	for i := 0; i < N; i++ {
		n = nextInt()
		ANS += min(n, m[i])
		m[i] -= n
		if m[i] < 0 {
			n = -m[i]
		} else {
			n = 0
		}
		ANS += min(n, m[i+1])
		m[i+1] -= n
		if m[i+1] < 0 {
			m[i+1] = 0
		}
	}
	fmt.Println(ANS)
}

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 6148
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,1};
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 main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    vector<int> cnt(26,0);
    for(int i=0; i<S.size(); i++){
        cnt[S[i]-'a']++;
    }
    int odd = 0;
    for(int i=0; i<26; i++){
        if(cnt[i]%2) odd++;
    }
    cout << odd/2 << enld;
    return 0;
}


Measured memory_bytes: 3212
a,b = map(int,input().split())
if a % 2 ==0:
    if (b - a + 1) % 4 == 0:
        print(0)
    if (b - a + 1) % 4 == 1:
        print(b)
    if (b - a + 1) % 4 == 2:
        print(b ^ (b -1))
    if (b - a + 1) % 4 == 3:
        print(b ^ (b -1) ^ (b-2))
else :
    if (b - a + 1) % 4 == 0:
        print(a ^ b ^ (b -1) ^ (b-2))
    if (b - a + 1) % 4 == 1:
        print(a)
    if (b - a + 1) % 4 == 2:
        print(a ^ b)
    if (b - a + 1) % 4 == 3:
        print(a ^ b ^ (b -1))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;
const int MOD = 1'000'000'007;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

// const int MAX = 1010;

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<ll> cum(n + 1);
    for (int i = 0; i < n; i++)
    {
        cum[i + 1] = cum[i] + a[i];
    }
    map<ll, ll> mp;
    for (auto c : cum)
    {
        mp[c]++;
    }
    ll ans = 0;
    for (auto m : mp)
    {
        if (m.second >= 2)
        {
            ans += m.second * (m.second - 1) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int h, w;
    
    while(true){
        cin >> h >> w;
        if (h==0 && w==0) break;
        for (int i=1; i<=h; i++){
            for (int j=1; j<=w; j++){
                if (i==1 or i==h or j==1 or j==w) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3076
from itertools import combinations
N, K = map(int, input().split())
A = list(map(int, input().split()))
mn = 10**18
for B in combinations(range(1,N),K-1):
    mx = A[0]
    score = 0
    for n in range(1,N):
        if n in B:
            if A[n] <= mx:
                mx += 1
                score += (mx - A[n])
            else:
                mx = A[n]
        else:
            mx = max(mx, A[n])
    mn = min(mn, score)
print (mn)

Measured memory_bytes: 3064
#include<stdio.h>
 
int main(){
	int i,j;
	int ans;
	int n,a,b,c,x;
	int y[100];
 
	while(scanf("%d%d%d%d%d",&n,&a,&b,&c,&x),n){
		for(i = 0;i < n;i++){
			scanf("%d",&y[i]);
		}
if(n==1&&x==y[0]){printf("0\n");continue;}
		j = 0;
		
		if(y[j] == x)j++;

		for(i = 0;i < 10000;i++){
			x = (a * x + b) % c;
			if(x == y[j]){
				j++;
			}
			if(n == j)break;
		}
		if(i == 10000)i = -2;
		i++;
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 612
import java.util.*;

public class Main {
    static int n;
    static int[] aArr;
    static int[] bArr;
    static int[] cArr;
 	static int[][][] dp;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		int ma = sc.nextInt();
		int mb = sc.nextInt();
		aArr = new int[n + 1];
		bArr = new int[n + 1];
		cArr = new int[n + 1];
		int amax = 0;
		int bmax = 0;
		for (int i = 1; i <= n; i++) {
		    aArr[i] = sc.nextInt();
		    bArr[i] = sc.nextInt();
		    cArr[i] = sc.nextInt();
		    amax += aArr[i];
		    bmax += bArr[i];
		}
		dp = new int[n + 1][401][401];
		int min = Integer.MAX_VALUE;
		for (int i = 1; ma * i <= amax && mb * i <= bmax; i++) {
		    min = Math.min(min, dfw(n, ma * i, mb * i));
		}
		if (min >= Integer.MAX_VALUE / 2) {
		    System.out.println(-1);
		} else {
		    System.out.println(min);
		}
   }
   
   static int dfw(int idx, int ma, int mb) {
       if (idx == 0 && ma == 0 && mb == 0) {
           return 0;
       }
       if (idx == 0 || ma < 0 || mb < 0) {
           return Integer.MAX_VALUE / 2;
       }
       if (dp[idx][ma][mb] != 0) {
           return dp[idx][ma][mb];
       }
       return dp[idx][ma][mb] = Math.min(dfw(idx - 1, ma, mb), dfw(idx - 1, ma - aArr[idx], mb - bArr[idx]) + cArr[idx]);
   }
}




Measured memory_bytes: 53972
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    REP(i, s.size()) {
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
            cnt++;
            ans = max(ans, cnt);
        } else
            cnt = 0;
    }

    cout << ans << endl;

    return 0;
}

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

int gcd(int a, int b){return a%b?gcd(b,a%b):b;}

signed main(){
	
	int a,b,c,d,e, k;
	int n, m, ans=0, count=0,f;
	string str;
	
	
	cin>>n>>k;
	//if(n&&k)n /=gcd(n,k);
	//if(n&&k)k /= gcd(n,k);
	//ans = n/k;
	//ans = min(ans, abs(k-ans));
	
	
	if(n<k)cout<<1<<endl;
	else if(n%k==0)cout<<0<<endl;
	else cout<<1<<endl;
	
	//else cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
void solve();
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++)
	{	//cout<<"Case #"<<i<<": ";
		solve();

	}

	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
	return 0;
}
void solve()
{
	int n, x, t;
	cin >> n >> x >> t;
	// x in t min
	// n in how many minutes?
	cout << (int)(ceil((double)n / x)*t);
}



Measured memory_bytes: 3780
S = input()
prefix_MM = False
surfix_MM = False
MM = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]
if S[0:2] in MM:
    prefix_MM = True
if S[2:4] in MM:
    surfix_MM = True

if prefix_MM and surfix_MM:
    print("AMBIGUOUS")
elif prefix_MM:
    print("MMYY")
elif surfix_MM:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		for (int i = 0; i < a.length; i++) {
			if (a[i] % 2 == 0) {
				if (a[i] % 3 != 0 && a[i] % 5 != 0) {
					System.out.println("DENIED");
					return;
				}
			}
		}
		System.out.println("APPROVED");
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL);
#define endl '\n'
using namespace std;


int main(){

        int n=0;
        int a;
        int t=3;
        while(t--){
            cin>>a;
            n=n*10 + a;
        }

        if(n%4==0) cout<<"YES"<<endl;
        else cout<<"NO"<<endl; 

    return 0;
}


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

int main() {
  cout << setprecision(20);
  string s, t;
  cin >> s >> t;
  vector<ll> v[30];
  for (int i = 0; i < s.size(); ++i) {
    int index = s[i] - 'a';
    v[index].push_back(i+1);
  }
  ll ans = 0;
  ll prev = 0;
  for (int i = 0; i < t.size(); ++i) {
    int index = t[i] - 'a';
    if (v[index].size() == 0) {
      cout << -1 << endl;
      return 0;
    }
    auto it = upper_bound(v[index].begin(), v[index].end(), prev);
    if (it == v[index].end()) {
      ans += s.size() - prev + v[index][0];
      prev = v[index][0];
    } else {
      ans += *it - prev;
      prev = *it;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1724
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int n,i;
	cin>>n>>i;
	cout<<n-i+1<<endl;
}

Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const int N = 120;
char s[N][N];
int dp[N][N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      dp[i][j] = INF;
      if (i == 0 && j == 0) {
        dp[i][j] = s[i][j] == '#';
        continue;
      }
      if (i - 1 >= 0) {
        dp[i][j] = min(dp[i][j], dp[i - 1][j] + (s[i - 1][j] == '.' && s[i][j] == '#'));
      }
      if (j - 1 >= 0) {
        dp[i][j] = min(dp[i][j], dp[i][j - 1] + (s[i][j - 1] == '.' && s[i][j] == '#'));
      }
    }
  }
  printf("%d\n", dp[n - 1][m - 1]);
  return 0;
}


Measured memory_bytes: 384
ALP = ('a'..'z').to_a
INF = 0xffffffffffffffff
# mod = 998244353
# mod = 10 ** 9 + 9
mod = 10 ** 9 + 7
PI = Math::PI
dx = [ 1,  0, -1,  0,  1,  1, -1, -1]
dy = [ 0,  1,  0, -1,  1, -1,  1, -1]
eight = [0, 1, 1, 0, -1, -1, 1, -1, 0]
def max(a,b);       a > b ? a : b                              end
def min(a,b);       a < b ?  a : b                             end
def swap(a,b);      a, b = b, a                                end
def gi;             gets.to_i                                  end
def gf;             gets.to_f                                  end
def gs;             gets.chomp                                 end
def gai(n=nil); n.nil? ? gets.split.map(&:to_i) : n.times.map{ gets.to_i } end
def gaf(n=nil); n.nil? ? gets.split.map(&:to_f) : n.times.map{ gets.to_f } end
def gas(n=nil); n.nil? ? gets.split : n.times.map{ gets.chomp } end
def ga2i(h);        h.times.map{ gets.split.map(&:to_i) }      end
def yn(f); puts f ? "Yes" : "No" end
def YN(f); puts f ? "YES" : "NO" end
def yes(f=nil); f.nil? ? (puts "Yes"; exit) : (puts f ? "Yes" : "No") end
def no(f=nil); f.nil? ? (puts "No"; exit) : (puts f ? "Yes" : "No") end
def yay(f=nil); f.nil? ? (puts "Yay!"; exit) : (puts f ? "Yay!" : ":(") end

class Array
  def lcm; inject(:lcm) end
  def gcd; inject(:gcd) end
  def prod; inject(:*) end
  def abs; map{|k| k.abs } end
  def mod(m); map{|e|e%m} end
  def cumsum; s = 0; map{|k| s += k } end
  # frequency dist.
  def fd(n=nil); n = self.max if n.nil?; res = Array.new(n+1,0);self.map{|e| res[e]+=1 };res;end
  # cumlative frequency dist.
  def cfd(n=nil); fd.cumsum; end
  def diff; s = self[0]; self[1...(self.size)].map{|k|d=k-s; s=k; d} end
  # def sum; inject(:+) end
  # def append(k); push(k) end
  # def prepend(k); unshift(k) end
end

def an(n,d=0) Array.new(n,d)end
def an2(n,m,d=0) Array.new(n){an(m,d)}end
def an3(n,m,l,d=0) Array.new(n){an2(m,l,d)}end
def zeros(n); an2(n,n) end
def eye(n); an2(n,n).each_with_index{|e,i|e[i]=1} end # 単位行列 identity matrix

n, x, y = gai
x -= 1
y -= 1
# 最後のn辺目がなければ、j-iが長さとなる。数えられる。
# 

d = an2(n,n)

n.times do |j|
  j.times do |i|
    d[i][j] = j - i
  end
end
# p d

n.times do |j|
  j.times do |i|
      t = (x - i).abs + 1 + (j - y).abs
      d[i][j] = t if d[i][j] > t

  end
end

# p d
ans = an(n-1)

n.times do |j|
  j.times do |i|
    k = d[i][j]
    ans[k-1] += 1
  end
end

puts ans

Measured memory_bytes: 33148
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int r,g,b,n;
    int count=0;
    cin >> r >> g >> b >> n;
    for(int i=0; i*r<=3000; i++){
        for(int j=0; j*g<=3000; j++){
            if(i*r+j*g>n)break;
            if((n-i*r-j*g)%b==0){
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
N,K = map(int, input().split())
A = list(map(int, input().split()))

loc = 1
loclog=[1]
flag = 0
hist = [0]*N

for i in range(K):
    hist[loc-1] = 1
    loc = A[loc-1]
    if hist[loc-1] != 0:
        roopstart = loclog.index(loc)
        roopend = len(loclog)
        flag = 1
        break
    loclog.append(loc)

if flag == 0:
    ans = loc
else:
    roopidx = (K+1-roopstart)%(roopend-roopstart)
    if roopidx == 0:
        ans = loclog[roopend-1]
    else:
        ans = loclog[roopstart+roopidx-1]
print(ans)

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

int main(void){
    int input[3],num[2];
    int i,j,Max,iMax,iMin,cnt=0;
    scanf("%d",&input[0]);
    scanf("%d",&input[1]);
    scanf("%d",&input[2]);

        if(input[0]>input[1]){
            Max=input[0];
            iMax=0;
        }else{
            Max=input[1];
            iMax=1;
        }
        if(Max<input[2]){
            Max=input[2];
            iMax=2;
        }
        j=0;
        for(i=0;i<=2;i++){
            if(i!=iMax){
                num[j]=input[i];
                j++;
            }
        }
        if(num[0]%2==num[1]%2){
            printf("%d",abs(num[0]-num[1])/2+Max-(int)fmax((double)num[0],(double)num[1]));//最大以外の数の偶奇が一致
        }
        else{
            if(Max%2==num[0]%2){
                for(i=num[1];i<=Max;i=i+2){
                    num[1]=num[1]+2;
                    cnt+=1;
 
                }
                for(j=num[0];j<Max;j=j+2){
                    num[0]=num[0]+2;
                    cnt+=1;
                }
                printf("%d",cnt+num[1]-Max);
            }
            else{
                for(i=num[0];i<=Max;i=i+2){
                    num[0]=num[0]+2;
                    cnt+=1;
                }
                for(j=num[1];j<Max;j=j+2){
                    num[1]=num[1]+2;
                    cnt+=1;
                }
                printf("%d",cnt+num[0]-Max);
            }
        }
    return 0;
}

Measured memory_bytes: 128
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

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

#define io ios_base::sync_with_stdio(false)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<long long>
#define pb push_back
#define mod 100000007
#define pii pair<int, int>
#define PI 2*acos(0.0)

int main()
{
    io;
    int n;
    string s;
    cin>>n >>s;
    if(s.size() <= n)
        cout<< s;
    else
        cout<< s.substr(0, n) <<"...";
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FASTIO
#define endl "\n"  // Since endl forces a buffer flush which slows down large I/O operations.
#define ff first
#define ss second
#define pb push_back
#define input(c, n) for (int i = 0; i < n; ++i) cin >> c[i];
#define exit_message(s) return 0 * printf(s)
#define show_all(c) for (auto i: c) cout << i << " "; cout << "\n";
#define display(c, a, n) cout << "Displaying array \"" << #c << "\" : \n"; for (int (i) = (a); (i) < (n); ++(i)) cout << (c)[(i)] << " "; cout << "\n";
#define forl(i, a, n) for (int i = (a); (i) < (n); ++(i))
#define dugbe(k) cout << "-\t> " << #k << " = " << k << "\n";

// What follows is a magical ordered set data structure.
// Supports the following functions:
// find_by_order(int k) - returns k'th smallest element (0-indexed)
// order_of_key(int k) - returns number of elements strictly smaller than k.
using namespace __gnu_pbds;
#define ordered_set tree <ll, null_type, greater_equal <ll>, rb_tree_tag, tree_order_statistics_node_update>

/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/

using namespace std;
typedef long long ll;
typedef pair<int, int> pr;
typedef pair<ll, ll> prll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pr> vpr;
ifstream in("input.txt");
const ll mod = 1e9 + 7;
const long double eps = 1e-7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

long long true_rand(long long n)
{
	// Returns a random number between 0 and n - 1 inclusive using mt19937.
    uniform_int_distribution<long long> uid(0, n - 1);
    return uid(rng);
}

ll mod_pow(ll a, ll b)
{
	if (b == 0)
		return 1LL;

	ll res = mod_pow(a, b >> 1);
	res = (res * res) % mod;
	if (b & 1LL)
		res = (res * a) % mod;
	
	return res;
}

const int N = 3e5 + 5;

int32_t main()
{
	#ifdef FASTIO
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
	#endif
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	int a;
	string s;
	cin >> a >> s;
	if (a < 3200)
		cout << "red\n";
	else
		cout << s << "\n";

	return 0;
}

Measured memory_bytes: 256