akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * 課題C5
 *
 * @author ken2
 */
public class Main {

	/** 天気 */
	private enum Weather {
		Sunny, Cloudy, Rainy
	};

	/**
	 * メイン処理
	 *
	 * @param args 起動引数
	 */
	public static void main(String[] args) {

		// 標準入力から今日の天気を取得
		String today = scanTodayWeather(System.in);

		// 標準出力へ明日の天気を出力
		String tomorrow = predictTomorrowWeather(today);
		System.out.println(tomorrow);
	}

	/**
	 * 今日の天気を取得
	 *
	 * @param in 入力ストリーム
	 * @return 今日の天気
	 */
	private static String scanTodayWeather(InputStream in) {
		String today = null;
		try (InputStreamReader isr = new InputStreamReader(in);
				BufferedReader br = new BufferedReader(isr);) {
			today = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return today;
	}

	/**
	 * 今日の天気から明日の天気を予測
	 * ・晴れ→曇り
	 * ・曇り→雨
	 * ・雨→晴れ
	 *
	 * @param today 今日の天気
	 * @return 明日の天気
	 */
	private static String predictTomorrowWeather(String today) {
		String tomorrow = null;
		Weather weather = Weather.valueOf(today);
		switch (weather) {
		case Sunny:
			weather = Weather.Cloudy;
			break;
		case Cloudy:
			weather = Weather.Rainy;
			break;
		case Rainy:
			weather = Weather.Sunny;
			break;
		}
		tomorrow = weather.toString();
		return tomorrow;
	}
}


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

int n, f[505000], g[22];
vector<int>G[505000];

int mg(int x,int y){
  for (int t;t=(x&y);){
    x+=t&-t;
  }
  return min(10001000,x|y);
}

void dfs(int x,int fff){
  for (auto y:G[x])
    if (y!=fff)
      dfs(y,x);
  memset(g,0,sizeof g);
  for (auto y:G[x])
    if (y!=fff){
      for (int i=0;i<=20;++i){
	int tmp=f[y]>>i<<i;
	if (tmp>>i&1) tmp+=1<<i;
	g[i]=mg(g[i],tmp);
      }
    }
  f[x]=998244353;
  for (int i=0;i<=20;++i)
    f[x]=min(f[x],g[i]|1<<i);
}

int main(){
  cin>>n; int x, y;
  for (int tim=n-1;tim--;){
    cin>>x>>y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs(1,0);
  int ans=0;
  for (int t=f[1];t;t>>=1) ++ans;
  cout<<ans-1<<endl;
}


Measured memory_bytes: 21376
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

typedef vector<ll> vec;
typedef vector<vec> mat;

int N;
ll K;
mat A;

mat matmul(mat &A, mat &B)
{
    mat C(A.size(), vec(B[0].size()));
    size_t nr = A.size(), nint = B.size(), nc = B[0].size();
    REP(i, nr){
        REP(k, nint){
            REP(j, nc){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
            }
        }
    }
    return C;
}

mat matpow(mat A, ll n)
{
    mat B(A.size(), vec(A.size()));
    REP(i, A.size()) B[i][i] = 1;
    while(n > 0){
        if(n & 1) B = matmul(B, A);
        A = matmul(A, A);
        n >>= 1;
    }
    return B;
}

void init()
{
}

void solve()
{
    ll ans = 0;
    mat B = matpow(A, K);
    REP(i, N){
        REP(j, N){
            ans += B[i][j];
            ans %= MOD;
        }
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    A.resize(N, vec(N));
    REP(i, N) REP(j, N) cin >> A[i][j];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int a,b;
  cin >> a >> b;
  int ans=-1;

  for(int i=1; i<=(2500/2); i++){
    double tmp1=i*0.08,tmp2=i*0.1;
    if((int)tmp1==a && (int)tmp2==b) {
      ans=i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int t[10][10];
int dp[10][2000];
int score[] = {0, 60, 70, 80};
bool nothing[10][10];

int toint(int *s){
  int res = 0;

  for(int i = 4; i >= 0; i--){
    res <<= 2;
    res |= s[i];
  }

  return res;
}

void totable(int x, int *s){
  for(int i = 0; i < 5; i++){
    s[i] = (x & 3);
    x >>= 2;
  }
}

int solve(){
  int before[10], next[10], tmp[10];
  memset(dp, -1, sizeof(dp));

  dp[0][toint(t[0])] = 0;

  //3¾¯Ê
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 1024; j++){
      if(dp[i][j] == -1) continue;

      totable(j, before);

      for(int k = 0; k < 256; k++){
        totable(k, tmp);

        int sum = 0;

        for(int l = 0; l < 5; l++){
          int top = before[l];
          if(l - 1 >= 0) top = (top + tmp[l - 1]) % 4;
          if(l < 4)      top = (top + tmp[l]) % 4;

          int bottom = t[i + 1][l];
          if(l - 1 >= 0) bottom = (bottom + tmp[l - 1]) % 4;
          if(l < 4)      bottom = (bottom + tmp[l]) % 4;

          if(!nothing[i][l]) sum += score[top];
          if(!nothing[i + 1][l] && i == 3) sum += score[bottom]; //ÁÊ

          next[l] = bottom;
        }

        int nextInt = toint(next);
        dp[i + 1][nextInt] = max(dp[i + 1][nextInt], dp[i][j] + sum);
      }
    }
  }

  int res = 0;
  for(int i = 0; i < 1024; i++){
    res = max(res, dp[4][i]);
  }

  cout << res << endl;
}

int main(){
  int T;
  cin >> T;

  while(T--){
    memset(nothing, 0, sizeof(nothing));

    for(int i = 0; i < 5; i++){
      for(int j = 0; j < 5; j++){
        cin >> t[i][j];
        if(t[i][j] == 0){
          nothing[i][j] = true;
        }
        else{
          t[i][j]--;
        }
      }
    }

    solve();
  }
}

Measured memory_bytes: 944
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int mypow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x;
		}
		x = x * x;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
int mystoi(string x) {
	int res = 0;
	rep(i, x.size()) {
		res = res * 10 + x[i] - '0';
	}
	return res;
}
/*--------Library Zone!--------*/

int n, a[10];
signed main() {
	cin >> n;
	int mi = inf;
	rep(i, 5) {
		cin >> a[i];
		mi = min(mi, a[i]);
	}
	cout << 4 + (n + mi - 1) / mi << endl;
}

Measured memory_bytes: 256
/* Aditya0412 */
    #include <bits/stdc++.h>
    using namespace std; 
    #define int long long 
    #define pb push_back 
    #define vii vector < int > 
    #define pii pair < int , int >
    #define fi first
    #define all(a)      (a).begin(),(a).end()
    #define si(x)       (int)((x).size())
    #define debug(x)    cout<<#x<<" is "<<(x)<<endl;cout.flush();  
    #define se second 
    #define endl        '\n'
    #define f(i,a,b)    for(int i=a;i<b;i++)
    #define mem(a,x)          memset(a,x,sizeof(a))
    #define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    // const int  mod=998244353;
    const int  mod = 1000000000+7;
    const int  N=1000000+6;
    #define M_PI           3.14159265358979323846

    // int x2[]={+1,-1,+0,+0};
    // int y2[]={+0,+0,+1,-1};
    // int x2[]={+0,+0,+1,-1,-1,+1,-1,+1};
    // int y2[]={-1,+1,+0,+0,+1,+1,-1,-1};
    // int x2[]={-2,-2,-1,-1,+1,+1,+2,+2};
    // int y2[]={-1,+1,-2,+2,-2,+2,-1,+1};

    // === Debug macro starts here ===

    int recur_depth = 0;
    #ifdef DEBUG
    #define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
    #else
    #define dbg(x)
    #endif
    template<typename Ostream, typename Cont>
    typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
        os<<"[";
        for(auto& x:v){os<<x<<", ";}
        return os<<"]";
    }
    template<typename Ostream, typename ...Ts>
    Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
        return os<<"{"<<p.first<<", "<<p.second<<"}";
    }

