akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAX_N=3e2+10;
const ll INF=1e18+10;

ll dp[MAX_N][MAX_N][MAX_N],H[MAX_N];
int N,K,M;

int main(){
	for(int i=0;i<MAX_N;i++) for(int j=0;j<MAX_N;j++) for(int k=0;k<MAX_N;k++)
		dp[i][j][k]=INF;
	scanf("%d%d",&N,&K); M=N;
	for(int i=0;i<N;i++) scanf("%d",&H[i]);
	bool flag=false;
	for(int i=0;i<N;i++) if(H[i]==0) flag=true;
	if(!flag) H[M++]=0;
//	for(int i=0;i<M;i++) printf("%d ",H[i]); printf("\n");
	dp[0][0][0]=H[0];
	if(K>0) for(int i=1;i<=N;i++) dp[0][1][i]=H[i];
	for(int i=1;i<N;i++){
		dp[i][0][i]=min(dp[i][0][i],dp[i-1][0][i-1]+(H[i]>H[i-1]?H[i]-H[i-1]:0));
		for(int j=1;j<=K;j++){
			for(int k=0;k<M;k++){
			//	cout<<dp[i][j][k]<<endl;
				if(i==k){
					for(int fr=0;fr<M;fr++)
						dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][fr]+(H[i]>H[fr]?H[i]-H[fr]:0));
				}
				else{			
					dp[i][j][k]=min(dp[i][j][k],dp[i-1][j-1][k]);	
					//	dp[i][j][k]=min(dp[i][j][k],dp[i-1][j-1][i-1]);
				}
			//	cout<<dp[i][j][k]<<endl;
			}
		}
	}
	ll ans=INF;
	for(int i=0;i<=K;i++) for(int j=0;j<M;j++)
		ans=min(ans,dp[N-1][i][j]);
	printf("%lld\n",ans);
	return 0;
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll n,k;
    char tapu;
    string s;
    cin >> n >> s >> k;
    rep(i,n){
        if(i+1==k) tapu = s[i];
    }
    rep(i,n){
        if(s[i]!=tapu) cout << '*';
        else cout << s[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int S; cin >> S; 
	long long mod = 1000000007; 
	long long B[3010][3010] = {}; 
	B[0][0] = 1; 
	for(int i = 0; i < 3005; i++){
		for(int j = 0; j <= i; j++){
			B[i+1][j] += B[i][j]; 
			B[i+1][j+1] += B[i][j]; 
			if(B[i+1][j] >= mod) B[i+1][j] -= mod; 
			if(B[i+1][j+1] >= mod) B[i+1][j+1] -= mod;
		}
	}
	long long ans = 0; 
	for(int d = 1; d < 700; d++){
		if(S < d*3) break; 
		int sum = S - d*3; 
		ans += B[d+sum-1][sum]; 
		ans %= mod; 
	}
	cout << ans << "\n"; 
}

Measured memory_bytes: 74408
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def f(A, B, C):
    for _ in range(3):
        A, B, C = B, C, A
        if A % 2 == 0:
            yield 0
        yield B * C

A, B, C = map(int, read().split())
print(min(f(A, B, C)))

Measured memory_bytes: 8988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int A,B,C,X,Y; cin>>A>>B>>C>>X>>Y;
    ll ans=INF;
    rep(i,max(X,Y)+1){
        if(ans>2*C*i+A*max(0,X-i)+B*max(0,Y-i))ans=2*C*i+A*max(0,X-i)+B*max(0,Y-i);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main() {
	string s;

	cin >> s;

	bool flag[2] = { false,false };

	if (s[0] == '0' && s[1] != '0' || (s[0] == '1' && s[1] <= '2')) {
		flag[0] = true;
	}
	if (s[2] == '0' && s[3] != '0' || (s[2] == '1' && s[3] <= '2')) {
		flag[1] = true;
	}
	
	switch (flag[0] * 2 + flag[1]) {
	case 0:
		cout << "NA";
		break;
	case 1:
		cout << "YYMM";
		break;
	case 2:
		cout << "MMYY";
		break;
	case 3:
		cout << "AMBIGUOUS";
		break;
	}

}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n + 2), d(n + 1), sd(n);
    rep(i, n) cin >> a[i + 1];

    int sum = 0;
    rep(i, n + 1) {
        d[i] = abs(a[i + 1] - a[i]);
        sum += d[i];
    }

    rep(i, n)
        sd[i] = abs(a[i + 2] - a[i]);

    rep(i, n) {
        cout << sum - d[i] - d[i + 1] + sd[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 4572
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <deque>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;
const ll MOD = 1000000007;

int n;
int X, Y, Z;
int XYZ;
int maxi;
// typedef pair<int,deque<int> > K;
typedef pair<int, ll> K;

bool isOK(const deque<int>& vs) {
  int as[] = {X, Y, Z};
  int i = 0;
  for(int v : vs) {
    if(i >= 3) {
      return false;
    }
    as[i] -= v;
    if(as[i] < 0) {
      return false;
    } else if(as[i] == 0) {
      ++i;
    }
  }
  return i == 3;
}

bool isPossible(const deque<int>& vs) {
  int as[] = {X, Y, Z};
  int i = 0;
  for(int v : vs) {
    if(i >= 3) {
      return false;
    }
    as[i] -= v;
    if(as[i] < 0) {
      return false;
    } else if(as[i] == 0) {
      ++i;
    }
  }
  return i <= 3;
}

ll mypow(ll x, ll n) {
  if(n == 0) {
    return 1;
  } else if(n % 2 == 0){
    return mypow(x*x%MOD, n/2);
  } else {
    return mypow(x*x%MOD, n/2)*x%MOD;
  }
}

ostream& operator<<(ostream& out, const deque<int>& vs) {
  out << "{";
  for(int v : vs) {
    out << v << ",";
  }
  return out << "}";
}

ll encode(const deque<int>& vs) {
  ll res = 0;
  ll t = 1;
  for(int v : vs) {
    res = res + (v-1)*t;
    t *= 10;
  }
  return res + t*9;
}

map<K, ll> memo;
ll solve(int rest, const deque<int>& vs, int sum) {
  //  K key(rest, vs);
  K key(rest, encode(vs));
  if(memo.count(key)) {
    return memo[key];
  }
  ll res = 0;
  if(rest > 0) {
    // deque<int> vvs = vs;
    // int ssum = sum;
    // while(!vvs.empty() && (ssum > XYZ || !isPossible(vvs))) {
    //   ssum -= vvs.front();
    //   vvs.pop_front();
    // }
    for(int cur = 1; cur <= 10; ++cur) {
      deque<int> nextVs;
      int nextSum;
      if(cur > maxi) {
        nextVs = deque<int>();
        nextSum = 0;
      } else {
        nextVs = vs;
        nextSum = sum;
        nextVs.push_back(cur);
        nextSum += cur;
        while(!nextVs.empty() && (nextSum > XYZ || !isPossible(nextVs))) {
          nextSum -= nextVs.front();
          nextVs.pop_front();
        }
      }
      if(nextSum == XYZ) {
        res = (res + mypow(10, rest-1)) % MOD;
      } else {
        res = (res + solve(rest-1, nextVs, nextSum)) % MOD;
      }
    }
  }
  // if(res > 0 && rest == 3) {
  //   cerr << "solve(" << rest << "," << vs << ") = " << res << endl;
  // }
  return memo[key] = res;
}

int main(void) {
  int n;
  scanf("%d%d%d%d", &n, &X, &Y, &Z);
  maxi = max(max(X, Y), Z);
  XYZ = X + Y + Z;
  deque<int> vs;
  ll res = solve(n, vs, 0);
  printf("%lld\n", res);
  
  return 0;
}


Measured memory_bytes: 37248
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;
int n;
int p[20010],a[20010],b[20010],num[20010];
int main(){
	scanf("%d",&n);
	int i,j;
	for(i=1;i<=n;++i){
		scanf("%d",&p[i]);num[p[i]]=i;
	}
	for(i=1;i<=n;++i){
		a[i]=i*30000;b[i]=(n+1-i)*30000;
	}
	for(i=1;i<=n;++i)  a[i]=a[i]+num[i];
	for(i=1;i<n;++i)  printf("%d ",a[i]);
	printf("%d\n",a[n]);
	for(i=1;i<n;++i)  printf("%d ",b[i]);
	printf("%d\n",b[n]);
	return 0;
}

Measured memory_bytes: 896
edge = []
n, q = map(int, input().split())
for _ in range(n+100):
    edge.append([])
for _ in range(n-1):
    a,b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)
res = [0] * (n+1)
cost = [0] * (n+1)
for _ in range(q):
    a,b = map(int, input().split())
    res[a] += b

import collections
q = collections.deque([[1, 0]])
used = [False] * (n+1)
while len(q) > 0:
    #print(q)
    curnode, cost = q.popleft()
    res[curnode] += cost
    used[curnode] = True
    for i in range(len(edge[curnode])):
        nnext = edge[curnode][i]
        if used[nnext] is True:
            continue
        else:
            q.append([nnext, res[curnode]])
res=res[1:]
print(" ".join(list(map(str, res))))


Measured memory_bytes: 127564
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L() {}
};
typedef vector<P> G;
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

double area(const G& g) {
  double A = 0;
  for (int i = 0; i < g.size(); ++i) {
    A += cross(g[i], next(g, i));
  }
  return A/2;
}
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}

