akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
using namespace std;
 
// Competetive Template:
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
// Debugging :
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ba  back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair 
#define mt make_tuple
#define fi first
#define se second
#define gcd __gcd
#define maxe *max_element
#define mine *min_element
#define deb debug
 
#define forz(i,n) for(long long int i=0;i<n;i++)
#define rep(i,k,n) for (lli i = k; i <= n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
 
typedef pair <lli,lli> pll;
 
 
lli countGreater(lli arr[], lli n, lli k) 
{ 
    lli l = 0; 
    lli r = n - 1; 
  
    // Stores the index of the left most element 
    // from the array which is greater than k 
    lli leftGreater = n; 
  
    // Finds number of elements greater than k 
    while (l <= r) { 
        lli m = l + (r - l) / 2; 
  
        // If mid element is greater than 
        // k update leftGreater and r 
        if (arr[m] > k) { 
            leftGreater = m; 
            r = m - 1; 
        } 
  
        // If mid element is less than 
        // or equal to k update l 
        else
            l = m + 1; 
    } 
  
    // Return the count of elements greater than k 
    return (n - leftGreater); 
}
 
bool is_palin(string input)
{
if (input == string(input.rbegin(), input.rend())) 
    return true;
return false;
}
void solve()
{
    lli n;cin>>n;
    forz(i,3)
    {
        lli d = n%10;
        if(d==7)
        {
            cout<<"Yes"<<endl;
            return;
        }
        n/=10;
    }
    cout<<"No"<<endl;
}
 
