akhauriyash/Code-Regression huggingface dataset:
#include<set>
#include<cstdio>
#include<queue>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
long long read(){
	long long f=1,x=0;
	char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();}
	return f*x;
}
int main(){
	long long  a=read(),b=read();
	if((a*b)%2==0)
		printf("Even\n");
	else
		printf("Odd\n");
	return 0;
}


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

using namespace std;
using ll=long long;

#define rep(i,n) for (int i = 0; i < (n); ++i)

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;cin>>n;
  ll ans=1ll,T;
  rep(i,n){
    cin>>T;
    ans=lcm(ans,T);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int max  =-1000000000;
		int min = 100000000;
		long sum = 0;
		
		int count = scan.nextInt();
		for(int i = 0;i<count;i++){

				int input = scan.nextInt();
//				int input = Integer.parseInt(args[i]);

				if(input > max){
					max = input;
				}
				if(input < min ){
					min = input;
				}
				sum = sum + input;
		}
		System.out.println(min+" "+max+" "+sum);

	}
}



Measured memory_bytes: 42364
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]

for a, b in ab:
    L = 10 ** 9
    p = 0
    i = 1
    for c, d in cd:
        l = abs(a - c) + abs(b - d)
        if l < L:
            L = l
            p = i
        i += 1
    print(p)


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

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

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

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

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

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

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  vl H(N);
  REP(i, N) cin >> H[i];
  ll m = llINF;
  bool ok = true;
  RREP(i, N) {
    if (H[i] <= m) {
      m = H[i];
    } else if (H[i] - 1 == m) {
      m = H[i] - 1;
    } else {
      ok = false;
      break;
    }
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 1024
N=int(input())
S=input()
re_list=[]
ele = list(map(str, S))
v_list=[]
vi_list=[]
flag = 0
count = 0
for i in range(1000):
    if i < 10:
        v_list.append("00"+str(i))
    elif i < 100:
        v_list.append("0" + str(i))
    else:
        v_list.append(str(i))

for i in range(1000):
    for j in range(N):
        if ele[j] == v_list[i][0] and flag == 0:
            flag = 1
            continue
        if ele[j] == v_list[i][1] and flag == 1:
            flag = 2
            continue
        if ele[j] == v_list[i][2] and flag == 2:
            count += 1
            break
    flag = 0
print(count)










Measured memory_bytes: 45660
n, k = map(int, input().split())

trees = []
for _i in range(n):
  tree = int(input())
  trees.append(tree)

trees.sort()
ans = float('inf')

for i in range(n - k + 1):
  diff = trees[i + k - 1] - trees[i]
  if ans > diff:
    ans = diff

print(ans)

Measured memory_bytes: 13232
n=int(input())
t=list(map(int,input().split()))
m=int(input())
p=[]
x=[]
for i in range(m):
    P,X=map(int,input().split())
    p.append(P)
    x.append(X)
for i in range(m):
    print(sum(t)-t[p[i]-1]+x[i])



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

bool isPrime(int n){
  if( n == 0 || n == 1 ) return false;  
  for(int d = 2; d * d <= n; d++)
    if( n % d == 0 ) return false;
  return true;
}

int main(){
  for(int N; cin >> N; ) {
    int ans = 0;
    for(int i = 1; i <= N; i++) {
      if( isPrime(i) && isPrime(N - i + 1) ) ans++;
    }
    cout << ans << endl;
  }
}

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

int main()
{
    int a, flag=0;
    cin >> a;

    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j == a){
                flag = 1;
                break;
            }
        }
    }
    if(flag == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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 po(int a) {
    return a * a * a * a * a;
}

void solve() {
	int x; cin >> x;
    for(int a = -1000; a <= 1000; ++ a) {
        for(int b = -1000; b <= 1000; ++ b) {
            if(po(a) - po(b) == x) {
                cout << a << " " << b << endl;
                return;
            }
        }
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <numeric>
#include <map>

template <typename T>
std::map<T, int> prime_factorize(T n)
{
	std::map<T, int> m;
	for (int i = 2; 1LL * i * i <= n; ++i) {
		int c = 0;
		for (; n % i == 0; n /= i) {
			++c;
		}
		if (c != 0) {
			m[i] = c;
		}
	}
	if (n != 1) {
		m[n] = 1;
	}
	return m;
}

using namespace std;

bool is_pairwise_coprime(const vector<int>& A)
{
	map<int, int> m;
	for (auto x : A) {
		for (auto& e : prime_factorize(x)) {
			m[e.first] += 1;
		}
	}
	for (auto& e : m) {
		if (e.second != 1) {
			return false;
		}
	}
	return true;
}

bool is_setwise_coprime(const vector<int>& A)
{
	return accumulate(A.begin(), A.end(), 0, std::gcd<int, int>) == 1;
}

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto& x : A) {
		cin >> x;
	}

	if (is_pairwise_coprime(A)) {
		cout << "pairwise coprime" << endl;
	}
	else if (is_setwise_coprime(A)) {
		cout << "setwise coprime" << endl;
	}
	else {
		cout << "not coprime" << endl;
	}
}


Measured memory_bytes: 10772
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;



int main() {
  string s;
  cin>>s;
  string t;
  while (sz(t) < sz(s)) t += "hi";
  if (s == t) yn;
  return 0;
}






















Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{int p,l,r;};
struct Node T[MAX];
int n;

void preParse(int u){
  if(u==NIL)return;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==NIL)return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,v,l,r,root;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=NIL;
  }
