akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d", &tmp);v.push_back(tmp);}}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int a, b, c;
  cin >> a >> b >> c;

  cout << max({a + b * 10 + c, a * 10 + b + c, c * 10 + a + b}) << endl;
  return 0;
}



Measured memory_bytes: 256
s=input()
c=0
l=0
r=len(s)-1
while r-l>0:
  if s[l]==s[r]:
    l+=1
    r-=1
  elif s[l]=='x':
    c+=1
    l+=1
  elif s[r]=='x':
    c+=1
    r-=1
  else:
    print(-1)
    exit()
print(c)

Measured memory_bytes: 39664
n = int(input())
for i in range(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
    print('YES' if abs((x2 - x1)*(y4 - y3) - (x4 - x3)*(y2 - y1)) < 1e-10 else 'NO')

Measured memory_bytes: 6752
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define itn int
#define tin int
#define tni int
bool dbg = false;
int N, A[100010];
int gcd(int a, int b)
{
    while (1) {
        if (a < b)
            swap(a, b);
        if (!b)
            break;
        a %= b;
    }
    return a;
}

int gcdall()
{
    int ret = A[0];
    FOR(i, 0, N)
    {
        ret = gcd(ret, A[i]);
    }
    return ret;
}
void solve()
{
    bool ans = 1;
    itn flag = 1;
    while (flag) {
        int ne, no;
        ne = 0;
        no = 0;
        int idx = 0;
        FOR(i, 0, N)
        {
            if (A[i] % 2ll) {
                no++;
                idx = i;
            } else
                ne++;
        }
        //dump(no);
        //dump(ne);
        if (ne % 2ll) {
            flag = 0;
        } else {
            if (no >= 2) {
                flag = 0;
                ans = !ans;
                //cout << "change" << endl;
            } else {
                ans = !ans;
                if (N == 1) {
                    break;
                }
                if (A[idx] == 1) {
                    if (ne % 2) {
                        ans = !ans;
                    }
                    break;
                }
                A[idx]--;
                itn t = gcdall();
                // dump(t);
                FOR(i, 0, N)
                {
                    A[i] /= t;
                }
            }
        }
        //cout << endl;
    }
    if (ans) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 0, N)
    cin >> A[i];
    solve();
    return 0;
}


Measured memory_bytes: 1024
def solve(N, Cs):
    counts = [-1 for _ in Cs] + [1]
    latest_c = {}
    ans = 1
    d = 10 ** 9 + 7
    for i, c in enumerate(Cs):
        if c not in latest_c:
            latest_c[c] = i
            counts[i] = ans
        else:
            previous_i = latest_c[c]
            if previous_i != i - 1:
                ans += counts[previous_i]
            latest_c[c] = i
            counts[i] = ans
    return ans % d

if __name__ == "__main__":
    N = int(input())
    Cs = [int(input()) for _ in range(N)]
    print(solve(N, Cs))


Measured memory_bytes: 760460
n = int(input())

def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table

print(sum(num_divisors_table(n-1)))

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