int main()
{
    kira; 
 
    solve();
    
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
int w,h;
int f[55][55];
int dx[8]={0,0,1,1,1,-1,-1,-1};
int dy[8]={1,-1,1,0,-1,1,-1,0};
void dfs(int x,int y)
{
	f[x][y]=0;
	for(int i=0;i<8;i++)
	{
		int nx=x+dx[i],ny=y+dy[i];
		if(f[nx][ny]==1)dfs(nx,ny);
	}
}
void print()
{
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cout << f[i][j] << ' ';
		}
		cout << endl;
	}
}
int main()
{
	while(1)
	{
		int ans=0;
		memset(f,0,sizeof(f));
		cin >> w >> h;
		if(w==0&&h==0)break;
		for(int i=1;i<=h;i++)
		{
			for(int j=1;j<=w;j++)
			{
				cin >> f[i][j];
			}
		}
		for(int i=1;i<=h;i++)
		{
			for(int j=1;j<=w;j++)
			{
				if(f[i][j]==1)
				{
					ans++;
					dfs(i,j);
					//print();
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

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

    int i, j, s;
    int A[100][100];
    int b[100];

	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
            cin >> A[i][j];
		}
	}

	for(j = 0; j < m; j++) cin >> b[j];

	for(i = 0; i < n; i++){
        s = 0;
		for(j = 0; j < m; j++){
            s = s + A[i][j] * b[j];
		}
        cout << s << endl;
	}

    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);
  }
  int s=0;
  for(int i=0;i<n;i++){
    s=s+a.at(i);
  }
  int cnt=0;
  for(int i=0;i<n;i++){
    if((s-1+4*m)/(4*m)<=a.at(i)){
      cnt++;
    }
  }
  if(cnt>=m){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,n,ans=0;
	cin>>n;
	int p[n];
    for(i=0;i<n;i++)
    	cin>>p[i];
    for(i=1;i<n-1;i++)
    {
    	if((p[i]>p[i+1]&&p[i]<p[i-1])||(p[i]<p[i+1]&&p[i]>p[i-1]))
    		ans++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
loop {
	n = gets.to_i
	break if n == 0
	a = gets.chomp.split
	if a.each_cons(2).any?{|c1, c2| c1 == ?x && c2 == ?x}
		puts 'none'
		next
	end
	max = Float::INFINITY
	min = -max
	
	a.each_cons(2).with_index{|(c1, c2), i|
		if c1 == ?x
			if i.even?
				max = c2.to_i-1 if c2.to_i <= max
			else
				min = c2.to_i+1 if c2.to_i >= min
			end
		elsif c2 == ?x
			if i.even?
				min = c1.to_i+1 if c1.to_i >= min
			else
				max = c1.to_i-1 if c1.to_i <= max
			end
		else
			if i.even? && c1.to_i >= c2.to_i
				max = 0
				min = 1
				break
			end
			if i.odd? && c1.to_i <= c2.to_i
				max = 0
				min = 1
				break
			end
		end
	}

	if min == max
		puts min
	elsif min < max
		puts 'ambiguous'
	else
		puts 'none'
	end

}

Measured memory_bytes: 8928
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define double long double
using namespace std;
const ll inf = 1000000000000000000;

const ll mod = 1000000007;
ll n, x, sum, ans;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    cin >> x;
    sum += x;
    for (ll i = 2; i <= n; ++i) {
        cin >> x;
        ans += ((sum * x) % mod);
        ans %= mod;
        sum += x;
        sum %= mod;
    }
    cout << ans;
    return 0;
}


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

const long long INF = 1LL << 60;
const int N_MAX = 3000;
int dp[N_MAX+1][N_MAX+1];

int main(){
  string s, t;
  cin >> s >> t;
  int sl = s.size(), tl = t.size();
  for(int i = 0; i <= sl; i++){
    for(int j = 0; j <= tl; j++){
      dp[i][j] = 0;
    }
  }
  
  for(int i = 1; i <= sl; i++){
    for(int j = 1; j <= tl; j++){
      if(s[i-1] == t[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
      else dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
    }
  }
  
  string ans = "";
  
  while(sl > 0 && tl > 0){
    if(dp[sl][tl] == dp[sl - 1][tl]) sl--;
    else if(dp[sl][tl] == dp[sl][tl - 1]) tl--;
    else {ans = s[sl-1] + ans; sl--; tl--;}
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 35456
#include <stdio.h>
int max(int x, int y) {
	return x > y ? x : y;
}
int main() {
	int n, h, w;
	scanf("%d%d%d", &h, &w, &n);
	printf("%d\n", (n + max(h, w) - 1) / max(h, w));
	return 0;
}

Measured memory_bytes: 128
a=list(input()); b=list(input()); c=list(input())
cur=a.pop(0)
while True:
    if cur == 'a':
        if len(a)==0:
            print('A')
            break
        cur=a.pop(0)
    elif cur == 'b':
        if len(b)==0:
            print('B')
            break
        cur=b.pop(0)
    else:
        if len(c)==0:
            print('C')
            break
        cur=c.pop(0)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

const int N = 100 + 10;
const int V = 200 + 10;
const int M = V * V * 2;
const long double INF = 1e5;

struct Edge
{
	long double w;
	int c, t;
	Edge *n, *r;
} edges[M], *totEdge, *firstEdge[V];

int n, m;
int x[N], y[N], z[N];

Edge* makeEdge(int s, int t, int c, long double w)
{
	Edge *e = totEdge ++;
	e->t = t; e->n = firstEdge[s]; firstEdge[s] = e;
	e->w = w; e->c = c;
	return e;
}

void addEdge(int s, int t, int c, long double w)
{
	Edge *st = makeEdge(s, t, c, w), *ts = makeEdge(t, s, 0, -w);
	st->r = ts; ts->r = st;
}

long double sqr(long double x)
{
	return x * x;
}

long double dis(int u, int v)
{
	return sqrt(sqr(x[u] - x[v]) + sqr(y[u] - y[v]) + sqr(z[u] - z[v]));
}

int spfa(int s, int t, int tot, long double &ret)
{
	static int in[V];
	static int aug[V];
	static long double dis[V];
	static Edge *prev[V];

	for(int i = 0; i < tot; ++ i) {
		in[i] = false;
		dis[i] = INF * INF;
	}

	queue<int> que;
	que.push(s);
	in[s] = true;
	dis[s] = 0;
	aug[s] = tot;
	aug[t] = 0;

	for( ; que.size(); ) {
		int u = que.front(); que.pop();
		for(Edge *e = firstEdge[u]; e; e = e->n) {
			if (e->c == 0) continue;
			int v = e->t;
			if (dis[v] > dis[u] + e->w) {
				dis[v] = dis[u] + e->w;
				aug[v] = min(aug[u], e->c);
				prev[v] = e;
				if (! in[v]) {
					in[v] = true;
					que.push(v);
				}
			}
		}
		in[u] = false;
	}

	if (aug[t] == 0)
		return false;
	ret += dis[t] * aug[t];
	int by = aug[t];

	for(int u = t; u != s; ) {
		prev[u]->c -= by;
		prev[u]->r->c += by;
		u = prev[u]->r->t;
	}
	return true;
}

long double costFlow(int s, int t, int tot)
{
	long double ret = 0;
	for( ; spfa(s, t, tot, ret); );
	return ret;
}

void solve()
{
	totEdge = edges;
	for(int i = 0; i < n; ++ i) {
		cin >> x[i] >> y[i] >> z[i];
	}
	int s = n + n;
	int t = s + 2;
	for(int i = 0; i <= t; ++ i) {
		firstEdge[i] = 0;
	}
	addEdge(s, s + 1, m, 0);
	for(int i = 0; i < n; ++ i) {
		addEdge(s + 1, i, 1, 0);
		addEdge(i, i + n, 1, -INF);
		addEdge(i + n, t, 1, 0);
		for(int j = 0; j < n; ++ j) {
			if (z[j] < z[i]) {
				addEdge(i + n, j, 1, dis(i, j));
			}
		}
	}

	long double ret = costFlow(s, t, n + n + 3) + n * INF;
	if (ret >= INF) {
		cout << -1 << endl;
	} else {
		printf("%.16f\n", (double)ret);
	}
}

int main()
{
	for( ; cin >> n >> m && (n || m); ) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n,k,m=0;
        cin>>n>>k;
        ll A[n];
       for(ll i=0;i<n;i++)
       {
           cin>>A[i];
       }
       sort(A,A+n);
       for(ll i=0;i<min(n,k);i++)
       {
           m=m+A[i];
       }
       cout<<m;
    }
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    vector<int>B(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    int ans = 0;
    for(int i = N-1; i >= 0; i--) {
        if((A[i]+ans)%B[i] != 0) {
            ans+=B[i]-(A[i]+ans)%B[i];
        }
    }
    cout << ans << endl;
}

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

struct Human{
  bool a,b,c;
  Human(){
    a = b = c = false;
  }
};

int main(){

    int n,x,y,z,tmp,count=0;

    cin >> n;

    Human hu[n+1];

    cin >> x;

    for(int i=0;i<x;i++){
      cin >> tmp;
      hu[tmp].a = true;
    }

    cin >> y;

    for(int i=0;i<y;i++){
      cin >> tmp;
      hu[tmp].b = true;
    }

    cin >> z;

    for(int i=0;i<z;i++){
      cin >> tmp;
      hu[tmp].c = true;
    }

    for(int i=1;i<n+1;i++){
      if( (hu[i].c && !hu[i].a) || (hu[i].c  && hu[i].b) ){
        count++;
      }
    }

    cout << count << endl;




    return 0;
}

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

const string YES = "Yes";
const string NO = "No";

int solve(long long N, long long A)
{

    for (int i = 0; i <= A; i++)
    {
        long long coin = 0;
        while (true)
        {

            if (1 * i + 500 * coin == N)
            {
                cout << "Yes" << endl;
                return 0;
            }
            else if (500 * coin > N)
            {
                break;
            }
            coin++;
        }
    }

    cout << "No" << endl;
    return 0;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long A;
    scanf("%lld", &A);
    solve(N, A);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

int main()
{
    int n; cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    vint c(9, 0);
    rep(i, n){
        int t = a[i] / 400;
        if(t<8) c[t]++;
        else c[8]++;
    }

    int ans = 0, z = 0;
    rep(i, 8) {
        if(c[i]>0) ans++;
        else z++;
    }
    int x, y;
    x = max(1, ans);
    y = ans + c[8];
    
    cout << x << " " << y << endl;
    return 0;}

Measured memory_bytes: 3564
#define _XOPEN_SOURCE 500
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n - 1); i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

double r;
void solve() {
    cin >> r;
    cout << 2 * r * M_PI << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

using namespace std;
typedef long long ll;
const int N = 200'010, M = 1e9 + 7;
vector<int> g[N];
int n, sz[N];
ll dp[N];

ll qpow(ll a, ll p) {
    ll res = 1;
    while (p) {
        if (p & 1) res = res * a % M;
        a = a * a % M, p >>= 1;
    }
    return res;
}

void dfs1(int v, int p = -1) {
    sz[v] = 1;
    for (auto to : g[v]) {
        if (to == p) continue;
        dfs1(to, v);
        sz[v] += sz[to];
    }
    dp[1] = dp[1] * sz[v] % M;
}

void dfs2(int v, int p = -1) {
    int tmp;
    for (auto to : g[v]) {
        if (to == p) continue;
        dp[to] = dp[v] * ((n - sz[to]) * qpow(sz[to], M - 2) % M) % M;
        dfs2(to, v);
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u].push_back(v), g[v].push_back(u);
    }
    dp[1] = 1;
    dfs1(1);
    dfs2(1);
    ll f = 1;
    for (int i = 1; i <= n; i++) f = f * i % M;
    for (int i = 1; i <= n; i++) printf("%lld\n", f * qpow(dp[i], M - 2) % M);
}


Measured memory_bytes: 16372
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s = Integer.toString(N);

		if(s.charAt(0) == s.charAt(2)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}



	}
}

Measured memory_bytes: 23380
n,k=map(int,input().split())
li=list(map(int,input().split()))
ans=[0]*n
ans[1]=abs(li[0]-li[1])
for i in range(2,n):
    ans[i]=min([y+z for (y,z) in zip(map(lambda x: abs(x-li[i]),li[max(0,i-k):i]),ans[max(0,i-k):i])])
    
print(ans[n-1])


Measured memory_bytes: 53600
#include <stdio.h>
#include <iostream>
#include <cmath>
#include<vector>
#include <ios>
#include <iomanip>
#include<algorithm>
using namespace std;

class civil {
public:
	int year;
	int x;
	int id;
	int pre;
};

int main() {
	int N, M;
	cin >> N >> M;
	vector<civil> c(M),tmp(M);
	vector<int>P(N, 1);
	for (int i = 0; i < M; i++) {
		cin >> c[i].pre >> c[i].year;
		c[i].id = i;
	}
	tmp = c;
	sort(tmp.begin(), tmp.end(), [](civil& x, civil& y) { return (x.year < y.year); });
	for (int i=0; i < M;i++) {
		c[tmp[i].id].x = P[tmp[i].pre - 1]++;
	}
	for (int i = 0; i < M; i++) {
		cout << setfill('0') << right << setw(6) << c[i].pre;
		cout << setfill('0') << right << setw(6) << c[i].x << endl;
	}
}

Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;

public class Main {

	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
	   
	    	int n=fs.nextInt();
	   if(n>=30)System.out.println("Yes");
	   else System.out.println("No");
	    	
	    }
	
	
	static void sort(int[] a ) {
		ArrayList<Integer> l = new ArrayList<>();
		for(int i:a) l.add(i);
		Collections.sort(l);
		for(int i=0;i<l.size();i++) a[i]=l.get(i);
	}
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				}catch(IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a = new int[n];
			for(int i=0;i<n;i++)a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 32684
import numpy as np
n = int(input())

s = [''] * n
time = [0] * n
for i in range(n):
    s[i], t = input().split()
    time[i:] = [j + int(t) for j in time[i:]]
x = input()
index = 0
while True:
    if s[index] == x:
        break
    index += 1
print(time[n-1]-time[index])


Measured memory_bytes: 12444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
   ll N, K;
   
   cin >> N >> K;
   COMinit();
   for(ll i = 1; i <= K; i++) {
       cout << COM(N - K + 1, i) * COM(K - 1, i - 1) % 1000000007 << endl;
      
   }

   
   


    return 0;
}

Measured memory_bytes: 15588
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        boolean[][] cards = new boolean[4][13];
        String[] card;
        int i, j;
        char c;
        for (i = 0; i < 4; i++) for (j = 0; j < 13; j++) cards[i][j] = false;
        for (i = 0; i < n; i++) {
            card = br.readLine().split(" ");
            if (card[0].equals("S")) {
                cards[0][Integer.parseInt(card[1]) - 1] = true;
            } else if (card[0].equals("H")) {
                cards[1][Integer.parseInt(card[1]) - 1] = true;
            } else if (card[0].equals("C")) {
                cards[2][Integer.parseInt(card[1]) - 1] = true;
            } else if (card[0].equals("D")) {
                cards[3][Integer.parseInt(card[1]) - 1] = true;
            }
        }
        for (i = 0; i < 4; i++) {
            for (j = 0; j < 13; j++) {
                if (!cards[i][j]) {
                    if (i == 0) c = 'S';
                    else if (i == 1) c = 'H';
                    else if (i == 2) c = 'C';
                    else c = 'D';
                    System.out.println(c + " " + (j + 1));
                }
            }
        }
    }
}

Measured memory_bytes: 24348
require 'set'
s = gets.strip
targets = Set['A', 'C', 'G', 'T']

longest = 0
current = 0
s.split('').each do |s|
  if targets.include?(s)
    current += 1
  else
    longest = [longest, current].max
    current = 0
  end
end
puts [longest, current].max


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

#define dbg(a)	cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

int main(){
	int n;	cin >> n;
	string s;	cin >> s;
	ll r = count(s.begin(), s.end(), 'R');
	ll g = count(s.begin(), s.end(), 'G');
	ll b = count(s.begin(), s.end(), 'B');
	ll ans = r*g*b;
	for (int i = 0; i < n; ++i){
		for (int j = 1; i+2*j < n; ++j){
			if(s[i]!=s[i+j] and s[i]!=s[i+2*j] and s[i+j]!=s[i+2*j])	ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ULL unsigned long long
#define LL long long
#define Max 1000005
#define mem(a,b) memset(a,b,sizeof(a));
#define pb push_back
#define mp make_pair
#define input ios::sync_with_stdio(false);cin.tie(0);
#define debug printf("debug!!!\n");
const LL mod=1e9+7;
const ULL base=131;
const LL LL_MAX=9223372036854775807;
using namespace std;
int a[Max],b[Max];
int n;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]),b[i]=a[i];
    sort(a,a+n);
    int ans=0;
    for(int i=0;i<n;i++)
        if(a[i]!=b[i])
            ans++;
    if(ans<=2)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 2304
def main():
    N = input()
    D_list = list(map(int, input().split()))

    if D_list[0] != 0:
        ans = 0
    
    else:
        maxD = max(D_list)
        count_ele_Dlist = [0] * (maxD + 1)

        for i in D_list:
            count_ele_Dlist[i] = count_ele_Dlist[i] + 1

        if count_ele_Dlist[0] == 1:
            ans = 1
            for i in range(1, maxD + 1):
                ans = (ans * count_ele_Dlist[i - 1] ** count_ele_Dlist[i]) % 998244353
        else:
            ans = 0
        
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14396
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int n;
struct dish
{
    int a, b, c;
};
vector<dish> v;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    F0R(i, n)
    {
        dish x;
        cin >> x.a;
        v.pb(x);
    }
    F0R(i, n) 
    {
        F0R(j, n)
        {
            if(i + 1== v[j].a) cin >> v[j].b;
        }
    }
    F0R(i, n) 
    {
        F0R(j, n)
        {
            if(i + 1 == v[j].a) cin >> v[j].c;
        }
    }
    ll res = v[0].b;
    FOR(i, 1, n)
    {
        res += v[i].b + ((v[i].a - v[i - 1].a == 1) ? v[i - 1].c : 0); 
    }
    cout << res;
    // for(auto i : v) cout << i.a << " " << i.b << " " << i.c << "\n";
    return 0;
}

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

class Rolling_Hash{
private:
  ll n;
  static constexpr ll base1=1007,base2=2009;
  static constexpr ll mod1=(1e9+7),mod2=(1e9+9);
  vector<ll> hash1,hash2,mpow1,mpow2;
public:
  Rolling_Hash(const string& s){
    n=s.size();
    hash1.resize(n+1,0);
    hash2.resize(n+1,0);
    mpow1.resize(n+1,1);
    mpow2.resize(n+1,1);
    for(ll i=0;i<n;++i){
      hash1[i+1] = (hash1[i]*base1+s[i])%mod1;
      hash2[i+1] = (hash2[i]*base2+s[i])%mod2;
      mpow1[i+1] = (mpow1[i]*base1)%mod1;
      mpow2[i+1] = (mpow2[i]*base2)%mod2;
    }
  }
  auto get(ll l,ll r){
    ll lefval = hash1[r]-hash1[l]*mpow1[r-l]%mod1;
    ll rigval = hash2[r]-hash2[l]*mpow2[r-l]%mod2;
    if(lefval<0)lefval+=mod1;
    if(rigval<0)rigval+=mod2;
    return make_pair(lefval,rigval);
  }
  auto get_LCP(ll a,ll b){
    ll len = min( n-a+1,n-b+1 );
    ll low=0,high=len;
    while( high-low>1 ){
      ll mid=(high+low)/2;
      if(get(a,a+mid)!=get(b,b+mid))high=mid;
      else low=mid;
    }
    return low;
  }
};

main(){

  ll n;
  string s;
  cin>>n>>s;

  Rolling_Hash rh(s);
  ll ans=0;
  rep(i,n){
    for(ll j=i+1;j<n;++j){
      ll lcp=rh.get_LCP(i,j);
      ans=max(ans,min(lcp,j-i));
    }
  }
  cout<<(ans)<<endl;

}

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

typedef struct{
	double x;
	double y;
}point;

void printpoint(point p){
	printf("%.8f %.8f\n",p.x,p.y);
}

void koch(int d,point p1,point p2){
	point s,u,t;
	double th = M_PI / 3.0;
	if(d==0)return;
	s.x = (p2.x + 2.0 * p1.x)/3.0;
	s.y = (p2.y + 2.0 * p1.y)/3.0;
	t.x = (2.0 * p2.x + p1.x)/3.0;
	t.y = (2.0 * p2.y + p1.y)/3.0;
	u.x = (t.x-s.x)*cos(th) - (t.y-s.y)*sin(th) + s.x;
	u.y = (t.x-s.x)*sin(th) + (t.y-s.y)*cos(th) + s.y;
	koch(d-1,p1,s);
	printpoint(s);
	koch(d-1,s,u);
	printpoint(u);
	koch(d-1,u,t);
	printpoint(t);
	koch(d-1,t,p2);
}

int main(void){
	int n;
	point ml,mr;
	ml.x = 0.0;
	ml.y = 0.0;
	mr.x = 100.0;
	mr.y = 0.0;
	scanf("%d",&n);
	printpoint(ml);
	koch(n,ml,mr);
	printpoint(mr);
	return 0;
}


Measured memory_bytes: 2060
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static AtCoder.Program;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC133().SolveA(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }

    }
  class ABC133
    {
        public void SolveA(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            WriteLine(Min(n * a, b));
            ReadLine();

        }
  }
}

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