for(i=0;i<n;i++){
  scanf("%d %d %d",&v,&l,&r);
T[v].l=l;
T[v].r=r;
if(l!=NIL)T[l].p=v;
if(r!=NIL)T[r].p=v;
}
for(i=0;i<n;i++)if(T[i].p==NIL)root=i;

printf("Preorder\n");
preParse(root);
printf("\n");
printf("Inorder\n");
inParse(root);
printf("\n");
printf("Postorder\n");
postParse(root);
printf("\n");

return 0;
}



Measured memory_bytes: 2092
n = int(input())
v_list = list(map(int, input().split()))

while len(v_list) > 1:
    v_list.sort(reverse=True)
    v = (v_list[-2] + v_list[-1]) / 2
    v_list[-2] = v
    v_list.pop()
print(v_list[0])


Measured memory_bytes: 3064
#include <stdio.h>
int main(void)
{
	int a, b;
	scanf("%d%d", &a, &b);
	if ((a + b) % 2 == 0){
		printf("%d\n", (a + b) / 2);
	}
	else {
		printf("IMPOSSIBLE\n");
	}
	return (0);
}


Measured memory_bytes: 128
from bisect import bisect_left
import sys
input = sys.stdin.buffer.readline


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))


ans = 0
for keta in range(0, 29)[::-1]:
    MOD = 1 << (keta + 1)
    T = 1 << keta
    for i in range(n):
        a[i] %= MOD
        b[i] %= MOD
    a.sort(reverse=True)
    b.sort()

    # T <= a[i] + b[j] < 2T もしくは 3T <= a[i] + b[j] < 4T
    # を満たすi, jの組の個数を尺取り法で探す
    T1 = [0] * n
    l = 0
    for i in range(n):
        while l < n and a[i] + b[l] < T:
            l += 1
        T1[i] = l

    T2 = [0] * n
    l = 0
    for i in range(n):
        while l < n and a[i] + b[l] < 2 * T:
            l += 1
        T2[i] = l

    T3 = [0] * n
    l = 0
    for i in range(n):
        while l < n and a[i] + b[l] < 3 * T:
            l += 1
        T3[i] = l

    T4 = [0] * n
    l = 0
    for i in range(n):
        while l < n and a[i] + b[l] < 4 * T:
            l += 1
        T4[i] = l

    cnt = 0  
    for i in range(n):
        cnt += (T2[i] - T1[i]) + (T4[i] - T3[i])

    # i, jの組の個数が奇数だったら、xorしたときにTが残る
    if cnt % 2 == 1:
        ans += T

print(ans)

Measured memory_bytes: 227076
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    int A,B;
    cin >> A >> B;
    int ans = 0;
    FOR(i,A,B+1){
        if(i/10000 == i%10 && (i/1000)%10 == (i/10)%10) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

const int N = (int)1e5 + 7;

int dp[N];
int n;
int a[N];

main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	dp[2] = dp[1] + abs(a[2] - a[1]);
	for (int i = 3; i <= n; i++) {
		dp[i] = min(dp[i - 2] + abs(a[i - 2] - a[i]), dp[i - 1] + abs(a[i - 1] - a[i]));
	}
	cout << dp[n];
}


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