int main() {
    string s;
    cin >> s;

    int q;
    cin >> q;

    bool rev = false;
    string head = "";
    string tail = "";
    for(int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if(t == 1) {
            rev = !rev;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if(f == 1) {
                if(rev) tail = tail + c;
                else    head = c + head;
            } else {
                if(rev) head = c + head;
                else    tail = tail + c;
            }
        }
    }

    s = head + s + tail;
    if(rev) reverse(s.begin(), s.end());
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 1512
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n;
  cin>>n;
  vector<Int> ps(n);
  for(Int i=0;i<n;i++) cin>>ps[i];
  Int ans=0;
  for(Int i=0;i+2<n;i++){
    vector<Int> vs({ps[i],ps[i+1],ps[i+2]});
    sort(vs.begin(),vs.end());
    ans+=ps[i+1]==vs[1];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n = list(str(x) for x in input())
l = len(n)
op_cnt = l - 1
for i in range(2 ** op_cnt):
  op = ['-'] * op_cnt
  for j in range(op_cnt):
    if ((i >> j) & 1):
      op[op_cnt-1 - j] = '+'

  formula = ''
  for j in range(op_cnt):
    formula += n[j] + op[j]
  formula += n[op_cnt]
  if eval(formula) == 7:
    print(formula + '=7')
    break


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


int main(){
  int h,w;
  cin >> h >> w;
  vector<string> g(h);
  rep(i,0,h){
    string s;
    cin >> s;
    g[i]=s;
  }
//  cout << g[0] << endl;
  int ans=0;
  int r_count=0;
  int c_count=0;
  int k=0;
  vector<ll> c_memo(w);
  rep(i,0,h){
    rep(j,0,w){
      if(g[i][j]== '#') {
        r_count=0;
        c_memo[j]=0;
        continue;
      }
      if(r_count==0){
        k=1;
        while(j+k<w && g[i][j+k]=='.'){
          r_count++; k++;
        }
      }
      if(c_memo[j]==0){
        c_count=0;
        k=1;
        while(i+k<h && g[i+k][j]=='.'){
          c_count++; k++;
        } 
        c_memo[j]=c_count;
      }
      c_count=c_memo[j];
//      cout << r_count << ' ' << c_count << endl;
      ans = max(ans, r_count + c_count);
    }
    r_count=0;
  }
  cout << ans+1 << endl;
  return 0;
}


Measured memory_bytes: 7408
#include <stdio.h>
#include <math.h>
int main(void)
{
    char S[3];
    scanf("%s", S);

    if (S[1] == 'B')
    {
        printf("ARC\n");
    }
    else
    {
        printf("ABC\n");
    }

    return 0;
}

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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

bool check(char c) {
  string s = "ACGT";
  for (auto x : s) {
    if (x == c) {
      return true;
    }
  }
  return false;
}

int main() {
  ios:: sync_with_stdio(false);
  cin.tie();
  string s;
  cin >> s;
  int n = s.length();
  int len = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (check(s[i])) {
      len++;
    } else {
      len = 0;
    }
    ans = max(ans, len);
  }
  cout << ans;
  return 0;
}




Measured memory_bytes: 3648
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

#define MOD (ll)(1e9+7)

ll fact(ll x)          //defining the function or function definition
{
	ll i, f = 1;
	for (i = 2; i <= x; i++) {
		f *= i;
		f %= MOD;
	}
	return f;
}
ll nPr(ll n, ll r)
{
	return fact(n) / fact(n - r) % MOD;
}

int main()
{
	ll N, M;
	cin >> N >> M;
	if (abs(N - M) > 1) {
		cout << 0 << endl;
		return 0;
	}
	ll n = nPr(N, N - 1);
	ll m = nPr(M, M - 1);
	ll ans = n * m;
	ans %= MOD;
	if (N == M) {
		ans *= 2;
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int comp(const void *a,const void *b){
	return *(int*)b-*(int*)a;
}

int main(){
	int n,m;
	int p[1000];
	int i,j;
	int ans;
	while(1){
		scanf("%d %d",&n,&m);
		if(n==0)return 0;
		ans=0;
		for(i=0;i<n;i++)scanf("%d",&p[i]);
		qsort(p,n,sizeof(int),comp);
		for(i=0;i<n;i++){
			if(i%m!=m-1)ans+=p[i];
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1076
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;
char t[100][100];
ll sd[100][100];
ll h,w;
ll l=-1;
queue<ll> xq,yq,cntq;


void dfs(){
    if(l!=-1) {
        while(!xq.empty()){
            xq.pop();
            yq.pop();
            cntq.pop();
        }
        return;
    }

    if(xq.size()==0) return;
    ll x=xq.front();
    ll y=yq.front();
    ll cnt=cntq.front();
    xq.pop();
    yq.pop();
    cntq.pop();
    //cout<<x<<" "<<y<<" "<<cnt<<endl;
    if(t[x][y]=='#') dfs();
    t[x][y]='#';
    cnt++;
    sd[x][y]=cnt;
    if(x==h&&y==w) {l=cnt;        while(!xq.empty()){
            xq.pop();
            yq.pop();
            cntq.pop();
        }return;}
    if(t[x-1][y]=='.'&&sd[x-1][y]==-1) {
        xq.push(x-1);
        yq.push(y);
        cntq.push(cnt);
    }
    if(t[x+1][y]=='.'&&sd[x+1][y]==-1){
        xq.push(x+1);
        yq.push(y);
        cntq.push(cnt);
    }
    if(t[x][y-1]=='.'&&sd[x][y-1]==-1){
        xq.push(x);
        yq.push(y-1);
        cntq.push(cnt);
    }
    if(t[x][y+1]=='.'&&sd[x][y+1]==-1){
        xq.push(x);
        yq.push(y+1);
        cntq.push(cnt);
    }
    if(l==-1)dfs();
    return;
}

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    vector<vector<char>> x(100,vector<char> (100));

    cin>>h>>w;
        rep(i,100)rep(j,100) sd[i][j]=-1;

    for(ll i=0;i<=h+1;i++){
        for(ll j=0;j<=w+1;j++){
            if(i==0||j==0||i==h+1||j==w+1){
                sd[i][j]=114514;
                t[i][j]='#';
            }else{
            cin>>t[i][j];
            }
            x[i][j]=t[i][j];
            if(t[i][j]=='.') {sum++;}
            else sd[i][j]=123456;
        }
    }
    
    sd[0][0]=0;
    if(t[1][1]=='#'||t[h][w]=='#'){
        cout<<-1<<endl;
        return 0;
    }
    xq.push(1);
    yq.push(1);
    cntq.push(0);
    dfs();
    if(l==-1) {
        cout<<-1<<endl;
        return 0;
    }
    cout<<sum-l<<endl;

    return 0;
}


Measured memory_bytes: 640
loop {
	n, m = gets.split.map &:to_i
	break if n == 0
	hs = (1..n).map { gets.to_i }
	ws = (1..m).map { gets.to_i }
	h_hash = Hash.new(0)
	(0..hs.size-1).each{|i|
		s = 0
		(i..hs.size-1).each{|j|
			s += hs[j]
			h_hash[s] += 1
		}
	}
	w_hash = Hash.new(0)
	(0..ws.size-1).each{|i|
		s = 0
		(i..ws.size-1).each{|j|
			s += ws[j]
			w_hash[s] += 1
		}
	}
	hs = h_hash.to_a.sort_by(&:first)
	ws = w_hash.to_a.sort_by(&:first)
	i = 0
	j = 0
	count = 0
	while i < hs.size && j < ws.size
		if hs[i][0] == ws[j][0]
			count += hs[i][1] * ws[j][1]
			i += 1
			j += 1
		elsif hs[i][0] < ws[j][0]
			i += 1
		else
			j += 1
		end
	end
	p count
}

Measured memory_bytes: 109760
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int X1,Y1,X2,Y2;
  cin>>X1>>Y1>>X2>>Y2;
  int X3,Y3,X4,Y4;
  X3=X2-(Y2-Y1);
  Y3=Y2+(X2-X1);
  X4=X3-(Y3-Y2);
  Y4=Y3+(X3-X2);
  cout<<X3<<" "<<Y3<<" "<<X4<<" "<<Y4;
}



Measured memory_bytes: 768
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 155;
int n,k,mo,f[2][N][N][N];
inline void add(int &x, int y){
	x+=y;x=x<mo?x:x-mo;
}
int solve(int n, int k){//no consequent k
	static int dp[N][N];memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	rep(i,0,n-1)rep(j,0,k-1)if(dp[i][j]){
		add(dp[i+1][0],dp[i][j]);if(j+1<k)add(dp[i+1][j+1],dp[i][j]);
	}
	int res=0;rep(i,0,k-1)add(res,dp[n][i]);
	return res;
}
inline bool ck(int a, int b, int c, int d){
	if(b-k>=c&&b-k<=d&&d-k>=a&&d-k<=b)return 0;
	return 1;
}
int main() {
	read(n);read(k);read(mo);
	if(n==1){puts("2");return 0;}
	if(k%2==0){
		printf("%lld\n",1LL*solve(n/2,k/2+1)*solve(n-n/2,k/2+1)%mo);
		return 0;
	}
	if(k==1){
		printf("%lld\n",1LL*solve(n,3));
		return 0;
	}
	#define f(p,i,j,k) f[p][i+2][j+2][k]
	f(0,0,-1,n+1)=1;
	rep(i,0,n-1){
		int p=i&1,q=p^1;//p-->q
		rep(x,0,i+1)rep(y,-1,i+1)rep(t,i,n+1)f(q,x,y,t)=0;
		rep(x,0,i)rep(y,-1,i){
			int T=n+1;
			if(i%2==0){
				for(int c=x+2;c<=n;c+=2)if(!ck(x+2,c,y+2,i-1)){
					T=c;break;
				}
			}
			else{
				for(int c=y+2;c<=n;c+=2)if(!ck(y+2,c,x+2,i-1)){
					T=c;break;
				}
			}
			rep(t,i,n+1)if(f(p,x,y,t)){
				if(!(i&1)){
					if(i+1!=t&&ck(y+2,i+1,x+2,i))add(f(q,x,y,t),f(p,x,y,t));
					int t_=t-i-1&1?t:n+1;umin(t_,T);
					add(f(q,x,i+1,t_),f(p,x,y,t));
				}
				else{
					if(i+1!=t&&ck(x+2,i+1,y+2,i))add(f(q,x,y,t),f(p,x,y,t));
					int t_=t-i-1&1?t:n+1;umin(t_,T);
					add(f(q,i+1,y,t_),f(p,x,y,t));
				}
			}
		}
	}
	int res=0;rep(x,0,n)rep(y,-1,n)rep(t,0,n+1)add(res,f(n&1,x,y,t));
	cout<<res<<endl;
	return 0;
}


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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

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

    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(1100000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 21724
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3+100;
char s[maxn][maxn];
int dp[maxn][maxn];
const int mod = 1e9+7;
int main(){
    int h,w;
    scanf("%d%d",&h,&w);
    for (int i=1;i<=h;i++){
        scanf("%s",&s[i][1]);
    }
    dp[1][1] = 1;
    for (int i=1;i<=h;i++){
        for (int j=1;j<=w;j++){
            if (s[i][j] == '#' || i == 1 && j == 1)continue;
            dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
        }
    }
    cout<<dp[h][w]<<endl;
    return 0;
}

Measured memory_bytes: 5632
#include <stdio.h>

int main()
{
  int N;
  int X;
  int T;

  scanf("%d", &N);
  scanf("%d", &X);
  scanf("%d", &T);

  int time = 0;

  time = (N/X)*T;

  if(N%X > 0){
    time = time + T;
  }

  printf("%d", time);

    return 0;
}

Measured memory_bytes: 1732
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz size
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 2*1e5+1;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// Criba de Eratostenes ------------------------------------
const int pr=10000;
map<int,int>isp;
void criba(){
    for(int i=0;i<=pr;i++)isp[i]=i;
    isp[0]=isp[1]=-1;
    for(int i=2;i*i<=pr;i++){
        if(isp[i]==i){
        for(int j=i+i;j<=pr;j+=i)
            isp[j]=i;
        }
    }
}
/// My Code -------------------------------------------------


int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    ///freopen("a.in","r",stdin);
    ///freopen("a.out","w",stdout);
    ///criba();
    int n,x;
    cin>>n>>x;
    vi v(n);
    int s=0;
    rep(i,n)cin>>v[i],s+=v[i];
    sort(all(v));
    int ans=n;x-=s;
    ans+=x/v[0];
    cout<<ans<<enl;

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main(){

	ll n;
	while(cin>>n&&n!=0){
		if(n<=4)
			cout<<0<<endl;
		else{
			int sum=0;
			for(ll i = 5; i <= n; i*=5){
				sum+=n/i;
			}
			cout<<sum<<endl;
		}
	}

	return 0;
}

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

using namespace std;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(NULL);

    int n,i,j,k;
    cin >> n;
    long int val;
    long long int dp[n][n],sum[n+1];
    sum[0]=0;
    for(i=0;i<n;i++){
    cin >> val;
    sum[i+1] = sum[i] + val;
    dp[i][i]=0;
    }
    
    for(i=1;i<n;i++){
        for(j=0;j<n-i;j++){
            dp[j][j+i] = 1e18L;
            for(k=j;k<j+i;k++){
                dp[j][j+i] = min(dp[j][j+i] , dp[j][k] + dp[k+1][j+i] + sum[j+i+1] - sum[j]);
            }
        }
    }
    cout << dp[0][n-1];
    
}

Measured memory_bytes: 1536
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			String str=sc.next();
			String res="";
			for(int i=0;i<str.length();i++){
				if(str.charAt(i)=='B'){
					if(res.length()!=0) res=res.substring(0,res.length()-1);
				}
				else res+=Character.toString(str.charAt(i));
			}
			System.out.println(res);
		}
	}
}


Measured memory_bytes: 9428
//============================================================================
// Name        : v
// Date        : Thu Mar  7 18:25:14 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mst(x, y) memset(x, y, sizeof(x))
#define pvar(x) cout << #x << ": "
#define fora(e, c) for (auto &e : c)
#define fori(i, a, b) for (int i = a; i < b; ++i)
#define ford(i, a, b) for (int i = a; i > b; --i)
#define output(v) cout << (v) << '\n'
#define jam(x, n) cout << "Case #" << x << ": " << n << "\n"
#define prt(x, a, n) { cout << x[a]; if (a < n - 1) cout << " "; }
#define par(x, s, n, v) if(v) pvar(x); fori(y, s, n) prt(x, y, n) cout << "\n"

#ifndef __has_trace
#define trace(...)
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

vvi edges, kids, pref, suff;
vi down, up;
int n, mod;

int add(int a, int b) {
    return (a + b) % mod;
}

int mul(int a, int b) {
    return (ll) a * b % mod;
}

// https://codeforces.com/blog/entry/64250?#comment-483299
void fast_down(int u) {
    if (down[u]) return;
    int ret = 1;
    fora (v, kids[u]) {
        fast_down(v);
        ret = mul(ret, 1 + down[v]);
    }
    down[u] = ret;

    int k = sz(kids[u]);
    pref[u] = vi(k + 1, 1);
    fori (i, 1, k + 1) {
        int v = kids[u][i - 1];
        pref[u][i] = mul(pref[u][i - 1], 1 + down[v]);
    }

    suff[u] = vi(k + 1, 1);
    ford (i, k - 1, -1) {
        int v = kids[u][i];
        suff[u][i] = mul(suff[u][i + 1], 1 + down[v]);
    }
}

void fast_up(int u) {
    if (u == 1) up[u] = 1;
    fori (i, 0, sz(kids[u])) {
        int v = kids[u][i];
        up[v] = up[u];
        up[v] = mul(up[v], pref[u][i]);
        up[v] = mul(up[v], suff[u][i + 1]);
        up[v] = add(up[v], 1);
        fast_up(v);
    }
}

// O(v + e)
// Get all directed kids for a ndoe u
void dfs(int u, int parent=-1) {
    fora (v, edges[u]) {
        if (v != parent) {
            kids[u].pb(v);
            dfs(v, u);
        }
    }
}

void solve_fast() {
    cin >> n >> mod;
    edges = vvi(n + 1);
    fori (i, 0, n - 1) {
        int x, y;
        cin >> x >> y;
        edges[x].pb(y);
        edges[y].pb(x);
    }

    down = vi(n + 1);
    pref = vvi(n + 1);
    suff = vvi(n + 1);
    kids = vvi(n + 1);
    dfs(1);
    fast_down(1);

    up = vi(n + 1);
    fast_up(1);

    // trace(edges, kids, down, pref, suff, up);
    fori (i, 1, n + 1) {
        output(mul(down[i], up[i]));
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve_fast();
    return 0;
}



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

int main(){
  string s;
  int K,cost;
  cin >> s >> K;
  //greedy algorithm
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'a' && i != s.size()-1) continue;
    else if(i == s.size() - 1){
      if(K == 0) break;
      else{
        s[i] = (char)(((s[i] + K - 'a')%('z'-'a' + 1)) + 'a' );
        break;
      }
    }else{
      cost = 'z' - s[i] + 1;
      if(K - cost >= 0){
        K-= cost;
        s[i] = 'a';
      }else{
        continue;
      }
    }
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    long long int i,a[8],b[8],sum=0,max=0;
    for(i=0;i<5;i++)
        scanf("%lld",&a[i]);
    for(i=0;i<5;i++)
    {
        if(a[i]%10!=0)
        {
            b[i]=10-(a[i]%10);
        }
        else b[i]=0;
        if(max<b[i])max=b[i];
    }
    for(i=0;i<5;i++)
    {
        sum=sum+a[i]+b[i];
    }
    printf("%lld\n",sum-max);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    double N;
    cin >> N;
    double odds=0,even=0;
    for(int i=1;i<=N;i++){
        if(i%2)odds++;
        else even++;
    }
    cout << fixed << setprecision(10)<< odds/N << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
		for (;;) {
			int n;
			scanf("%d", &n);
			if (n == 0) { break; }

			int s_max = 0;
			int s_min = 100000000;
			int sum = 0;

			for (int i = 0; i < n; i++) {
					int s;
					scanf("%d", &s);

					sum += s;
					s_max = max(s, s_max);
					s_min = min(s, s_min);
			}

			sum -= s_max;
			sum -= s_min;

			printf("%d\n", sum / (n - 2));
		}
		return 0;
}

Measured memory_bytes: 1028
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

const ll mod = 1000000007;

ll modpow(ll a, ll k) {
	if (k == 0) return 1;
	ll tmp = modpow(a, k / 2);
	if (k % 2 == 0)
		return tmp * tmp % mod;
	return tmp * tmp % mod * a % mod;
}

ll fact(ll k, int sgn = 0) {
	static vector<ll> fac(2, 1LL);
	static vector<ll> inv(2, 1LL);
	static vector<ll> finv(2, 1LL);
	static ll nx = 2LL;
	while (nx <= k) {
		fac.push_back(fac[nx - 1] * nx % mod);
		inv.push_back(mod - inv[mod % nx] * (mod / nx) % mod);
		finv.push_back(finv[nx - 1] * inv[nx] % mod);
		++nx;
	}
	if (sgn == 0)
		return fac[k];
	return finv[k];
}

ll comb(ll a, ll b) {
	if (b < 0 || b > a) return 0;
	return fact(a) * fact(b, 1) % mod * fact(a - b, 1) % mod;
}

int main() {
	ll n, k; cin >> n >> k;
	ll res = 0;
	for (int i = 0; i <= min(k, n - 1); ++i) {
		ll tmp = comb(n, i);
		tmp = (tmp * comb(n - 1, i)) % mod;
		res = (res + tmp) % mod;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 5204
# -*- coding: utf-8 -*-

H, W = map(int, input().split())
N = int(input())
aN = list(map(int, input().split()))

nums = []
for i in range(N):
    nums.extend([i+1] * aN[i])

grid = [[0] * W for _ in range(H)]
k = 0
for i in range(H):
    for j in range(W):
        grid[i][j] = nums[k]
        k += 1

for i in range(H):
    if i % 2 == 0:
        print(*grid[i])
    else:
        print(*reversed(grid[i]))


Measured memory_bytes: 3956
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int x; cin >> x;
    int rad = 0;
    for(int i = 1; ; i++){
        rad += x;
        if(rad % 360 == 0){
            cout << i << '\n';
            return 0;
        }
    }
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

int n, m, k;
vector<int> a, b;
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
    {
        int c;
        cin >> c;
        a.push_back(c);
    }
    for (int i = 0; i < m; i++)
    {
        int c;
        cin >> c;
        b.push_back(c);
    }
    for (int i = 1; i < n; i++)
        a[i] += a[i - 1];
    for (int i = 1; i < m; i++)
        b[i] += b[i - 1];

    int ans = (upper_bound(a.begin(), a.end(), k) - a.begin());
    for (int i = 1; i <= m; i++)
    {
        int left = k - b[i - 1];
        if (left < 0)
            continue;
        int it = upper_bound(a.begin(), a.end(), left) - a.begin();
        ans = max(ans, it + i);
    }

    cout << ans;
    return 0;
}

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

int point(string s) {
    if(s == "T" || s == "J" || s == "Q" || s == "K") return 10;
    if(s == "A") return 1;
    return s[0]-'0';
}

int cal(vector<string> cards) {
    if(cards[1] == "A" && point(cards[0]) == 10) return -1;
    if(cards[0] == "A" && point(cards[1]) == 10) return -1;
    int p = 0;
    bool aces = false;
    for(int i=0; i<cards.size(); ++i) {
        if(p <= 16) {
            int t = point(cards[i]);
            if(t == 1 && p+11 <= 21) {
                aces = true;
                p += 11;
            }else if(aces && p+t > 21) {
                aces = false;
                p -= 10;
                p += t;
            }else{
                p += t;
            }
        }else if(p == 17 && aces) {
            int t = point(cards[i]);
            p += t;
            if(p > 21) {
                aces = false;
                p -= 10;
            }
        }
    }
    return p;
}

int main() {
    int tc;
    string card;
    cin>>tc;
    while(tc--) {
        vector<string> hand(10);
        cin>>hand[0]>>hand[1];
        for(int i=0; i<8; ++i) {
            cin>>hand[i+2];
        }
        int p = cal(hand);
        if(p > 21) cout<<"bust"<<endl;
        else if(p == -1) cout<<"blackjack"<<endl;
        else cout<<p<<endl;
    }
}

Measured memory_bytes: 0
import math
N = int(input())

# 約数の数を出してくれる
def make_divisors(n):
    divisors = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return len(divisors)

cnt = 0
# 1からNまでの奇数
for i in range(1, N + 1, 2):
    if make_divisors(i) == 8:
        cnt += 1
print(cnt)

Measured memory_bytes: 38384
import java.util.*;
import java.lang.*;

public class Main
{
    public static void main (String[] args) throws java.lang.Exception
	{
        
        int top = 0;
        int second = 0;
        int third = 0;
        int wk = 0;
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int height = sc.nextInt();
            
            if( !(0 <= height && height <= 10000)) {
                continue;
            }
            
            if (top < height) {
                wk = top;
                top = height;
                height = wk;
            }
            if (second < height) {
                wk = second;
                second = height;
                height = wk;
            }
            if (third < height) {
                wk = third;
                third = height;
                height = wk;
            }
	    }
        
        System.out.println(top);
        System.out.println(second);
        System.out.println(third);
    }   
}

Measured memory_bytes: 17360
n = int(input())
l = [0] * 10*12

for _ in range(n):
    b,f,r,v = map(int,input().split())
    k = 3*10*(b-1) + 10*(f-1) + (r-1)
    l[k] = l[k] + v

k = 0
for i in range(15):
    if (i+1)%4 == 0:
        print ('####################')
        k += 1
    else:
        for j in range(10):
            print (' ' + str(l[((0+i-k)*10)+j]), end='')
        print ()



Measured memory_bytes: 5620
using System;
using System.Linq;
 
namespace aizu
{
    public class OnlineJudge
    {
        static void Main()
        {
            int[] input;
            while(((input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray())[0] | input[1]) != 0) {
                var data = (from p in Enumerable.Range(1, input[0]) let d = Console.ReadLine().Split().Select(b => b == "1").ToArray() select (Enumerable.Range(1, input[1]).Select(q => new { k = q, v = d[q - 1] })).ToDictionary(q => q.k, q => q.v)).ToArray();
                Console.WriteLine(string.Join(" ", Enumerable.Range(1, input[1]).OrderByDescending(p => data.Count(q => q[p] == true)).ThenBy(p => p).Select(q => q.ToString()).ToArray()));
            }
        }
    }
}

Measured memory_bytes: 17240
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(long long n) {

        auto calc = [&](long long n, long long k) {
            if (k == 1) {
                return 1LL;
            }
            while (n % k == 0) {
                n /= k;
                // cout << n << " " << k << " " << endl;
            }
            if (n > k) {
                n %= k;
            }
            return n;
        };

        auto DIV = [&](long long X) {
            vector<long long> res;
            for (int i = 2; i * 1LL * i <= X; ++i) {
                if (X % i == 0) {
                    if (calc(X, i) == 1) {
                        res.push_back(i);
                    }
                    
                    if (i * 1LL * i != X) {
                        if (calc(X, X / i) == 1) {
                            res.push_back(X / i);
                        }
                    }
                }
            }
            return res;
        };

        auto DIV2 = [&](long long X) {
            vector<long long> res;
            for (int i = 1; i * 1LL * i <= X; ++i) {
                if (X % i == 0) {
                    res.push_back(i);
                    if (i * 1LL * i != X) {
                        res.push_back(X / i);
                    }
                }
            }
            return res;
        };

        auto A = DIV(n);
        auto B = DIV2(n - 1);

        for (auto x : B) {
            A.push_back(x);
        }
        A.push_back(n);
        if (n > 2) {
            A.push_back(n - 1);
        }
        sort(A.begin(), A.end());
        A.resize(unique(A.begin(), A.end()) - A.begin());
  
        // for (auto x  : A) {
        //     cout << x  << ":" << calc(n, x) << "\n";
        // }
        // cout << endl;
        int res = A.size();
        --res;
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n;
    cin >> n;
    Solution sol;
    cout << sol.solve(n) << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e5 + 10, INF = 1e9;
int d[maxn], k;


int main()
{
    scanf("%d", &k);
    for(int i = 0; i < k; i++)
        d[i] = INF;
    priority_queue<pii> q;
    for(int i = 1; i <= 9; i++) {
        if(d[i % k] == INF) {
            d[i % k] = i;
            q.push({ -i, i % k });
        }
    }

    while(!q.empty()) {
        pii t = q.top();
        q.pop();
        int dist = -t.first, u = t.second;
        if(u == 0)
            return !printf("%d\n", dist);
        for(int i = 0; i < 10; i++) {
            int v = (10 * u + i) % k;
            if(i + dist < d[v]) {
                d[v] = i + dist;
                q.push({ -d[v], v});
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll hpow(ll x,ll y){
    ll ans=1;
    ll i=x;
    if(y==0)return 1;
    while(y>0){
        if(y%2==1){
            ans=(ans*i)%i_7;
        }
        i=(i*i)%i_7;
        y=y/2;
        
    }
    return ans;
}

int main(){fastio
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll ka[n+1];
    ll kai=1;
    rep(i,1,n){
        kai=(kai*i)%i_7;
    }
    ka[1]=kai;
    rep(i,2,n){
        ka[i]=(kai*hpow(i,i_7-2))%i_7;
    }
    ll sum[n+1];
    sum[0]=0;
    rep(i,1,n){
        sum[i]=(sum[i-1]+ka[i])%i_7;
    }
    ll ans=0;
    rep(i,1,n){
        ans=(ans+a[i-1]*(sum[n+1-i]+sum[i]-kai))%i_7;
    }
    cout<<ans<<endl;
    
    return 0;
}




Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main {
    
    public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] p = br.readLine().split("[\\s]+");
		int n = Integer.parseInt(p[0]);
		int m = Integer.parseInt(p[1]);
		int[] c = new int[m];
		for (int i=0;i<n;i++) {
	    	int[] a = Arrays.stream(br.readLine().split("[\\s]+"))
				.mapToInt(Integer::parseInt).toArray();
	    	for (int j=1;j<a.length;j++) c[a[j]-1]++;
		}
		int ans = 0;
		for (int i=0;i<m;i++) if (c[i] == n) ans++;
		System.out.println(ans);
    }

}

Measured memory_bytes: 26704
import java.util.Scanner;

public class Main
{

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

        int x = scan.nextInt();
        int y = scan.nextInt();
        int c = scan.nextInt();
        int k = 0;

        for (int a = x; a <= y; a++) {
            if (c % a == 0) {
                k++;
            }
        }
        System.out.println(k);
    }

}



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

#define REP(i, s, e) for(int i = (int)s; i < (int) e; i++)
#define rep(i, n) REP(i, 0 ,n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define fi first
#define se second
#define pb push_back
#define mp nake_pair


typedef long long ll;
typedef vector<ll> vi;

const int MAX_C = 100;
 
vector<vi> C(MAX_C,vi(MAX_C,-1LL));
 
void calcC(){
    for(int i=0; i<MAX_C; i++){
        for(int j=0; j<=i; j++){
            if(j==0||j==i)C[i][j]=1LL;
            else{
                C[i][j] = C[i-1][j-1] + C[i-1][j];
            }
        }
    }
}

int d[256];

int main(){
    calcC();
    string s;
    cin>>s;
    rep(i, s.size()) d[s[i]]++;
    int odd = 0;
    REP(i, 'a', 'z'+1) if(d[i]&1) odd++;
    if(odd > 1) {
        cout<<0<<endl;
        return 0;
    }
    int all = 0;
    REP(i, 'a', 'z' + 1) d[i] /= 2, all+=d[i];

    ll ans = 1LL;
    REP(i, 'a', 'z' + 1){
        ans *= C[all][d[i]];
        all -=d[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1288
#include<stdio.h>

#define N 100

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j, e, v,c=0,k=0;
  int u = 0,mincost = 0;
  int cost[N];
  int d[N];
  int p[N],M[N][N];
  
  
  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }
  
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }
  
  for(i=0;i < n;i++){
    d[i] = INFTY;
    p[i] = -1;
    cost[i] = 0;
  }
  
  d[0] = 0;
  
  while(1){
    u = -1;
    mincost = INFTY;
    
    for(i=0;i < n;i++){
      if(d[i] < mincost && cost[i] == 0){
	mincost = d[i];
	u = i;
      }
    }
    
    if(u == -1) break;
    
    cost[u] = 1;
    
    for(v=0;v <n;v++){
      if(d[v] > d[u]+M[u][v]){
	p[v] = u;
	d[v] = d[u]+M[u][v];
      }
    }
  }
  
  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (d[i]==INFTY?-1:d[i]));
  }
  
  return 0;
}

Measured memory_bytes: 636
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 		first
#define s 		second
#define int     long long
#define ll      int
#define ld 		long double
#define pb 		push_back
#define eb 		emplace_back
#define mk 		make_pair
#define vi 		vector<int>
#define pii 		pair<int,int>
#define pip             pair<int,pii>
#define vpi 		vector<pii>
#define sbcount(x) __builtin_popcountll(x)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define trav(a, x)      for(auto& a : x)
#define all(x)          x.begin(), x.end()
#define fill(a,val)	memset(a,val,sizeof(a))
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		    cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl(){cout<<"Control"<<endl;}
int make_num(string p){stringstream geek(p); int x = 0; geek >> x;return x;}
string make_str(int x){ostringstream str1; str1 << x; string geek = str1.str(); return geek;}

signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); 
	cin.exceptions(cin.failbit);
	string p;
    int k;
    cin>>k;
    cin>>p;
    if(p.length()>k)
    {
        string h = p.substr(0,k)+"...";
        cout<<h;
    }
    else
    {
        cout<<p;
    }
    
    