int main() {
  int n;
  cin>>n;
  long long a[n],b[n],c[n];
  for(int i=0;i<n;i++){
    long long k;
    cin>>k;
    a[i]=k;
  }
  b[0]=0;
  b[1]=max(a[0],a[1]);
  c[0]=a[0];
  c[1]=b[1];
  b[2]=max(b[1],a[2]);
  c[2]=a[0]+a[2];
  for(int i=3;i<n;i++){
    if(i%2==1){
      b[i]=max(a[i]+b[i-2],a[i-1]+c[i-3]);
      c[i]=b[i];
    }
    else {
      b[i]=max(max(c[i-2],a[i-1]+b[i-3]),a[i]+b[i-2]);
      c[i]=c[i-2]+a[i];
    }
  }
  cout<<b[n-1]<<endl;
}


Measured memory_bytes: 8320
# include <algorithm>
# include <cmath>
# include <iostream>
# include <map>
# include <queue>
# include <string>
# include <vector>

typedef long long ll;
using namespace std;

const ll mod = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    string s[n];
    for (int i = 0; i < n; i++) {
        string ss; cin >> ss;
        s[i] = ss;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int dx = i;
        bool valid = true;
        for (int y = 0; y < n; y++) {
            for (int x = 0; x < n; x++) {
                int newY = x - dx;
                int newX = y + dx;
                if (newX < 0) newX += n;
                else if (newX > n - 1) newX -= n;
                if (newY < 0) newY += n;
                else if (newY > n - 1) newY -= n;
                if (s[y][x] != s[newY][newX]) valid = false;
            }
        }
        if (valid) ans++;
    }
    cout << ans * n << endl;
    return 0;
}


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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    int total = -n;
    int a;

    for(int i=0; i<n; i++){
        cin >> a;
        total += a;
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
	
	
    public static void main(String[] args) {
    	FastScanner sc = new FastScanner();
    	
    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	int T = sc.nextInt();
    	
    	int num = (T/A) * B;
    	
    	System.out.println(num);
    	
    }
    
}