    // === Debug macro ends here ===
int dp[N];
    main() 
    {
        fastIO;
        int n;cin>>n;
        mem(dp,0);
        for(int i=1;i<N;i++)
        {
            for(int j=1;j*i<N;j++)
            {
                dp[i*j]++;
            }
        }
        int ans=0;
        for(int c=1;c<n;c++)
        {
            ans+=dp[n-c];
        }
        cout<<ans;

        
        
    } 

Measured memory_bytes: 11460
#include <bits/stdc++.h>
using namespace std;
int main(){
    int edgesCount;
    cin>>edgesCount;
    vector<int> edges(edgesCount);
    for(int i=0;i<edges.size();i++){
        cin>>edges[i];
    }
    sort(edges.begin(),edges.end());
    int longest=edges[edges.size()-1];
    edges.pop_back();
    if(accumulate(edges.begin(),edges.end(),0)>longest){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin >> n >> m;
    if (n + m == 15) cout << "+" << endl;
    else if (n * m == 15) cout << "*" << endl;
    else cout << "x" << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
guide = []
for i in range(N):
    s,p=LS()
    guide.append([s,100-int(p),i+1])
guide.sort()
for a in guide:
    print(a[2])

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair <int,int>
#define vpii vector< pair<int,int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int MAX = 2e5 + 5;
bool prime[MAX];
void sieve()
{
	memset(prime, true, sizeof(prime));
	for(int i = 2; i < MAX; i++){
		if(prime[i]){
			for(int j = 2 * i; j < MAX; j += i)
			prime[j] = false;
		}
	}
}
int main()
{
	boost;
	sieve();
	vector <int> v;
	int i;
	fo(i, 2, MAX){
		if(prime[i])
		v.pb(i);
	}
	int n;
	cin >> n;
	int x = lower_bound(all(v), n) - v.begin();
	cout << v[x];
}

Measured memory_bytes: 640
#include<stdio.h>
int main (void){
  int w,h,x,y,r,a=0;
  scanf("%d %d %d %d %d",&w,&h,&x,&y,&r)\
;
  if(x-r>=0&&x+r<=w){
    a++;
  }
  if(y-r>=0&&y+r<=h){
    a++;
  }
  if(a==2){
    printf("Yes\n");
  } else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}


// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

mint choose (int n, int a) {
    mint x = 1, y = 1;
    rep(i,a) {
        x *= n-i;
        y *= i+1;
    }
    return x / y;
}

combination comb(100005);
mint f(int n, int k) {
  if (n < 0) return 0;
  // nPk = nCk * k!
  mint res = comb(n,k);
  res *= comb.fact[k];
  return res;
}

vector<int> to[100005];
mint ans = 1;
int k;

void dfs(int v, int p=-1) {
    for (int u : to[v]) {
        if (u == p) continue;
        dfs(u,v);
    }
    if (p == -1) ans *= f(k, int(to[v].size())+1);
    else ans *= f(k-2, int(to[v].size())-1);
}

int main() {
    int n;
    cin >> n >> k;
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dfs(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13780
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

typedef long long ll;

char s[8];

int main() {

   scanf("%s", s);
   int curr = s[0] == 'R' ? 1 : 0;
   int ans = curr;
   for (int i = 1; i < 3; i++) {
      if (s[i] == 'S') curr = 0;
      else curr++;
      ans = max(ans, curr);
   }
   printf("%d\n", ans);

   return 0;
}


Measured memory_bytes: 1736
#include <stdio.h>
#define MAX 30
#define NIL -1

typedef struct{ 
	int p, lc, rc;
}node;

node T[MAX];
int i,n;

void preOrder(int u){
	if (u == NIL)
		return;
	printf(" %d", u);
	preOrder(T[u].lc);
	preOrder(T[u].rc);
}

void inOrder(int u){
	if (u == NIL)
		return;
	inOrder(T[u].lc);
	printf(" %d", u);
	inOrder(T[u].rc);
}

void postOrder(int u){
	if (u == NIL)
		return;
	postOrder(T[u].lc);
	postOrder(T[u].rc);
	printf(" %d", u);
}


int main(void) {
	int id, l, r, root, leftmost;
	
	scanf("%d", &n);
	//initialize
	for (i=0; i<n; i++){
		T[i].p = T[i].lc = T[i].rc = NIL;
	}
	
	for(i=0; i<n; i++){
		scanf("%d", &id);
		scanf("%d %d", &l, &r);
		T[id].lc = l;
		T[id].rc = r;
		T[l].p = T[r].p = id;
	}
	
	printf("Preorder\n");
	for(i=0; i<n; i++){
		if(T[i].p == NIL)
			root = i;
	}
	preOrder(root);
	
	printf("\nInorder\n");
	inOrder(root);
	
	printf("\nPostorder\n");
	postOrder(root);
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 2052
#include<cstdio>
int gcd(int a,int b)
{
return b==0?a:gcd(b,a%b);
}
int main()
{
int a,b;
while(scanf("%d%d",&a,&b)!=EOF)
{
printf("%d\n",gcd(a,b));
}
return 0;
}

Measured memory_bytes: 2584
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,j,k;
    cin>>n;
    ll arr[n][5],dp[n][5]={};
    for(i=0;i<n;i++)
        for(j=0;j<3;j++)
            cin>>arr[i][j];
    dp[0][0]=arr[0][0];
    dp[0][1]=arr[0][1];
    dp[0][2]=arr[0][2];
    for(i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+arr[i][2];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
    return 0;
}


Measured memory_bytes: 8064
import java.io.*;
import java.util.*;

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;

    public static void main(String[]$) {
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int[][] array = new int[h][w];
        for (int i = 0; i < h; i++) {
            if (i >= b) {
                Arrays.fill(array[i], 0, a, 1);
            } else {
                Arrays.fill(array[i], a, w, 1);
            }
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                System.out.print(array[i][j]);
            }
            System.out.println();
        }
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 48156
A,B,K = map(int,input().split())

D = set()
RANGE = A+K if A+K<B else B+1
for i in range(A,RANGE):
    D.add(i)
    
RANGE = B-K+1 if B-K+1>A else A
for i in range(RANGE,B+1):
    D.add(i)
    
for i in sorted(D):
    print(i)

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

int main(void){
  int n, a[1010];
  long long ans=1;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    a[i] = i + 1;
  }
  for (int i = 2; i <= n; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      while (a[j]%i==0) {
        cnt++;
        a[j]/=i;
      }
    }
    ans = ans*(cnt + 1) % (1000000000 + 7);
  }
  printf("%lld", ans);

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String line = sc.nextLine();
			Scanner s = new Scanner(line);
			int[] a = new int[5];
			a[0] = s.nextInt();
			a[1] = s.nextInt();
			a[2] = s.nextInt();
			a[3] = s.nextInt();
			a[4] = s.nextInt();
			Arrays.sort(a); 
			printReverse(a);
		}
	}

	
	static void printReverse(int[] a) {
		for (int i = a.length - 1; i >= 0; i--) {
			System.out.print(a[i]);
			if (i == 0)
				break;
			System.out.print(" ");
		}
		System.out.println();
	}
}

Measured memory_bytes: 17176
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>

using namespace std;

#define ll long long int
#define pii pair<int,int>
#define ti3 tuple<ll,ll,ll>

struct BIT
{
    std::vector<int> bit;
    
    BIT(int size) : bit(size, 0){ }
    
    void add(int k, int x) {
        while (k < bit.size()) {
            bit[k] += x;
            k += k &-k;
        }
    }
    int sum(int k) {
        int res = 0;
        while (k > 0) {
            res += bit[k];
            k -= k&-k;
        }
        return res;
    }
};

struct UnionFind {
    vector<int> data;
    
    UnionFind(int size) : data(size, -1) { }
    
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y)
        {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

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

Measured memory_bytes: 1152
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stdio.h>
#include <fstream>
#include <cmath>
#include <stdlib.h>
#include <iomanip>
#include <algorithm>
#include <limits.h>
#include <stack>
#include <cmath>
#include <math.h>
#include <array>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false);
#define DEBUG_VIS(x) cerr<<"vis "<<x<<endl;
#define DEBUG_REACH cerr<<"reach here"<<endl;
#define DEBUG_SEQ(x) cerr<<x<<" ";
#define SET_ZERO(x) memset(x,0,sizeof(x));
#define SET_NEGONE(x) memset(x,-1,sizeof(x));
#define SET_INF(x) memset(x,127,sizeof(x));
#define SET_NEGINF(x) memset(x,128,sizeof(x));
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<double,double> pdd;
typedef long long ll;
typedef unsigned int uint;
const int maxn = 1e5 + 10;
template <class T> T mymin(const T a,const T b){return a < b ? a : b;}
template <class T> T mymax(const T a,const T b){return a > b ? a : b;}
int N,M;
vector<int> G[maxn];
int a[maxn],dfn[maxn],vis[maxn],bel[maxn],low[maxn],inst[maxn],sz[maxn],dfs_clock,scc_cnt;
stack<int> S;
void tarjan(int u){
    dfn[u] = low[u] = ++dfs_clock;
    S.push(u);
    inst[u] = 1;
    for(int v : G[u]){
        if(!dfn[v]){
            tarjan(v);
            low[u] = min(low[u],low[v]);
        }
        else if(inst[v]) low[u] = min(low[u],dfn[v]);
    }
    if(low[u] == dfn[u]){
        int v = 0;
        scc_cnt++;
        while(v != u){
            v = S.top();
            S.pop();
            bel[v] = scc_cnt;
            sz[scc_cnt]++;
            inst[v] = 0;
        }
    }
}
int main(){
    FAST_IO
    cin>>N>>M;
    for(int i = 1; i <= N; i++) cin>>a[i];
    for(int i = 1; i <= M; i++){
        int u,v;
        cin>>u>>v;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    for(int i = 1; i <= N; i++) if(!dfn[i]) tarjan(i);
    int ans = 0;
    for(int i = 1; i <= N; i++){
        if(bel[a[i]] == bel[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12160
from itertools import product
a = [0, 0, 0]
N, a[0], a[1], a[2] = list(map(int,input().split()))
l = []
for i in range(N):
  l.append(int(input()))
mm = float("inf")
for p in product(range(4), repeat=N):
  c = [0]*4
  s = [0]*4
  for i in range(N):
    c[p[i]] += 1
    s[p[i]] += l[i]
  if min(c[:3])==0:
    continue
  m = 0
  for j in range(3):
    m += max(0, c[j]-1)*10
    m += abs(a[j]-s[j])
  mm = min(mm, m)
print(mm)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using P = pair<int, int>;

VI oya(101010), rnk(101010);
void init(int n) {
  for (int i = 0; i < n; i++) {
    oya[i] = i;
    rnk[i] = 0;
  }
}
int find(int x) {
  if (oya[x] == x) return x;
  return oya[x] = find(oya[x]);
}
void unite(int x, int y) {
  x = find(x); y = find(y);
  if (x == y) return;
  if (rnk[x] < rnk[y]) {
    oya[x] = y;
  } else {
    oya[y] = x;
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}
bool same(int x, int y) {
  return find(x) == find(y);
}
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  if (m + n / 2 < n - 1) {
    cout << "Impossible" << '\n';
    return 0;
  }
  init(n);
  vector<P> cost(n); for (int i = 0; i < n; i++) {
    cin >> cost[i].first;
    cost[i].second = i;
  }
  sort(cost.begin(), cost.end());
  for (int i = 0; i < m; i++) {
    int x, y; cin >> x >> y;
    unite(x, y);
  }
  map<int, int> mi;
  vector<bool> used(n);
  map<int, int> memo;
  for (int i = 0; i < n; i++) {
    int key = find(cost[i].second);
    if (not mi.count(key) or cost[i].first < mi[key]) {
      mi[key] = cost[i].first;
      memo[key] = cost[i].second;
    }
  }
  int c = mi.size();
  if (c == 1) {
    cout << 0 << '\n';
    return 0;
  }
  lint res = 0;
  for (auto&& i : mi) {
    res += i.second;
    used[memo[i.first]] = true;
  }
  int j = 0;
  for (int i = 0; i < c - 2; i++) {
    while (used[cost[j].second]) {
      j++;
    }
    res += cost[j].first;
    j++;
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

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

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    ll a, b, c, k;
    cin>>a>>b>>c>>k;
    ll d=a-b;
    if (k%2!=0)
    {
        d=-d;
    }
    cout<<d;
    return 0;
}

Measured memory_bytes: 3648
s = input()
a = int(s[0 : 2])
b = int(s[2:])

#print(a, b)
if a<=12 and b<=12 and a>0 and b>0:
  print('AMBIGUOUS')

elif a<=12 and (b == 0 or b > 12) and a > 0:
  print("MMYY")
  
elif b<=12 and b > 0 and (a == 0 or a > 12):
  print("YYMM")
else:
  print("NA")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-9;
int main()
{
  int n,m;
  cin>>n>>m;
  vector<int>v(n);
  int sum=0;
  for(int i=0;i<n;++i)
  {
    cin>>v[i];
    sum+=v[i];
  }
  sort(v.rbegin(),v.rend());
  int cnt=0;
  double r = sum*(1.0/double(4*m));
  //cout<<r<<endl;
  bool ok=false;
  for(int i=0;i<n;++i)
  {
    if(double(v[i])>=r)
    {
      cnt++;
      if(cnt==m)
      {
        ok=true;
        cout<<"Yes"<<endl;
        break;
      }
    }
  }
  if(!ok)
  {cout<<"No"<<endl;}
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[120][120];
int h, w;
bool a[120], b[120];
int main() {
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			scanf(" %c", &s[i][j]);
			if (s[i][j] == '#') {
				a[i] = true;
				b[j] = true;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		if (a[i]) {
			for (int j = 0; j < w; j++) {
				if (b[j]) {
					printf("%c", s[i][j]);
				}
			}
			printf("\n");
		}
	}
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int a, b; cin >> a >> b;
  a--; b--;
  cout << 100 << " " << 100 << endl;
  vector<string> v(100);
  REP(i, 100) {
    REP(j, 100) {
      if(j < 50)v[i].pb('#');
      else v[i].pb('.');
    }
  }
  

  int cnta = 0;
  P posa = make_pair(0, 0);
  while(cnta < a) {
    v[posa.fi][posa.se] = '.';
    if(posa.se != 48) posa.se += 2;
    else {
      posa.fi += 2;
      posa.se = 0;
    }
    cnta++;
  }

  int cntb = 0;
  P posb = make_pair(0, 51);
  while(cntb < b) {
    v[posb.fi][posb.se] = '#';
    if(posb.se != 99) posb.se += 2;
    else {
      posb.fi += 2;
      posb.se = 51;
    }
    cntb++;
  }

  REP(i, 100) {
    REP(j, 100) {
      cout << v[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, B[101];
//---------------------------------------------------------------------------------------------------
int used[101];
vector<int> solve() {
    vector<int> ans;

    rep(i, 0, N) {
        int cn = 1;
        int cand = -1; int an = -1;
        rep(j, 0, N) if(!used[j]) {
            if(cn == B[j]) cand = j, an = B[j];
            cn++;
        }
        if(cand < 0) return {};
        ans.push_back(an);
        used[cand] = 1;
    }

    reverse(all(ans));
    return ans;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> B[i];

    auto v = solve();
    if(v.size() == 0) cout << -1 << endl;
    else {
        fore(i, v) printf("%d\n", i);
    }
}

Measured memory_bytes: 256
N=gets.to_i
(1..3500).each do |h|
    (h..3500).each do |n|
        d = 4*h*n - n*N - h*N
        next if d <= 0
        if h*n*N % d == 0
            w = h*n*N / d
            puts "#{h} #{n} #{w}"
            exit
        end
    end
end


Measured memory_bytes: 14384
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

inline
int gcd(int a, int b)
{
    if (a < b) swap(a, b);
    if (b == 0){
        return a;
    }else{
        return gcd(b, a % b);
    }
}

int main()
{
    scanInt(N);
    scanInt(K);
    scanVecInt(A, N);
    sort(A.begin(), A.end());
    if (A.back() < K){
        puts("IMPOSSIBLE");
        return 0;
    }
    if (binary_search(A.begin(), A.end(), K)){
        puts("POSSIBLE");
        return 0;
    }
    int g = A[0];
    for (int i = 1; i < N; ++i){
        g = gcd(g, A[i]);
        if (g == 1) break;
    }
    if (K % g == A.back() % g){
        puts("POSSIBLE");
    }else{
        puts("IMPOSSIBLE");
    }
}


Measured memory_bytes: 640
use std::io;

fn main() {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s);

    let num = s.trim_right().parse::<usize>().unwrap();

    let mut v = vec![num];
    let mut i = 0;
    loop {
        let num = v[i];

        let x = if is_even(num) {
            even_func(num)
        } else {
            odd_func(num)
        };
        if v.contains(&x) {
            println!("{}", i + 2);
            break;
        }

        v.push(x);
        i += 1;
    }

}

fn is_even(num: usize) -> bool {
    num % 2 == 0
}

fn even_func(num: usize) -> usize {
    num / 2
}

fn odd_func(num: usize) -> usize {
    3 * num + 1
}

Measured memory_bytes: 4352
// 用復習
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
 int g[15][15];
 int n;
 cin>>n;
 rep(i,n) rep(j,n) g[i][j]=-1;
  rep(i,n){
    int m;
    cin>>m;
    rep(j,m){
    	int a,x;
        cin>>a>>x;
      	a--;
      	g[i][a]= x;
    }
  }
  int ans=0;
  rep(i,1<<n){
  	vector<int>d(n);
    rep(j,n) if(i>>j &1){
    	d.at(j)=1;
    }
    bool ok=true;
    rep(j,n){
    	if(d.at(j)==1){
        	rep(k,n){
            	if(g[j][k]==-1) continue;
              	if(g[j][k] != d.at(k)) ok=false;
            }
        }
    }
    if(ok) ans =max(ans,__builtin_popcount(i));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	ll n,l=0,ans=1;
	const ll mod = 998244353;

	map<ll, ll> m;
	in(n);

	vll d(n);
	in(d[0]);
	if (d[0] != 0) {
		outn(0);
		return 0;
	}
	m[0] = 1;

	rep(i, 1, n) {
		in(d[i]);
		if (d[i] == 0) {
			outn(0);
			return 0;
		}
		l = max(l, d[i]);
		m[d[i]]++;
	}

	repeq(i, 1, l) {
		if (m[i] == 0) {
			outn(0);
			return 0;
		}
		
		ll tmp = 1;
		rep(j, 0, m[i]) {
			tmp = (tmp * m[i - 1]) % mod;
		}

		ans = (ans * tmp)%mod;
	}

	outn(ans);

	return 0;


}


Measured memory_bytes: 7296
#abc177 d
import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))
frend=[[] for _ in range(N+1)]
for _ in range(M):
    A,B=list(map(int,input().split()))
    frend[A].append(B)
    frend[B].append(A)

#仲間グループを作る
group=[0]*(N+1)
q = collections.deque([])
no_seen = set(range(1,N+1))
No=0
while no_seen:
    q.append(no_seen.pop())
    No += 1
    while q:
        now = q.popleft()
        group[now]=No
        for member in frend[now]:
            if member in no_seen:
                q.append(member)
                no_seen.discard(member)

gc=collections.Counter(group)
print(gc.most_common()[0][1])                
    


Measured memory_bytes: 134428
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <random>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define pi 3.141592653589793
#define prique priority_queue
constexpr auto mod=1000000007;
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int n){
    int cnt=0;
    for(int i=1;i<=sqrt(n);i++){
        if(n%1==0)cnt++;
    }
    if(cnt!=1) return false;
    else return n!=1;
}
struct UnionFind{
    vector<int> r;
    UnionFind(int N){
        r=vector<int>(N,-1);
    }
    int root(int x){
        if(r[x]<0) return x;
        return r[x]=root(r[x]);
    }
    bool unite(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(r[x]>r[y]) swap(x,y);
        r[x]+=r[y];
        r[y]=x;
        return true;
    }
    int size(int x){
        return -r[root(x)];
    }
};
vector<int> v;
int n,m,cnt=0,ans=0,aa[220000];
pair<int,int> pp[220000];
string s,ss[220000];
queue<int> que;
signed main(){
    cin>>n>>m>>cnt>>ans;
    cout<<max({n*cnt,m*ans,n*ans,m*cnt});
}

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

int main() {
  string memo;
  cin >> memo;
  int sum = 700;

  if (memo[0] == 'o') sum += 100;
  if (memo[1] == 'o') sum += 100;
  if (memo[2] == 'o') sum += 100;

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


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

signed main(void)
{
	string s;
	cin >> s;
	char c[] ="CF";
	int j = 0;
	rep(i, s.size())
	{
		if (s[i] == c[j])
		{
			j++;
			if (j == 2)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include <vector>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {

    int A, B;

    cin >> A;
    cin >> B;

    if (B % A == 0) {
        cout << A + B << endl;
    } else {
        cout << B - A << endl;

    }
}

Measured memory_bytes: 256
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/
 
#include <bits/stdc++.h>
using namespace std;
 
 
#define ll                          long long
#define ld                          long double
 
#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second
 
#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
#define  MN                           INT_MIN
#define  MX                           INT_MAX

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

int32_t main()
{
	ll a,b;
	cin >> a >> b;
	ll ans = (a+b) / 2;
	if((a+b)%2==0){
		cout << ans << endl;
	}else{
		cout << "IMPOSSIBLE";
	}
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int n;
vector<lint> a, sum, osum, esum;

bool check(int mid, lint x){
    int l = lower_bound(a.begin(), a.end(), x * 2LL - a[mid]) - a.begin();
    l = max(l, 1);
    return mid - l + 1 <= n - mid;
}

int meguru_search(int ok, int ng, lint x){
    while(abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if(check(mid, x)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    return ok;
}

lint query(lint x){
    int ar = meguru_search(0, n, x);
    int al = max(ar * 2 - n, 0);
    lint res = sum[n] - sum[ar] + (al % 2 == 0 ? esum[al] : osum[al]);
    return res;
}

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

    int Q;
    cin >> n >> Q;

    a.resize(n + 1);
    REP(i, 1, n + 1){
        cin >> a[i];
    }

    sum.resize(n + 1);
    osum.resize(n + 1);
    esum.resize(n + 1);
    REP(i, 1, n + 1){
        sum[i] = sum[i - 1] + a[i];
        osum[i] = osum[i - 1] + (i % 2 == 1 ? a[i] : 0);
        esum[i] = esum[i - 1] + (i % 2 == 0 ? a[i] : 0);
    }

    rep(q, Q){
        lint x;
        cin >> x;
        lint ans = query(x);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4864
n, m = (int(i) for i in input().split())
a = [int(i) for i in input().split()]

acc = 0
l = []
for x in a:
    acc += x
    l.append(acc%m)

dic = {}
res = 0
for x in l:
    if x in dic:
        res += dic[x]
        dic[x] += 1
    else:
        dic[x] = 1

    if x == 0:
        res += 1


print(res)



Measured memory_bytes: 63640
import sys
input = sys.stdin.readline

N, X = map(int, input().split())
S = list(map(int, input().split()))
mod = 10**9 + 7
S.sort(reverse=True)
dp = [0] * (X+1)
dp[X] = 1
for i in range(N):
    ndp = dp[:]
    for j in range(X+1):
        # not use
        ndp[j] = ndp[j] * (N - i - 1) % mod
        # use
        ndp[j % S[i]] = (ndp[j % S[i]] + dp[j]) % mod
    dp = ndp
ans = 0
for j in range(X+1):
    ans = (ans + dp[j] * j) % mod
print(ans)

Measured memory_bytes: 213812
#include <stdio.h>


int main() {
	long long A, B, AB, X, Y, cost, costuri[6];

	scanf("%lld %lld %lld %lld %lld", &A, &B, &AB, &X, &Y);
	
	costuri[0] = X * A + Y * B;
	costuri[1] = X * 2 * AB + Y * B;
	costuri[2] = X * A + Y * 2 * AB;
	costuri[3] = X * 2 * AB + Y * 2 * AB;
	
	if (Y >= X) {
		costuri[4] = X * 2 * AB + (Y - X) * B;
		costuri[5] = X * 2 * AB + (Y - X) * 2 * AB;
	} else {
		costuri[4] = (X - Y) * A + Y * 2 * AB;
		costuri[5] = (X - Y) * 2 * AB + Y * 2 * AB;
	}
	
	cost = costuri[0];
	
	for (int i = 1; i < 6; i++) {
		if (costuri[i] < cost) {
			cost = costuri[i];
		}
	}
	
	printf("%lld\n", cost);

	return 0;
}

Measured memory_bytes: 128