return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<vector>
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	for (int i = 0; i < n; ++i)cin >> a[i];
	if (n % 2 != 0) {
		for (int i = n - 1; i >= 0; i -= 2) cout << a[i] << " ";
		for (int i = 1; i < n - 1; i += 2) {
			cout << a[i];
			if (i != n - 2)cout << " ";
		}
		cout << endl;
	}
	else {
		for (int i = n - 1; i >= 1; i -= 2)cout << a[i] << " ";
		for (int i = 0; i < n - 1; i += 2) {
			cout << a[i];
			if (i != n - 2)cout << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <string.h>

int main(void)
{
	char* string;
	char str[10001];
	int i;
	int numOfJOI;
	int numOfIOI;
	
	string = str;
	
	while( scanf( "%s", string ) != EOF )
	{
		numOfJOI = 0;
		numOfIOI = 0;
		while( string[0] != '\0' )
		{
			if( strncmp( string, "JOI", 3 ) == 0 )
			{
				numOfJOI++;
			}
			if( strncmp( string, "IOI", 3 ) == 0 )
			{
				numOfIOI++;
			}
			string++;
		}
		printf( "%d\n%d\n", numOfJOI, numOfIOI );
	}
	
	return (0);
}

Measured memory_bytes: 552
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
struct edge{int from,to,cost;};
signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ans=0;
  rep2(i,3000)for(int j=0;i+j<=3000;j++){
  if((d-i*a-j*b)%c==0&&d-i*a-j*b>=0)
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256