class FastScanner {
    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() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; 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 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();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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



int main(){
 int N,M;
 cin >> N >> M;
 vector<int>P(M);
 vector<string>S(M);
 int sum=0;
 vector<int>count(N+1);
 int ans1=0;
 for (int i = 0; i < M; i++){
    cin >> P[i] >> S[i];
 }
 vector<int>ans(N+1);
 for (int i = 0; i < M; i++){
    if (S[i]=="AC"){
        ans[P[i]]=1;
    }
    else if(S[i]=="WA" && ans[P[i]]==0){
        count[P[i]]+=1;
    }
    
 }

 for (int i = 0; i < N+1; i++){
    sum+=ans[i];
 }
 for (int i = 0; i < N+1; i++){
    if(ans[i]==1){
     ans1+=count[i];
    }
 }


 cout << sum << ' ' << ans1 << endl;
 
 
}

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

typedef long long lglg;
const lglg INF = 1LL << 60;

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

	int N,M; lglg L; cin >> N >> M >> L;
	lglg adj[N+1][N+1], newadj[N+1][N+1];
	for (int i=1; i<=N; ++i) {
		for (int j=1; j<=N; ++j) {
			if (i==j) adj[i][j] = newadj[i][j] = 0;
			else adj[i][j] = newadj[i][j] = INF;
		}
	}
	for (int i=0; i<M; ++i) {
		int a,b,c; cin >> a >> b >> c;
		adj[a][b] = adj[b][a] = c;
	}