G convex_cut(const G& g, const L& l) {
  G Q;
  REP(i, g.size()) {
    P A = curr(g, i), B = next(g, i);
    if (ccw(l[0], l[1], A) != -1) Q.push_back(A);
    if (ccw(l[0], l[1], A)*ccw(l[0], l[1], B) < 0)
      Q.push_back(crosspoint(L(A, B), l));
  }
  return Q;
}

int main() {
  int n;
  while(cin>>n,n) {
    G g(n);
    REP(i, n) {
      double x, y;
      cin >> x >> y;
      g[i] = P(x,y);
    }
    double S = area(g)/2;
    double a = 0, b = PI;
    REP(i, 100) {
      double c = (a+b) / 2;
      double fa = S-area(convex_cut(g, L(P(0,0), P(cos(a), sin(a)))));
      double fc = S-area(convex_cut(g, L(P(0,0), P(cos(c), sin(c)))));
      if (fa*fc>0) {
        a = c;
      } else {
        b = c;
      }
    }
    double ax = cos(a)*100;
    double ay = sin(a)*100;
    printf("%.15f %.15f\n", ax, ay);
  }
}

Measured memory_bytes: 1012
// Date: 2020-04-27

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

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define IO freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout)
#define FIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define D(x) cout << #x << " = " << x << endl;
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
template <typename T> void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> void chkmin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int a[N], n;
int main() {
    FIO;
    cin >> n;
    rep(i, 1, n) cin >> a[i];
    sort(a+1, a+1+n);
    int ans1 = a[n], ans2 = a[1], cur = min(abs(a[1]-a[n]/2), abs(a[1]-(a[n]+1)/2));
    rep(i, 2, n-1) {
        int tp = min(abs(a[i]-a[n]/2), abs(a[i]-(a[n]+1)/2));
        if(tp < cur) ans2 = a[i], cur = tp;
    }
    cout << ans1 << " " << ans2;


    return 0;
}

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