int main(){
    int A, B, C; cin >> A >> B >> C;
    bool flg = false;
    for(int i = 1; i <= B; i++){
        if(i*A%B==C) flg = true;
    }
    cout << (flg ? "YES" : "NO") << endl;
    return 0;
}


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

int main(){
int N;
cin >> N;
string s[N];
int c0=0, c1=0, c2=0, c3=0;
rep(i,N){
cin >> s[i];
if(s[i]=="AC") c0++;
if(s[i]=="WA") c1++;
if(s[i]=="TLE") c2++;
if(s[i]=="RE") c3++;
} 
cout << "AC x " << c0 << endl;
cout << "WA x " << c1 << endl;
cout << "TLE x " << c2 << endl;
cout << "RE x " << c3 << endl;
return 0;
}

Measured memory_bytes: 6748
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();

    int start = A + B;

    if (24 <= start) {
      start = start - 24;
    }

    System.out.println(start);

  }
}

Measured memory_bytes: 22868
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	static final int INF=Integer.MAX_VALUE;
	static final long LINF=Long.MAX_VALUE;

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		sc.close();
		String output = input.substring(0, 4) + " " + input.substring(4, input.length()); 
		
		p(output);
		
		
		
	}
	
	
	
	
	public static void p(Number a) {
		System.out.println(a);		
	}
	public static void p(String a) {
		System.out.println(a);		
	}
	public static void pn(Number a) {
		System.out.print(a);		
	}
	public static void pn(String a) {
		System.out.print(a);		
	}
	
	public static int powerInt(int a, int b) {
		return (int) Math.pow(a, b);
	}

	public static int max(int arr[]) {
		int max = arr[0];
		
		for (int i=0; i<arr.length; i++) {
			if (max < arr[i]) {
				max = arr[i];
			}
		}
		
		return max;
	}
	public static double max(double arr[]) {
		double max = arr[0];
		
		for (int i=0; i<arr.length; i++) {
			if (max < arr[i]) {
				max = arr[i];
			}
		}
		
		return max;
	}	
	public static int min(int arr[]) {
		int max = arr[0];
		
		for (int i=0; i<arr.length; i++) {
			if (max > arr[i]) {
				max = arr[i];
			}
		}
		
		return max;
	}
	public static double min(double arr[]) {
		double max = arr[0];
		
		for (int i=0; i<arr.length; i++) {
			if (max > arr[i]) {
				max = arr[i];
			}
		}
		
		return max;
	}	

}




class CompUpInt implements Comparator {
	public int compare(Object o1,Object o2){
		int n1 = (int)o1;
		int n2 = (int)o2;
		return n1 - n2;
	}
}
class CompUpDbl implements Comparator {
	public int compare(Object o1,Object o2){
		double n1 = (double)o1;
		double n2 = (double)o2;
		return (n1 > n2) ? 1 : -1;
	}
}
class CompUpIntD2 implements Comparator {
	public int compare(Object o1,Object o2){
		int n1[] = (int[])o1;
		int n2[] = (int[])o2;
		return n1[1] - n2[1];
	}
}


Measured memory_bytes: 9684
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
    int N;
    long long a[100010][3];
    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
    }
    long long dp[100010][3]; //n-1日目の幸福度の最大値候補を3パターン
    for(int i=0;i<100010;i++){
        for(int j=0;j<3;j++){
            dp[i][j] = 0;
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j==k) continue;
                chmax(dp[i+1][k],dp[i][j] + a[i][k]);
            }
        }
    }
    long long maxdp = 0;
    for(int j=0;j<3;j++){
        chmax(maxdp,dp[N][j]);
    }
    cout << maxdp << endl;
    return 0;
}

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

int main() {
    int N,r=0;
    cin >> N;
    vector<vector<int>> c(10, vector<int>(10,0));
    
    rep(i,N) {
        string s = to_string(i+1);
        c.at(s.at(0)-'0').at(s.at(s.size()-1)-'0')++;
    }

    rep(i,9)
        rep(j,9)
            r += c.at(i+1).at(j+1)*c.at(j+1).at(i+1);
    cout << r << endl;
}

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