	for (int k=1; k<=N; ++k)
		for (int i=1; i<=N; ++i)
			for (int j=1; j<=N; ++j)
				adj[i][j] = min(adj[i][j], adj[i][k]+adj[k][j]);

	for (int i=1; i<=N; ++i)
		for (int j=1; j<=N; ++j)
			if (i != j && adj[i][j] <= L) newadj[i][j] = 1;

	for (int k=1; k<=N; ++k)
		for (int i=1; i<=N; ++i)
			for (int j=1; j<=N; ++j)
				newadj[i][j] = min(newadj[i][j], newadj[i][k]+newadj[k][j]);
	
	int T; cin >> T;
	while (T--) {
		int s, t; cin >> s >> t;
		if (newadj[s][t] == INF) cout << "-1\n";
		else cout << newadj[s][t]-1 << '\n';
	}
}

Measured memory_bytes: 1920
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      String s = sc.next();

      Map<Integer, Integer> prefixCnt = new HashMap<>();
      prefixCnt.put(0, 1);
      int fac = 1; 
      int cur = 0;
      long res = 0;
      for(int i = s.length() - 1; i >= 0; i--) {
        cur = (cur + (s.charAt(i) - '0') * fac) % 2019;
        fac = (fac * 10) % 2019;
        if(prefixCnt.containsKey(cur)) {
          res += prefixCnt.get(cur);
          prefixCnt.put(cur, prefixCnt.get(cur) + 1);
        } else
          prefixCnt.put(cur, 1);
      }
      System.out.println(res);
  }
}

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