int main(){
  int x;
  cin >> x;
  int nums[x];
  int tmp;
  for (int i = 0; i < x; i++){
    cin >> tmp;
    nums[i] = tmp;
  }
  
  for (int i = 0; i < x; i++){
    int b = x - (i + 1);
    if(b == 0){
      cout << nums[b];
    }else{
      cout << nums[b] << " ";
    }
    
  }
  cout << endl;
  
}


Measured memory_bytes: 3108
#import<atcoder/all>
using namespace std;int n,i,k;int main(){cin>>n>>k;vector<int>a(n),b;for(;i<n;a[i++]=k)cin>>k;for(;cin>>i;)b.push_back(i);for(int i:atcoder::convolution(a,b))cout<<i<<' ';}

Measured memory_bytes: 19048
#include <bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  string b = "YAKI";
  for (int i = 0; i < 4; i++) {
    if (a[i] != b[i]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 256
H = int(input())
A = [0]
# A = [int(i) for i in input().split()]
s = input().split()
for si in s:
    A.append(int(si))


def parent(i):
    return i // 2


def left(i):
    return 2 * i


def right(i):
    return 2 * i + 1


def max_heapify(a, i):
    l = left(i)
    r = right(i)
    if l <= H and a[l] > a[i]:
        largest = l
    else:
        largest = i

    if r <= H and a[r] > a[largest]:
        largest = r

    if largest != i:
        a[i], a[largest] = a[largest], a[i]
        max_heapify(a, largest)


def build_max_heap(a):
    for i in range(H // 2, 0, -1):
        max_heapify(a, i)


build_max_heap(A)
print("", " ".join([str(i) for i in A[1:]]))



Measured memory_bytes: 99736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6+5;
const ll mod = 1e9+7;
vector<int>e[maxn];
int c[maxn];
int p[maxn];
int res;
void dfs(int pos,int fa)
{
    p[pos] = c[res];res--;
    for(int i = 0; i < e[pos].size(); ++i)
    {
        int nowpos = e[pos][i];
        if(nowpos == fa)continue;
        dfs(nowpos,pos);
    }
}
int main()
{
    int n;
    while(cin>>n)
    {
        //cout<<"xx"<<endl;
        for(int i = 1; i <= n; ++i)e[i].clear();
        for(int i = 1; i < n; ++i)
        {
            int x,y;
            cin>>x>>y;
            e[x].push_back(y);
            e[y].push_back(x);
        }
        int ans = 0;
        for(int i = 0; i < n; ++i)
            cin>>c[i],ans += c[i];
        sort(c,c+n);ans -= c[n-1];
        res = n-1;
        //cout<<"xx"<<endl;
        dfs(1,-1);
        cout<<ans<<endl;
        //cout<<"xx"<<endl;
        for(int i = 1; i <= n; ++i)
        {
            cout<<p[i];
            if(i == n)cout<<endl;
            else cout<<" ";
        }
    }
}





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

int main() {
  int t,y;
  cin >> t >> y;
  vector<vector<char>>a(t,vector<char>(y));
  for(int i=0;i<t;i++){
    for(int j=0;j<y;j++) cin >> a.at(i).at(j);
  }
  
  //横に同じのが連なった場合の処理。
  for(int i=0;i<t;i++){
    bool eq=false;
    
    for(int j=0;j<y;j++){
      if(a.at(i).at(j)=='#'){
        eq=true;
        break;
      }
    }
    
    if(eq==false){
      for(int k=i;k<t-1;k++) a.at(k)=a.at(k+1);
      for(int l=0;l<y;l++) a.at(t-1).at(l)='.';      //←a.at(t-1)=(y,'.');
      a.pop_back();         /*←やりたいのは、全て'.'の行をラストに→ラストの行削除
                               そのために一個ずつずらす。*/
      i--;                //iの位置が一個ずつずれる（はず）なのでi--する
      t--;
         }
    
  }
  
  //縦に同じのが連なった場合の処理。
  for(int j=0;j<y;j++){
    bool eq=false;
      
    for(int i=0;i<t;i++){
      if(a.at(i).at(j)=='#'){
        eq=true;
        break;
      }
    }
    
    if(eq==false){
      for(int i=0;i<t;i++){
        swap(a.at(i).at(j),a.at(i).at(y-1));
        for(int k=j;k<y-2;k++){
          swap(a.at(i).at(k),a.at(i).at(k+1));
        }
        a.at(i).pop_back();
      }
      j--;
      y--;
    }
    
  }
  
  //あとは出力！
  for(int i=0;i<t;i++){
    for(int j=0;j<y;j++){
      if(j==y-1) cout << a.at(i).at(j) << endl;
      else cout << a.at(i).at(j);
    }
  }
}

Measured memory_bytes: 256
MOD = 10**9 + 7
k = int(input())
s = input()
n = len(s)

MAX = 2 * 10**6 + 5
fact = [1] * (MAX + 1)  # i!
finv = [1] * (MAX + 1)  # (i!)^{-1}
iinv = [1] * (MAX + 1)  # i^{-1}
for i in range(2, MAX + 1):
    fact[i] = fact[i - 1] * i % MOD
    iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * iinv[i] % MOD


def comb(n: int, k: int) -> int:
    if n < k or n < 0 or k < 0:
        return 0
    return (fact[n] * finv[k] % MOD) * finv[n - k] % MOD


ans = 0
for i in range(k + 1):
    ans += comb(n + k - i - 1, k - i) * pow(25, k - i, MOD) % MOD * pow(
        26, i, MOD) % MOD
    ans %= MOD

print(ans)


Measured memory_bytes: 117580
import java.util.Scanner;
class Main{


	static char[][] map;

	static long[][] c;
	static int ans;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		long n = sc.nextLong();
		
		for(long i = 1 ;i*i <= n;i++){
			if(i*i == n){
				System.out.println((i-1)*2);
				return;
			}
		}
		for(long i = (long)Math.sqrt(n);i >= 1;i--){
			if(n%i == 0){
				System.out.println(i-1+(n/i)-1);
				break;
			}
		}
		


	}
	
//	static void dfs(int y,int x,int num,int count){
//		if((y+1)*(x+1) > num){
//			return;
//		}
//		if((y + 1)*(x+1) == num){
//			ans = Math.min(ans, count);
//			return;
//		}
//		
//		if(y + 1 <= )
//		dfs(y+1, x, num, count);
//		
//	}

	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}
	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



	static long lcm (long a, long b) {
		long g = gcd(a,b);
		return a/g*b;
	}




}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return   end- otherpair.end;
	}








}






Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;while(t--)
#define pb push_back
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(int i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
#define vinn(n,v) int n;cin>>n;vector<int>v(n);loop(i,0,n)cin>>v[i];
#define vinm(n,m,v) int n,m;cin>>n>>m;vector<int>v(n);loop(i,0,n)cin>>v[i];
#define debug(x) cerr<<#x<<" : "<<x<<endl;
mt19937 rd(time(0)); // i = rd%n
signed main() 
{
    fastio();

    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;


    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC114
{
    class C
    {
        static int res = 0;
        static long N = 0;
        static void Main(string[] args)
        {
            N = long.Parse(Console.ReadLine());
            // dfsの呼び出し
            dfs("0");
            Console.WriteLine(res);
        }

        static void dfs(string s)
        {
            if (long.Parse(s) > N) return;

            if (0 < s.Count(x => x == '7') && 0 < s.Count(x => x == '5') && 0 < s.Count(x => x == '3'))
            {
                res++;
            }

            foreach (char c in "753")
            {
                dfs(s + c);
            }
        }


    }
}


Measured memory_bytes: 15312
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,_max,a[N];
bool check(int co,int n){
	if(co<0)	return false;
	if(!n)	return true;
	if(!co)	return false;
	if(co*2>n)	return false;
	return true;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		_max=max(_max,a[i]);
	}
	for(int i=1;i<=n;i++)
		if(a[i]<_max-1){
			puts("No");
			return 0;
		}
	int k=0;
	for(int i=1;i<=n;i++)
		if(a[i]==_max-1)	++k;
	if(check(_max-k,n-k)||(!k&&_max==n-1))	puts("Yes");
	else	puts("No");
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
typedef long long lint;
const int N=2e5+5;
int n,q;
struct node{
	int pos;
	lint s,f;
};

template <class T> inline void apn(T &x,const T y){
	if(x>y) x=y;
}
inline node merge(const node &a,const node &b){
	return (node){a.s<b.s?a.pos:b.pos,std::min(a.s,b.s)};
}

struct SGT{
	int x,y;
	lint v;
	node tr[N<<1];
	inline int idx(const int l,const int r){
		return (l+r)|(l!=r);
	}
	inline void upd(const int l,const int r){
		const int mid=(l+r)>>1;
		tr[idx(l,r)]=merge(tr[idx(l,mid)],tr[idx(mid+1,r)]);
	}
	inline void psh_f(const int k,const lint v){
		tr[k].f+=v,tr[k].s+=v;
	}
	inline void psh(const int l,const int r){
		const int k=idx(l,r);
		if(l!=r&&tr[k].f){
			const int mid=(l+r)>>1;
			psh_f(idx(l,mid),tr[k].f);
			psh_f(idx(mid+1,r),tr[k].f);
			tr[k].f=0;
		}
	}
	void build(const int l,const int r){
		const int k=idx(l,r);
		if(l==r){
			tr[k]=(node){l,(lint)1e14};
			return;
		}
		const int mid=(l+r)>>1;
		build(l,mid);
		build(mid+1,r);
		upd(l,r);
	}
	node ask(const int l,const int r){
		psh(l,r);
		const int k=idx(l,r);
		if(l>=x&&r<=y) return tr[k];
		const int mid=(l+r)>>1;
		if(y<=mid) return ask(l,mid);
		if(x>mid) return ask(mid+1,r);
		return merge(ask(l,mid),ask(mid+1,r));
	}
	void mod(const int l,const int r){
		psh(l,r);
		const int k=idx(l,r);
		if(l>=x&&r<=y){
			psh_f(k,v);
			return;
		}
		const int mid=(l+r)>>1;
		if(x<=mid) mod(l,mid);
		if(y>mid) mod(mid+1,r);
		upd(l,r);
	}
	void mod1(const int l,const int r){
		psh(l,r);
		const int k=idx(l,r);
		if(l==x&&r==x){
			apn(tr[k].s,v);
			return;
		}
		const int mid=(l+r)>>1;
		if(x<=mid) mod1(l,mid);
		else mod1(mid+1,r);
		upd(l,r);
	}
	inline node ask_t(const int a,const int b){
		x=a,y=b;
		return ask(1,n);
	}
	inline void mod_t(const int l,const int r,const lint val){
		x=l,y=r,v=val;
		mod(1,n);
	}
	inline void mod1_t(const int a,const lint val){
		x=a,v=val;
		mod1(1,n);
	}
}tr_up,tr_dn;

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

int main(){
#ifndef ONLINE_JUDGE
//	freopen("c.in","r",stdin);
#endif
	n=nxi(),q=nxi();
	tr_up.build(1,n);
	tr_dn.build(1,n);
	const int q1=nxi(),q2=nxi();
	int lst=q1;
	tr_up.mod1_t(q2,q2);
	tr_dn.mod1_t(q2,n-q2+1);
	for(int i=1;i<=q;++i){
		const int mov=nxi(),step=abs(lst-mov);
		const node ans_l=tr_dn.ask_t(1,mov);
		const node ans_r=tr_up.ask_t(mov,n);
		const lint ans=std::min(ans_l.s-(n-mov+1),ans_r.s-mov);
		tr_up.mod_t(1,n,step);
		tr_dn.mod_t(1,n,step);
		tr_up.mod1_t(lst,ans+lst);
		tr_dn.mod1_t(lst,ans+(n-lst+1));
		lst=mov;
	}
	lint ans=1e14;
	for(int i=1;i<=n;++i){
		apn(ans,tr_up.ask_t(i,i).s-i);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 18944
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define FORE(i, a, b) for(int i = a; i <= b; ++i)
#define FORD(i, a, b) for(int i = a; i >= b; --i)
#define El "\n"
typedef long long int ll;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<s.size();i++)
	{
	    if(s[i]=='+')
	    ans++;
	    else
	    ans--;
	}
	cout<<ans;
	return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// 結果を入れたmapを返します
map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i <= sqrt(n); i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  // 2以上で割り切れなかったら
  if (n != 1) ret[n] = 1;
  return ret;
}

// ====================================================================

int main() {
  ll n;
  cin >> n;
  map<ll, ll> m;
  for (ll i = 1; i <= n; i++) {
    map<ll, int> res = prime_factor(i);
    for (auto p : res) {
      m[p.first] += p.second;
    }
  }
  ll ans = 1;
  for (auto x : m) {
    ans = ans * (x.second + 1) % MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
using LL = long long;
const int mod = 1e9 + 7;
const int N = 200000 + 5;
int f[N], finv[N], inv[N];

void init()
{
	inv[1] = 1;
	for (int i = 2; i < N; ++i)
		inv[i] = (mod - mod / i) * 1LL * inv[mod % i] % mod;
	f[0] = finv[0] = 1;
	for (int i = 1; i < N; ++i)
	{
		f[i] = f[i - 1] * 1LL * i % mod;
		finv[i] = finv[i - 1] * 1LL * inv[i] % mod;
	}
}

int comb(int n, int m)//c(n, m)
{
	if (m < 0 || m > n) return 0;
	return f[n] * 1LL * finv[n - m] % mod * finv[m] % mod;
}

int main()
{
	//init();
	LL n, k;
	cin >> n >> k;//n + 1个数

	LL sum = 0;
	
	for (int i = k; i <= n + 1; ++i)
	{
		LL a = 0, b = i - 1, c = n - i + 1, d = n;
		LL x = (a + b) * i / 2, y = (c + d) * i / 2;
		sum = (sum + y - x + 1) % mod;
	}
	cout << sum << endl;
	return 0;
}

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

#define repo(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;

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

    int Q;
    cin >> Q;
//     cout << "Q : " << Q <<  endl;
    bool isreverse = false;

    deque<char> s;

    for(auto c : S) s.emplace_back(c);
    int t;
    int f;
    char c;
    for(int i = 0; i < Q; i++){
//         cout << i << "版目" << endl; 
        cin >> t;

        if(t == 1){
           isreverse = !isreverse;
        }else{
            cin >> f >> c;

            if(f == 1){
                if(isreverse){
                    s.emplace_back(c);
                }else{
                    s.emplace_front(c);
                }
            }else{
                if(isreverse){
                    s.emplace_front(c);
                }else{
                    s.emplace_back(c);
                }
            }
        }
    }

    if(isreverse){
      reverse(s.begin(), s.end());
    }
    string ans;
   for(auto ss : s) ans+=ss; 
    
   cout << ans << endl; 
    return 0;
}



Measured memory_bytes: 1412
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader() {
			br =  new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while(st==null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
					
				}
				catch(IOException e) {
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static void main(String[] args) {
		FastReader ob = new FastReader();
		long n=ob.nextLong(),a=ob.nextLong(),b=ob.nextLong();
		long q=n/(a+b),r=n%(a+b);
		long ans=(q*a);
		if(a<r) {
			ans+=a;
		}
		else if(a>=r && a!=0) {
			ans+=r;
		}
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
int getSum(int n) 
 { 
    int sum; 
  
    /* Single line that calculates sum */
    for (sum = 0; n > 0; sum += n % 10, n /= 10); 
  
    return sum; 
 }
//--main function
int main(){
	int n,a,b,s=0;
	cin>>n>>a>>b;
	REP(i,1,n){
		if(getSum(i)>=a && getSum(i)<=b)s+=i;
	}
	cout<<s;
	return 0;

//   TimeTaken();
}


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

N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = -10**18

for i in range(N):
    now = i
    visit = [False]*N
    visit[now] = True
    l = []
    
    while True:
        nex = P[now]-1
        l.append(C[nex])
        
        if visit[nex]:
            break
        
        visit[nex] = True
        now = nex
    
    s = sum(l)
    acc = 0
    
    for j in range(min(K, len(l))):
        acc += l[j]
        ans = max(ans, acc+max(0, (K-j-1)//len(l)*s))

print(ans)

Measured memory_bytes: 86340
package main

import(
	"bufio"
	"os"
	"strings"
	"fmt"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	num := strings.Split(sc.Text(), "")
	if (num[0] == num[1] && num[1] == num[2]) || (num[1] == num[2] && num[2]== num[3]) {
		fmt.Printf("Yes")
	} else {
		fmt.Printf("No")
	}
}

Measured memory_bytes: 640
li = int(input())
a = li//100
b = li-a*100
p = 0
q = 0
if 0<a<13:
    p=1
if 0<b<13:
    q=1
if p==1 and q==1:
    print("AMBIGUOUS")
elif p==1:
    print("MMYY")
elif q==1:
    print("YYMM")
else:
    print("NA")

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

int main(){
    ll n, ans=999999999, inf=999999999;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    ll m = a.at(n-1) - a.at(0);
    rep(k,m){
        ll tmp=0;
        rep(l,n){
            tmp += pow(a.at(l)-(k+a.at(0)),2);
        }
        ans=min(tmp,ans);
    }
    if(ans == inf) cout << 0 << endl;
    else cout << ans << endl;
}

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

int main()
{
	int N;
	vector <int> H(0);
	int ans = 0;

	cin >> N;

	for (int i = 0; i < N; i++) {
		int h;
		cin >> h;
		H.push_back(h);
	}

	int ans2 = 0;
	for (int i = 0; i < N-1; i++) {
		int h = H[i];
		if (h >= H[i + 1])
			ans2++;
		else
			ans2 = 0;

		if (ans < ans2)
			ans = ans2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
int n,K;
ll dp[55][55][5005];
/*
dp[i][j][k]
配对到第i个数，还有j对数配对的方案数
*/
int main()
{
    scanf("%d%d",&n,&K);
    if(K&1){printf("0\n");return 0;}
    dp[0][0][0] = 1;
    for(int i=0;i<n;i++)
        for(int j=0;j<=i;j++)
        for(int k=0;k<=n*n;k++)
    {
        dp[i+1][j][k+j]=(dp[i+1][j][k+j]+dp[i][j][k]*(2*j+1))%mod;
        if(j>0)
            dp[i+1][j-1][k+j-1]=(dp[i+1][j-1][k+j-1]+dp[i][j][k]*j*j)%mod;
        dp[i+1][j+1][k+j+1]=(dp[i+1][j+1][k+j+1]+dp[i][j][k])%mod;
    }
    printf("%lld\n",dp[n][0][K/2]);
}


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

	string s;
	cin >> s;
	
	if (s[s.size()-1] == 's')
		s += "es";
	else
		s += "s";
	cout << s;

	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x;
	scanf("%d", &x);
	for(int i=x;i<=999;i++){
		bool ok = 0;
		if(i/100 == (i/10)%10 && i/100 == i%10) ok = 1;
		if(ok) return !printf("%d\n", i);
	}
}

Measured memory_bytes: 256
from collections import deque
k=int(input())
q=deque([(1,1)])
v=[0]*(k+1)
while True:
    i,c=q.popleft()
    if i==0:
        break
    if v[i]:
        continue
    v[i]=True
    q.append(((i+1)%k,c+1))
    q.appendleft(((i*10)%k,c))
print(c)

Measured memory_bytes: 45152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int MOD;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  explicit operator int() { return n; }
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator<(mint a, mint b) { return a.n < b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};

mint modinv(mint n) {
  int a = (int)n, b = MOD;
  int s = 1, t = 0;
  while (b != 0) {
    int q = a / b;
    a -= q * b;
    s -= q * t;
    swap(a, b);
    swap(s, t);
  }
  return s >= 0 ? s : s + MOD;
}


int main() {
  // S[j] - 10^{j-i} S[i] = 0
  // S[j] = 10^{j-i} S[i]
  // S[j] 10^{-j} = S[i] 10^{-i}
  int N; cin >> N >> MOD;
  string S; cin >> S;
  if (MOD == 2) {
    ll ans = 0;
    rep(i, N) {
      if ((S[i] - '0') % 2 == 0) {
        ans += i + 1;
      }
    }
    cout << ans << endl;
    return 0;
  }
  if (MOD == 5) {
    ll ans = 0;
    rep(i, N) {
      if ((S[i] - '0') % 5 == 0) {
        ans += i + 1;
      }
    }
    cout << ans << endl;
    return 0;
  }
  map<mint, ll> mp;
  mp[0]++;
  mint s = 0;
  mint p = 1;
  ll ans = 0;
  // P = 2, 5
  for (char c : S) {
    s = s * 10 + (c - '0');
    p *= modinv(10);
    ans += mp[s * p]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1028
// abc116_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> H(N);
    REP(i, N) cin >> H[i];

    int ans = 0;
    REP(i, 101){
        bool update = false;
        bool zero = true;
        REP(j, N){
            if (H[j] > 0){
                if (zero) ans++;
                H[j]--;
                update = true;
                zero = false;
            } else {
                zero = true;
            }
        }

        if (not update){
            print(ans);
            return 0;
        }
    }

    print(ans);


    return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

/// n 番目のフィボナッチ数を求める
/// F(0) = 0, F(1] = 1, F(2) = 1, F(3) = 2, F(4) = 3
int fib(int n) {
    if (n == 0) return 0;

    auto mat = new Mat4x4([[1, 1], [1, 0]]);
    auto m = mat.pow(n, int.max);
    return m.get(0, 1);
}

void main() {
    int n = readint;
    // 問題文の定義だとF(0) = 1, F(1) = 1 なので値を 1 だけずらす
    writeln(fib(n + 1));
}

class Mat4x4 {
    private int[][] _mat;

    this(const int[][] init) {
        assert(init.length == 2);
        assert(init[0].length == init[1].length && init[0].length == 2);

        _mat = new int[][](2, 2);
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                _mat[i][j] = init[i][j];
            }
        }
    }

    int get(int r, int c) const {
        return _mat[r][c];
    }

    Mat4x4 mul(const Mat4x4 m, int mod) const {
        auto t = new int[][](2, 2);

        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                int x = 0;
                for (int k = 0; k < 2; k++) {
                    x = (x + (_mat[i][k] * m.get(k, j)) % mod) % mod;
                }
                t[i][j] = x;
            }
        }
        return new Mat4x4(t);
    }

    Mat4x4 copy() const {
        return new Mat4x4(_mat);
    }

    Mat4x4 pow(int k, int mod) const {
        assert(k > 0);
        if (k == 1) return this.copy();

        auto m = this.pow(k / 2, mod);
        if (k % 2 == 0)
            return m.mul(m, mod);
        else
            return this.mul(m.mul(m, mod), mod);
    }

    void dump() const {
        writeln(_mat[0][0], " ", _mat[0][1]);
        writeln(_mat[1][0], " ", _mat[1][1]);
    }
}



Measured memory_bytes: 2508
from collections import deque

N,M = [int(v) for v in input().split()]
ad_list = [[] for _ in range (N+1)]
ad_num = [0 for _ in range(N)]
topo = []

for _ in range(M):
    l,r = [int(v) for v in input().split()]
    ad_list[l].append(r)
    ad_num[r-1] += 1

for i in range(1,N+1):
    if ad_num[i-1] == 0:
        topo.append([i,0])
queue = deque(topo[:])
while queue:
    n1,cnt = queue.popleft()
    for n2 in ad_list[n1]:
        ad_num[n2-1] -= 1
        if ad_num[n2-1] == 0:
            topo.append([n2,cnt+1])
            queue.append([n2,cnt+1])
print(max([v[1] for v in topo]))


Measured memory_bytes: 33384
// C++11
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <cmath>
#include <iostream>
#include <numeric>
#include <random>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>

using namespace std;

#define LOCAL 1

#if LOCAL
#define pv(val) cerr << #val << '=' << (val) << endl
#define pvn(name, val) cerr << name << '=' << (val) << endl
#define pl cerr << '@' << __LINE__ << endl
#else
#define pv(val)
#define pvn(name, val)
#define pl
#endif

template <class T>
ostream& operator<<(ostream& os, vector<T> const& vec) {
  if (vec.empty()) {
    os << "{}";
  } else {
    os << '{';
    for (size_t i = 0; i < vec.size() - 1; i++) os << vec[i] << ", ";
    os << vec.back() << '}';
  }
  return os;
}

template <class T, size_t S>
ostream& operator<<(ostream& os, array<T, S> const& arr) {
  if (arr.empty()) {
    os << "{}";
  } else {
    os << '{';
    for (size_t i = 0; i < arr.size() - 1; i++) os << arr[i] << ", ";
    os << arr.back() << '}';
  }
  return os;
}

int main(void)
{
  int N, X;
  cin >> N >> X;
  int minm = 1000000;
  for(int i = 0; i < N; i++){
    int m;
    cin >> m;
    X -= m;
    minm = min(minm, m);
  }
  cout << N + X / minm << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cstdio>
#include<string>

using namespace std;
int main() {
	string s2,t;
	cin >> s2 >> t;
	int a = s2.size();
	int b = t.size();
	char koho[52] = {'\0'};
	int cnt = 0;
	char now[52] = { '\0' };
	for (int i = 0; i <= a - b; i++) {
		int k = 0;
		for (int j = 0; j < b; j++) {
			if (s2[i+j] == t[j]||s2[i+j]=='?') {
				k++;
			
			}
		}
		if (k == b) {
			char cou[52] = { '\0' };
			for (int j = 0; j < b; j++) {
				int l = j + i;
				cou[l] = t[j];
			}
			for (int j = 0; j < a; j++) {
				if (s2[j] != '?'&&cou[j]=='\0') {
					cou[j] = s2[j];
				}
				if (cou[j] == '\0'&&s2[j]=='?') {
					cou[j] = 'a';
				}
			}
			cnt = 1;
			for (int j = 0; j < a; j++) {
				if (now[j] == '\0') {
					for (int z = 0; z < a; z++) {
						now[z] = cou[z];
					}
					break;
				}
				if (cou[j] == now[j]) {
				}
				else if (cou[j] > now[j]) {
					break;
				}
				else {
					for (int z = 0; z < a; z++) {
						now[z] = cou[z];
					}
					break;
				}
			}
		}
	}
	if (cnt == 0) {
		cout << "UNRESTORABLE" << endl;
	}
	else {
		for (int i = 0; i < a; i++) {
			cout << now[i] << flush;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, x = [int(z) for z in input().split()]
children = [int(z) for z in input().split()]

children.sort()
sum = 0

for i in children:
    sum += i

if sum < x:
    print(N - 1)
elif sum == x:
    print(N)
else:
    cnt = 0
    for i in children:
        if x - i < 0:
            break
        else:
            x -= i
            cnt += 1
    print(cnt)


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

tree_list = []
sort_list = []
for x in range(N):
    tree_list.append(int(input()))

sort_list = sorted(tree_list)

min_heigt = sort_list[M-1] - sort_list[0]

for x in range(N-M+1):
    nagasa =sort_list[x+M-1] - sort_list[x] 
    if min_heigt > nagasa:
        min_heigt = nagasa

print(min_heigt)

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

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

	int n, k; cin >> n >> k;
	vector<int> a(n);

	for (auto &i: a)
		cin >> i;

	vector<vector<int>> dp(n + 1, vector<int>(k + 1, 0));
	dp[0][0] = 1;

	for (int i = 1; i <= n; ++i) {
		vector<int> prefix(k + 1, 0);
		prefix[0] = dp[i - 1][0];

		for (int j = 1; j <= k; ++j) prefix[j] = (prefix[j - 1] + dp[i - 1][j]) % MOD;
		for (int j = 0; j <= k; ++j) {
			int temp = j - a[i - 1] - 1;
			if (temp >= 0)
				dp[i][j] = (prefix[j] - prefix[temp] + MOD) % MOD;
			else
				dp[i][j] = prefix[j];
		}
	}

	cout << dp[n][k] << "\n";

	return 0;
}

Measured memory_bytes: 40192
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using i64 = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
const int INF = (1 << 30);
const i64 INFL = (1LL << 62);
const i64 MOD = 1000000007;
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
i64 mod_pow(i64 a, i64 n, T mod) {
  mod = (i64)mod;
  i64 res = 1, p = a % mod;
  while (n) {
    if (n & 1) res = res * p % mod;
    p = p * p % mod;
    n >>= 1;
  }
  return res;
}
void print() { std::cout << std::endl; }
template <typename T, typename... A>
void print(const T& first, const A&... rest) {
  cout << sizeof...(rest) << endl;
  std::cout << first;
  if (sizeof...(rest)) std::cout << " ";
  print(rest...);
}
template <typename... A>
void print(const A&... rest) {
  print(rest...);
}
template <typename A>
void print(const std::vector<A>& v) {
  std::for_each(v.begin(), v.end(), [](A x) { std::cout << x << " "; });
  std::cout << std::endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  int cnt[26] = {};
  rep(i, h) {
    string a;
    cin >> a;
    for (auto& ai : a) {
      cnt[ai - 'a']++;
    }
  }
  if (!(h & 1) && !(w & 1)) {
    rep(i, 26) {
      if (cnt[i] % 4 == 0) {
        continue;
      } else {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  } else if ((h & 1) && (w & 1)) {
    int cnt_odd = 0;
    int cnt_mod_2 = 0;
    rep(i, 26) {
      if (cnt[i] & 1) {
        cnt_odd++;
        cnt[i]--;
      }
    }
    if (cnt_odd != 1) {
      cout << "No" << endl;
      return 0;
    }
    rep(i, 26) {
      if (cnt[i] % 4 == 2) {
        cnt_mod_2++;
        cnt[i] -= 2;
      }
    }
    if (!(cnt_mod_2 <= (h / 2) + (w / 2))) {
      cout << "No" << endl;
      return 0;
    }
    rep(i, 26) {
      if (cnt[i] % 4 != 0) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;

  } else {
    int tmp = ((w & 1) ? h / 2 : w / 2);
    int cnt_mod_2 = 0;
    rep(i, 26) {
      if (cnt[i] % 4 == 2) {
        cnt_mod_2++;
        cnt[i] -= 2;
      }
    }
    if (!(cnt_mod_2 <= tmp)) {
      cout << "No" << endl;
      return 0;
    }
    rep(i, 26) {
      if (cnt[i] % 4 != 0) {
        cout << "No" << endl;
        return 0;
      }
    }
    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    string s;
    vector<pair<int,int>> l;
    cin >> n >> q;
    cin >> s;
    int a,b;
    for(int i=0;i<q;i++){
        cin >> a >> b;
        l.emplace_back(make_pair(a,b));
    }
    int w=0;
    int e[100010];
    e[0]=0;
    for(int i=1;i<n;i++){
        if(s[i-1]=='A' && s[i]=='C') {
            w++;
        }
        e[i]=w;
    }
    for(int i=0;i<q;i++){
        cout << e[l[i].second-1]-e[l[i].first-1] << endl;
    }

    return 0;

}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

#include <bits/stdc++.h>
#define rep(i,a,n) for(ll i = a;i < n;i++)
typedef long long ll;
using namespace std;

int main(){ 
    ll r,g,b,n;
    cin >> r >> g >> b >> n;

    ll cnt = 0;
    rep(i,0,3001){
        rep(j,0,3001){
            ll k = n-i*r-j*g;
            if(k >= 0 && k % b == 0){
                cnt++;
                //cout << i << " " << j << " " << k << endl;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3588
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 cnt[100005];

bool isPrime(ll n){
	for(ll i = 2; i*i <= n; i++){
		if(n%i == 0) return false;
	}
	return true;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cnt[0] = 0;
	for(int i = 3; i <= 100000; i++){
		cnt[i] = cnt[i-1];
		if(i%2 == 1){
			if(isPrime(i) && isPrime((i+1)/2)) cnt[i]++;
		}
	}
	int q;
	cin >> q;
	int l, r;
	rep(i,q){
		cin >> l >> r;
		cout << cnt[r] - cnt[l-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1024