int main() {
	int n, L[100010],R[100010] , ans=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> L[i];
		cin >> R[i];
	}
	for (int i = 0; i < n; i++) {
		ans += R[i] - L[i]+1;
	}
	cout << ans << endl;




	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;



int main() {
	int n; cin >> n;
	vector<int> a(n);
	int sum = 0;
	rep(i, 0, n) {
		cin >> a[i];
		sum += a[i];
	}
	int ans = inf, sub = 0;
	rep(i, 0, n) {
		sub += a[i];
		ans = min(max(sub,sum-sub)-min(sub,sum-sub), ans);
	}
	printf("%d", ans);
	return 0;
}


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

int main(){
  int N,D;
  cin >> N >> D;
  int arr[N][D];
  for(int i = 0; i < N; i++){
    for(int j = 0; j < D; j++){
      cin >> arr[i][j];
    }
  }
  int dist;
  int ans=0;
  for(int i = 0; i < N; i++){
	for(int j = i+1; j < N; j++){
	  dist=0;
      for(int k = 0; k < D; k++){
		dist+=pow(arr[i][k]-arr[j][k],2);
      }
      if(pow((int)sqrt(dist),2)==dist)ans++;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		String t = sc.next();
		sc.close();
		boolean f = true;
		HashMap<Character, Character> c1 = new HashMap<>();
		HashMap<Character, Character> c2 = new HashMap<>();
		for(i=0;i<s.length();i++) {
			if(c1.containsKey(s.charAt(i))) {
				if(!c1.get(s.charAt(i)).equals(t.charAt(i))) {
					f = false;
					break;
				}
			} else {
				c1.put(s.charAt(i), t.charAt(i));
			}
			if(c2.containsKey(t.charAt(i))) {
				if(!c2.get(t.charAt(i)).equals(s.charAt(i))) {
					f = false;
					break;
				}
			} else {
				c2.put(t.charAt(i), s.charAt(i));
			}
		}
		out.println(f?"Yes":"No");
	}
}


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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int x, k, d;
    cin >> x >> k >> d;

    if(abs(x)/d > k){
        cout << abs(x) - k*d << endl;
        return 0;
    }
    else{
        if((k - abs(x)/d) % 2 == 0){
            cout << abs(x) - abs(x)/d*d << endl;
        }
        else{
            cout << abs(abs(x) - (abs(x)/d + 1)*d) << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
	
int32_t main(){
	boost;
	int n,m,k;
	cin>>n>>m>>k;
	int a[n],b[m];
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i > 0)
			a[i] += a[i-1];
	}
	for(int i = 0;i<m;i++){
		cin>>b[i];
		if(i > 0)
			b[i] += b[i-1];
	}
	int ans = 0;
	int r = m-1 ;
	for(int i=0;i<n && a[i]<=k;i++) {
		int cur = i + 1;
		int rem = k - a[i];
		while(r>=0 && b[r]>rem)
			r--;
		cur += r+1;
		ans = max(ans,cur);
	}

	r = n - 1;
	for(int i=0;i<m&&b[i]<=k;i++){
		int cur = i + 1;
		int rem = k - b[i];
		while(r>= 0 && a[r]>rem)
			r--;
		cur += r+1;
		ans = max(ans,cur);
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 6764
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<string,int> P;

bool isLeap(int i){
	return i % 400 == 0 
			? true : i % 100 == 0
			? false : i % 4 == 0
			? true : false;
}

int getSum(int y,int m,int d,const int* month){
	int sum=0;
	for(int i=0;i<y;i++){
		sum += isLeap(i) ? 366 : 365;
	}

	for(int i=1;i<m;i++){
		sum += i != 2 ? month[i] :
			isLeap(y) ? month[i] + 1 : month[i];
	}

	sum += d;

	return sum;
}

int main(){
	const int month[] = {-1,31,28,31,30,31,30,31,31,30,31,30,31};
	int y1, m1, d1, y2, m2, d2;
	while(~scanf("%d %d %d %d %d %d",&y1, &m1, &d1, &y2, &m2, &d2)){
		if(y1 < 0 || m1 < 0 || d1 < 0
			|| y2 < 0 || m2 < 0 || d2 < 0) break;

		cout << abs(getSum(y1,m1,d1,month) - getSum(y2,m2,d2,month)) << endl;
	}
}

Measured memory_bytes: 3240
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;


signed main() {
  int M, D;
  cin >> M >> D;

  int ans = 0;
  FOR(j, 22, D+1){
    int d1 = j/10;
    int d2 = j%10;
    if(d1*d2 <= M && d1 >= 2 && d2 >= 2) ans++;
  }

  cout << ans << endl;

  return 0;
}

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

int main()
{
  int N;
  std::cin >> N;
  std::vector<unsigned int> a(N);
  for(int i=0; i<N; i++) {
    std::cin >> a[i];
  }

  unsigned int i=1;
  unsigned int max_a = *std::max_element(a.begin(), a.end());
  while(true) {
    if(max_a < i) {
      break;
    }

    // count 1 of i-bit
    int n = 0;
    for(int j=0; j<N; j++) {
      if(a[j] & i) n++;
    }
    // std::cout << "n: " << n << std::endl;
    if(n % 2 == 1) {
      for(int j=0; j<N; j++) {
        a[j] = a[j] ^ i;
      }
    }
    i = i << 1;
  }

  for(int j=0; j<N; j++) {
    std::cout << a[j] << " ";
  }
  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */
void yes(){
  cout << "YES" << endl;
  exit(0);
}

void no(){
  cout << "NO" << endl;
  exit(0);
}

int main() {
  vector<string> s(2);
  REP(i, 2) cin >> s[i];
  REP(j,3){
    if(s[0][j] != s[1][2-j]) no();
  }
  yes();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
string yes = "Yes\n";
string no = "No\n";

#define M 1000000000000000000

int  main()
{
	int n; cin >> n;
	vector<ll>  a(n);
	ll sum = 1;
	rep(i, n)
	{
		cin >> a[i];
		if (a[i] == 0)
		{
			cout << 0 << endl;
			return 0;
		}
	}
	rep(i, n)
	{
		if (M / sum < a[i])
		{
			cout << -1 << endl;
			return 0;
		}
		sum *= a[i];
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 4016
#include <iostream>
using namespace std;
int main() {
	string menu;
	cin >> menu;
	int ans = 700;
	if(menu[0] == 'o') ans += 100;
	if(menu[1] == 'o') ans += 100;
	if(menu[2] == 'o') ans += 100;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
#define MAX 100010

int par[MAX];
int rn[MAX];

void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    rn[i] = 0;
  }
}

int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;

  if (rn[x] < rn[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (rn[x] == rn[y]) rn[x]++;
  }
}

bool same(int x, int y) {
  return find(x) == find(y);
}

signed main() {
  int n, m;
  cin >> n >> m;
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  init(n);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    unite(x, y);
  }
  int count = 0;
  for (int i = 0; i < n; i++) {
    int res = i + 1;
    if (p[i] == res || same(res, p[i])) {
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int main(){
		int a[5];
		for(int i = 1;i <= 3;i++)scanf("%d",a+i);
		sort(a+1,a+4);
		//for(int i = 1;i <= 3;i++) printf("%d\n",a[i]);
		
		if(a[1]==5&&a[2]==5&&a[3]==7)puts("YES");
		else puts("NO");
		return 0;
	}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
using namespace std;


//ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
//ll arr[1000007];
//ll modPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//
//	ll halfpow = modPower(b, p / 2);
//	ll toReturn = (halfpow * halfpow) % mod;
//	if (p % 2)
//		toReturn = (toReturn * b) % mod;
//
//	return toReturn;
//}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
//void pre(ll n) {
//
//	fact[0] = 1;
//	inv[0] = 1;
//
//	for (ll i = 1; i <= n; i++) {
//		fact[i] = (i * fact[i - 1]) % mod;
//		inv[i] = modPower(fact[i], mod - 2);
//		arr[i] = modPower(i, mod - 2);
//	}
//}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
//ll ncr(ll n, ll r) {
//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
//}
//
//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}

const ll mod = 1e9 + 7;
const ll N = 1e5 + 7;
const ll INF = 1e9 + 5;

ll n,w;

ll weight[107] = {}, vals[107] = {};
ll dp[107][N];

int main()
{
    MohamedMotaz;
    cin >> n >> w;
   // memset(dp, 0, sizeof(dp));
    f(i,1,n + 1) cin >> weight[i] >> vals[i];

    f(i,1,n + 1){
        f(j, 1, w + 1){
            //two options, take or leave
            ll op1 = 0, op2 = 0;
            op1 = dp[i - 1][j];

            if (j >= weight[i]){
                op2 = vals[i] + dp[i - 1][j - weight[i]];
            }
            dp[i][j] = max(op1, op2);
        }
    }

//    f(i,1,n + 1){
//        f(j, 1, w + 1){
//            cout << dp[i][j] << " ";
//        }cout << endl;
//    }
    cout << dp[n][w];
}



Measured memory_bytes: 79360
import math
import sys
from itertools import accumulate
from functools import reduce
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())
    = [list(list(sys.stdin.readline().rstrip())) for i in range(h)] #文字列を分解して二次元配列入力

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    n,m = map(int, sys.stdin.readline().split())
    a=[input() for _ in range(n)]
    b=[input() for _ in range(m)]
    r = any([r[j:j+m] for r in a[i:i+m]]==b for i in range(n-m+1) for j in range(n-m+1)) #内包表記×多重ループ
    print("Yes" if r else "No")

Measured memory_bytes: 5116
#include <stdio.h>
int main(void) {
	long long n, i, a, b, ans[100001] = {};
	long long k, count = 0;
	scanf("%lld%lld", &n, &k);
	for (i = 0; i < n; i++) {
		scanf("%lld%lld", &a, &b);
		ans[a] += b;
	}

	for (i = 1 ; i <= 100000; i++) {
		count += ans[i];
		if (k <= count) break;
	}
	printf("%lld\n", i);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<setprecision(30)<<w*h/2<<' ';
    bool flag=false;
    if(2*x==w && 2*y==h) flag=true;
    if(flag){
      cout<<1<<endl;
    }else{
      cout<<0<<endl;
    }
}

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



int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    int n, m;
    while (scanf("%d", &n) == 1) {
        vector<int> a(n);
        for (int i = 0; i < n; i++) scanf("%d", &a[i]);

        scanf("%d", &m);
        vector<int> b(m);
        for (int i = 0; i < m; i++) scanf("%d", &b[i]);

        map<int, int> mp;
        for (int x : a) mp[x]++;

        bool ok = 1;
        for (int x : b) ok &= mp[x]-- > 0;

        string s = ok ? "YES" : "NO";
        cout << s << endl;
    }

#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

Measured memory_bytes: 11264
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>

using namespace std;

int main() {

    string S,T;
    cin>>S>>T;
    int A,B;
    cin>>A>>B;
    string U;
    cin>>U;

    if(S==U){
        A=A-1;
    }
    else{
        B=B-1;
    }


    cout<<A<<" "<<B<<endl;



}



Measured memory_bytes: 256
import java.util.Scanner;



public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		double input = Double.parseDouble(s.nextLine());
		System.out.print((int)input + ":");
		for(int i=2 ; (int)Math.floor(Math.sqrt(input))+1 > i ;) {
			if(input%i == 0) {
				System.out.print(" " + i);
				input = input / i;
			}else
				i++;
		}
		if(input!=1)
			System.out.print(" " + (int)input);
		System.out.println("");
	}

}

Measured memory_bytes: 26568
n = gets.to_i
v = gets.split(" ").map(&:to_i)
c = gets.split(" ").map(&:to_i)
res = 0

for i in 0..(n-1) do
  if v[i]-c[i] > 0
    res += v[i]-c[i]
  end
end
puts res

Measured memory_bytes: 1788
S = int(input())
S1, S2 = S // 100, S % 100

YYMM = (1 <= S2 and S2 <= 12)
MMYY = (1 <= S1 and S1 <= 12)

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

Measured memory_bytes: 9104
#include <bits/stdc++.h>
#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
using namespace std;

void File () {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}

const int N = 310;
int dp[N][N], sum[N][N], C[N][N], n, k, Mod;

int main () {
	File();

	cin >> n >> k >> Mod;
	For (i, 0, n) {
		C[i][0] = 1;
		For (j, 1, i)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % Mod;
	}

	For (j, 0, k)
		dp[1][j] = 1, sum[1][j] = k - j + 1;

	For (i, 2, n + 1) {
		For (j, 0, k)
			For (q, 1, i - 1)
				(dp[i][j] += 1ll * dp[i - q][j] * C[i - 2][q - 1] % Mod * sum[q][j + 1] % Mod) %= Mod;

		Fordown (j, k, 0)
			sum[i][j] = (dp[i][j] + sum[i][j + 1]) % Mod;
	}

	printf ("%d\n", dp[n + 1][0]);

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> Vec;

struct State {
    ll cost;
    Vec v;
    State(ll cost, Vec v) :
        cost(cost), v(v) {}

    bool operator < (const State &s) const {
        return cost > s.cost;
    }
};

ll get_val(Vec &v)
{
    ll res = 0LL, N = v.size();
    for (auto &x: v) {
        res *= N;
        res += x;
    }
    return res;
}

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

    priority_queue<State> Q;
    Q.push(State(0, start));

    unordered_map<ll, ll> min_cost;
    min_cost[get_val(start)] = 0;    
    
    while (!Q.empty()) {
        State s = Q.top(); Q.pop();
        Vec v = s.v;
        
        for (int i = 0; i < N; i++) {
            for (int j = i+1; j < N; j++) {
                swap(v[i], v[j]);
                ll vv = get_val(v);
                if (min_cost.count(vv) == 0 ||
                    s.cost + c[i][j] < min_cost[vv]) {
                    min_cost[vv] = s.cost + c[i][j];
                    Q.push(State(min_cost[vv], v));
                }                    
                swap(v[i], v[j]);
            }
        }        
    }

    ll res = 0;
    for (auto &x: min_cost) {
        res = max(res, x.second);
    }    
    cout << res << endl;    
    return 0;
}

Measured memory_bytes: 9108
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

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

#define pb push_back
#define fr first
#define sc second

const ll M = 1000000007;

ll modpow(ll x,ll k){
	if(k == 0)return x;
	ll ret = modpow(x,k/2);
	ret *= ret; ret %= M;
	if(k&1LL){
		ret *= x;
		ret %= M;
	}
	return ret;
}

int main(){
	static ll N,C;
	static ll A[402],B[402];
	scanf("%lld%lld",&N,&C);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%lld",&A[i]);
	}
	for(int i = 1 ; i <= N ; i ++){
		scanf("%lld",&B[i]);
	}
	
	static ll dp[402][402] = {};
	dp[0][0] = 1;
	for(int i = 1 ; i <= N ; i ++){
		ll d[402] = {};
		ll t[402] = {};
		for(int k = A[i] ; k <= B[i] ; k ++){
			t[k] = 1;
		}
		for(int j = 0 ; j <= C ; j ++){
			for(int k = A[i] ; k <= B[i] ; k ++){
				d[j] += t[k];
				t[k] *= k;
				t[k] %= M;
			}
			d[j] %= M;
		}
		for(int j = 0 ; j <= C ; j ++){
			for(int k = 0 ; k <= j ; k ++){
				dp[i][j] += dp[i-1][j-k]*d[k];
				dp[i][j] %= M;
			}
		}
	}
	cout << dp[N][C] << endl;
}



Measured memory_bytes: 1536
#include <stdio.h>
 
int main() {

    int n, m;
    scanf("%d %d\n", &n, &m);

    int matrix[n][m] = {};
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            scanf("%d ", &matrix[i][j]);
        }
    }

    int vector[m][1] = {};
    for (int i=0; i<m; i++) {
        scanf("%d", &vector[i][0]);
    }

    int sum = 0;
    for (int i=0; i<n; i++) {
        sum = 0;
        for (int j=0; j<m; j++) {
            sum = sum + matrix[i][j] * vector[j][0];
        }
        printf("%d\n", sum);
    }

    return 0;
}


Measured memory_bytes: 2736
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl = vector<ll>; using vvl = vector<vl>;
using vp = vector<pair<int,int>>;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main(){
  int n;cin >> n;
  vl in(n);
  rep(i,n) cin >> in[i];
  ll ans = 0;
  FOR(i,0,n) {
    FOR(j,i,n) {
      FOR(k,j,n) {
        if(in[i] == in[j]||in[j] == in[k]) continue;
        if(in[i] == in[k]) continue;
        vl l(0);
        l.push_back(in[i]);
        l.push_back(in[j]);
        l.push_back(in[k]);
        sort(l.begin(),l.end());
        if(l[0]+l[1] > l[2]) ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin>>n;
  int a[n];
  vector<int> v;
  for(int i=0;i<n;++i) cin>>a[i];
  if(n%2){
    for(int i=0;i<n;++i)
      if(i%2) v.push_back(a[i]);
      else v.insert(v.begin(),a[i]);
  }else{
    for(int i=0;i<n;++i)
      if(i%2) v.insert(v.begin(),a[i]);
      else v.push_back(a[i]);
  }
  for(int i=0;i<n;++i) cout<<v[i]<<(i==n-1?"\n":" ");
  return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using ll = long long;

int main()
{
  ll N;
  std::cin >> N;
  std::vector< ll > vl(2 * N, 0LL);
  for (ll i = 0; i < 2 * N; i++) {
    std::cin >> vl[i];
  }

  std::sort(vl.begin(), vl.end(), std::less<>());
  ll ans = 0LL;
  for (ll i = 0; i < 2 * N; i+=2) {
    ans += vl[i];
  }

  std::cout << ans << std::endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vi32 p(n), q(n);
  cin >> p >> q;
  int ans1 = -1;
  int ans2 = -1;
  vi32 ju(n);
  iota(all(ju), 1);
  int cnt = 1;
  do {
    {
      bool f = true;
      rep(i, n) if (ju[i] != p[i]) f = false;
      if (f) ans1 = cnt;
    }
    {
      bool f = true;
      rep(i, n) if (ju[i] != q[i]) f = false;
      if (f) ans2 = cnt;
    }
    cnt++;
  } while (next_permutation(all(ju)));
  cout << abs(ans1 - ans2) << endl;
}


Measured memory_bytes: 256
#j-i=Ai+Aj Ai+i=-Aj+j
#Li=Ai+i
#Ri=-Ai+i
#とおくと、Li=Rjとなるとき、Aiが正なので、必ずi<jとなる
from collections import defaultdict

n=int(input())
A=list(map(int,input().split()))

L=defaultdict(int)
R=defaultdict(int)

for i in range(n):
	L[A[i]+i+1]+=1
	R[-A[i]+i+1]+=1

r=0
for k,v in L.items():
	j=R[k]
	r+=v*j

print(r)
	

Measured memory_bytes: 73608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b;
  c = a + b;
  if (c % 2 == 0){
    cout << c / 2 << endl;
  }else{
  	cout << c / 2 + 1<< endl;
  }
}

Measured memory_bytes: 256
while True:
    t = input().split()
    a = int(t[0])
    op = t[1]
    b = int(t[2])

    if op == '?':
        break

    if op == '+':
        print("%d"%(a+b))

    elif op == '-':
        print("%d"%(a-b))

    elif op == '*':
        print("%d"%(a*b))

    elif op == '/':
        print("%d"%(a/b))


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> pipii;
typedef priority_queue<pii, vector<pii>, greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
//const double PI = acos(-1);
const int mod = 1000000007;

// ----------------------DEBUG TEMPLATE--------------------------
void __print(int 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
// ----------------------DEBUG TEMPLATE--------------------------



int bu(vi &arr,int n,int k){
	int dp[n+2][k+2];
	memset(dp,0,sizeof(dp));
	for(int i =0;i <=k;i++){
		dp[1][i] = (i<=arr[1])?1:0;
	}	
	for(int i =2;i <=n;i++){
		
		for(int j =0;j<=k;j++){
			if(j==0){
				dp[i][j] = dp[i-1][j];
				continue;
			}
			if(j-arr[i]-1>=0){
				dp[i][j] = (dp[i][j-1] + dp[i-1][j] - dp[i-1][j-arr[i]-1] +mod)%mod;
			}
			else{
				dp[i][j] = (dp[i][j-1] + dp[i-1][j])%mod ;
			}
			// for(int m=0; m<=arr[i] && m<=j;m++){
			// 	dp[i][j] += dp[i-1][j-m];
			// }
		}
	}
	// for(int i =k;i>=0;i--){
	// 	if(dp[n][i] != 0){
	// 		return dp[n][i];
	// 	}
	// }
	// fo(i,n+1){
	// 	fo(j,k+1){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	return dp[n][k];


}



void solve(){
	int n,k;
	cin>>n>>k;
	vi arr(n+1);
	Fo(i,1,n+1) cin>>arr[i];
	cout<<bu(arr,n,k)<<endl;
	
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	// cin>>t;
	while(t--){
		solve();
	}


}

Measured memory_bytes: 83148