#define si(x) scanf("%d",&x)

using namespace std;

vector<vector<int> > child;
int dfs(int node){
    if(child[node].size()==0)return 0;
    vector<int> dist;
    for(int i=0;i<child[node].size();i++){
        dist.push_back(dfs(child[node][i]));
    }
    sort(dist.begin(),dist.end());
    int ans  = 0;
    for(int i=0;i<dist.size();i++){
        ans = max(ans,dist[i])+1;
    }
    return ans;
}

int main()
{
    int n;
    si(n);
    vector<int> parent(n+1);
    child.resize(n+1);
    for(int i=2;i<=n;i++){
        si(parent[i]);
        child[parent[i]].push_back(i);
    }
    cout << dfs(1);
    return 0;
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
#define MAXN 200009
#define MAXM 320
#define MOD 1000000007
#define INF 1000000009
#define FOR(x,n) for(int x=0; x<n; x++)
#define FOR1e(x,n) for(int x=1; x<=n; x++)
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

vector<int> sol;
int n, a, b;
vector<int> vec;

bool check() {
	int cresc = 1, decresc = 1;
	vector<int> cs, ds; cs.assign(n+1, 0); ds.assign(n+1, 0);
	for (int i = 0; i < n; i++) {
		cs[i] = 1; ds[i] = 1;
	
		for (int j = 0; j < i; j++) {
			if (vec[i] > vec[j]) cs[i] = max(cs[i], cs[j]+ 1);
			if (vec[i] < vec[j]) ds[i] = max(ds[i], ds[j]+ 1);
		}
		cresc = max(cresc, cs[i]);
		decresc = max(decresc, ds[i]);
	}
	if (cresc == a && decresc == b) return true;
	return false;
}
void init() {
	srand(time(NULL));
	int iter = 0;
	bool ok = false;

	while(iter++ < 100 && !ok) {
		vec.clear();
		FOR(x, n) vec.push_back(x+1);
		random_shuffle(vec.begin(), vec.end());
		ok = check();
	}

	if (ok)
		for (int i = 0; i < (int)vec.size(); i++) {
			if (i != 0) printf(" ");
			printf("%d", vec[i]);
		}
	else printf("-1");
	printf("\n");
}

int main() {
	cin >> n >> a >> b;
	//init();

	bool ok = false;
	
	for (int i = 0; i < b && !ok; i++) {
		int aux = b;
		b -= i;

		if (n-i >= b && (n-i-1)/b + 1 == a) {
			//printf("A-- %d %d %d",i, a, b);
			ok = true;
			int ind = 1, ul = n;

			for (int k = 1; k <= i; k++) {
				sol.push_back(ul--);
			}
			while (sol.size() < n) {
				vector<int> tmp; int sz = 0;
			
				while (ind <= ul && sz < b) {
					tmp.push_back(ind++); sz++;
				}
				reverse(tmp.begin(), tmp.end());
			
				for (int i = 0; i < (int) tmp.size(); i++) {
					sol.push_back(tmp[i]);
				}
			}
		}
		b = aux;
	}
	for (int i = 0; i < a && !ok; i++) {
		int aux = a;
		a -= i;
		if (n-i >= b && (n-i-1)/b + 1 == a) {
			//printf("B-- %d %d %d",i, a, b);
			
			ok = true;
			int ind = 1;
			for (int k = 1; k <= i; k++) {
				sol.push_back(ind++);
			}
			while (sol.size() < n) {
				vector<int> tmp; int sz = 0;
			
				while (ind <= n && sz < b) {
					tmp.push_back(ind++); sz++;
				}
				reverse(tmp.begin(), tmp.end());

				for (int i = 0; i < (int) tmp.size(); i++) {
					sol.push_back(tmp[i]);
				}
			}
		}
		a = aux;
	}

	if (!ok) { printf("-1\n"); return 0; }
	
	for (int i = 0; i < (int)sol.size(); i++) {
		if (i != 0) printf(" ");
		printf("%d", sol[i]);
	}
	printf("\n");
}

Measured memory_bytes: 4080
#include <bits/stdc++.h>
#define INF 1000000000000
using namespace std;

int n;
int stones[100001];
long long dp[100001];

long long solve(int i) {
    if (i==n) return 0;
    else if (i > n) return INF;
    int r1,r2;
    if (dp[i] < 0) dp[i] = min(solve(i+1)+fabs(stones[i+1]-stones[i]),solve(i+2)+fabs(stones[i+2]-stones[i]));
    return dp[i];
}

int main() {
    cin >> n;
    fill(dp,dp+n+1,-1);
    for (int i=1; i<=n; i++) {
        cin >> stones[i];
    }
    cout << solve(1) << endl;
    return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
#define  vi vector<long long int>
#define  set1 set<long long int>
#define  pb push_back
#define  map1 map<long long int,long long int>
#define  ll long long int
#define  mp make_pair
#define  inf 1e17
#define  minf INT_MIN
#define  setbits(x) __builtin_popcountll(x)
#define  pres(x,y) fixed<<setprecision(y)<<x
#define  pair1 pair<long long int,long long int>
#define  mk(arr,n,type) type *arr=new type[n];
#define  mod 1000000007
#define  pi  3.1415926535897932384626433832
#define  ins insert
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//find_by_order() --> returns an iterator to the k-th largest element (counting from zero)
//order_of_key()  --> the number of items in a set that are strictly smaller than our item.
#define  w(t) long long int t;t=1;while(t--)


void solve() {

	string a, b;
	cin >> a >> b;
	ll n, m;
	n = a.length(), m = b.length();

	ll dp[n + 1][m + 1];
	memset(dp, 0, sizeof(dp));


	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= m; j++) {
			if (a[i - 1] == b[j - 1]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else {
				ll mx = max(dp[i - 1][j], dp[i][j - 1]);
				dp[i][j] = mx;
			}
		}
	}

	ll i = n, j = m;
	string s;
	while (i > 0 && j > 0) {
		if (dp[i][j] > dp[i - 1][j] && dp[i][j] > dp[i][j - 1]) {
			s.pb(a[i - 1]);
			i--;
			j--;
		}
		else {
			if (dp[i - 1][j] > dp[i][j - 1]) {
				i--;
			}
			else {
				j--;
			}

		}
	}

	reverse(s.begin(), s.end());
	cout << s << "\n";



}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	w(t) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 73952
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int h,w;cin>>h>>w;
  REP(i,h){
    REP(j,w){
      cin>>a[i][j];
    }
  }
  vector<int> x,y,z,zz;
  REP(i,h){
    REP(j,w){
      if(j==w-1)continue;
      if(a[i][j]%2==1){
        // cout<<i+1<<" "<<j+1<<" "<<i+1<<" "<<j+2<<endl;
        x.push_back(i+1);
        y.push_back(j+1);
        z.push_back(i+1);
        zz.push_back(j+2);
        a[i][j+1]++;
      }
    }
  }
  REP(i,h){
    if(i==h-1)continue;
    if(a[i][w-1]%2==1){
      // cout<<i+1<<" "<<w<<" "<<i+2<<" "<<w<<endl;
      x.push_back(i+1);
      y.push_back(w);
      z.push_back(i+2);
      zz.push_back(w);
      a[i+1][w-1]++;
    }
  }
  P(x.size());
  REP(i, (int)x.size()){
    cout<<x[i]<<" "<<y[i]<<" "<<z[i]<<" "<<zz[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 5348
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] a = Input.ScanIntArray();
          
          Console.WriteLine((a[0]-1)*(a[1]-1));
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13396
#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(){
    string st;
    cin >> st;
    vector<int> alp(26);
    rep(i, 26) alp.at(i) = 0;
    int f = 0;
    rep(i, st.size()){
        if(st.at(i) == 'a') alp.at(0)++;
        if(st.at(i) == 'b') alp.at(1)++;
        if(st.at(i) == 'c') alp.at(2)++;
        if(st.at(i) == 'd') alp.at(3)++;
        if(st.at(i) == 'e') alp.at(4)++;
        if(st.at(i) == 'f') alp.at(5)++;
        if(st.at(i) == 'g') alp.at(6)++;
        if(st.at(i) == 'h') alp.at(7)++;
        if(st.at(i) == 'i') alp.at(8)++;
        if(st.at(i) == 'j') alp.at(9)++;
        if(st.at(i) == 'k') alp.at(10)++;
        if(st.at(i) == 'l') alp.at(11)++;
        if(st.at(i) == 'm') alp.at(12)++;
        if(st.at(i) == 'n') alp.at(13)++;
        if(st.at(i) == 'o') alp.at(14)++;
        if(st.at(i) == 'p') alp.at(15)++;
        if(st.at(i) == 'q') alp.at(16)++;
        if(st.at(i) == 'r') alp.at(17)++;
        if(st.at(i) == 's') alp.at(18)++;
        if(st.at(i) == 't') alp.at(19)++;
        if(st.at(i) == 'u') alp.at(20)++;
        if(st.at(i) == 'v') alp.at(21)++;
        if(st.at(i) == 'w') alp.at(22)++;
        if(st.at(i) == 'x') alp.at(23)++;
        if(st.at(i) == 'y') alp.at(24)++;
        if(st.at(i) == 'z') alp.at(25)++;
    }
    rep(i, 26) if(alp.at(i)%2 != 0) f = 1;
    if(f == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())

li = list(map(int,input().split()))
b_li = [0]
accum_value = 0
for i in range(N):
    accum_value += li[i]
    b_li.append(accum_value)

mod_dict = dict()
# print(b_li)
for i in range(N+1):
    mod = b_li[i] % M
    if mod not in mod_dict.keys():
        mod_dict[mod] = 1
    else:
        mod_dict[mod] += 1
# print(mod_dict)

ans = 0
for i in mod_dict.keys():
    val = mod_dict[i]
    ans += val*(val-1)/2

print(int(ans))


Measured memory_bytes: 17240