akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 2000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

ll gcd(ll a,ll b){
  if(a>b)swap(a,b);
  ll ret=b;
  while(ret%a!=0){
    ret+=b;
  }
  return ret;
}

int main(){
  int n;
  ll t[105];
  cin>>n;
  rep(i,n)cin>>t[i];
  sort(t,t+n);
  ll ans=t[0];
  for(int i=1;i<n;i++){
    ans=gcd(ans,t[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
H,W = map(int, raw_input().split())
S = [raw_input() for y in range(H)]
A = [list(s) for s in S]
for y in range(H):
  for x in range(W):
    if S[y][x]!='#':
      c = 0
      for dx in range(-1,2):
        for dy in range(-1,2):
          if (dx,dy)!=(0,0) and 0<=x+dx<W and 0<=y+dy<H and S[y+dy][x+dx]=='#':
            c += 1
      A[y][x] = str(c)
for a in A:
  print ''.join(a)


Measured memory_bytes: 2692
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int N;
int cnt[200000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N-1; i++){
        int a;
        cin >> a;
        a--;
        cnt[a]++;
    }
    for(int i = 0; i < N; i++){
        cout << cnt[i] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 4440
#include <iostream>
#include <vector>

using namespace std;

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

    vector<long long int> C(N-1);
    vector<long long int> S(N-1);
    vector<long long int> F(N-1);
    for(int n=0; n<N-1; n++) {
        cin >> C[n] >> S[n] >> F[n];
    }
    
    for(int n=0; n<N; n++) {
        long long int ans=0;
        for(int cur=n; cur<N-1; cur++) {
            if(ans>S[cur]) {
                long long int tmp=ans-S[cur];
                tmp %= F[cur];
                if(tmp) {
                    tmp = F[cur]-tmp;
                }
                ans += tmp;
            } else {
                ans = S[cur];
            }
            ans += C[cur];
        }
        cout << ans << endl;
    }
    

    return 0;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <bitset>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_N = 120;
int N;
int W[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> W[i];
    }

    int ret = 0;
    for (int i = 1; i <= N; i++) {
        ret += W[i];
    }

    for (int T = 1; T < N; T++) {
        int S1 = 0;
        int S2 = 0;
        for (int i = 1; i <= N; i++) {
            if (i <= T) {
                S1 += W[i];
            } else {
                S2 += W[i];
            }
        }
        ret = std::min(ret, abs(S2-S1));
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	int A, B; cin >> A >> B;
	if (A > B) cout << "safe" << endl;
	else cout << "unsafe" << endl;
	return 0;
}

Measured memory_bytes: 3600
import scala.io.StdIn.readInt
 
object Main extends App {
  val n = readInt
  var minv = readInt
  var maxv = Int.MinValue
 
  for(i<-1 until n) {
    val m = readInt
    if(m-minv > maxv)
      maxv = m-minv
    if(minv > m)
      minv = m
  }
  println(maxv)
}

Measured memory_bytes: 62848
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
		int H = sc.nextInt();
		int W = sc.nextInt();
		if(H==0 && W==0) break;
		for(int i = 1;i <= H;i++){
			for(int j = 1;j <= W;j++){
				if((i+j)%2 == 0){
					System.out.print("#");
				}else{
					System.out.print(".");
				}
			}
			System.out.println();
		}
		System.out.println();
		}
	}
}

Measured memory_bytes: 37316
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
void solve()
{
    string str;  cin>>str;
    ll max_len=0;
    ll n=sl(str);
    rep(i,0,n)
    {
        ll j=i;
        while(str[i]=='R') i++;
        max_len=max(max_len,i-j);
    }cout<<max_len;
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    return 0;
}


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

int main(){
    int n,d,count=0;
    double dis;
    cin >> n >> d;
    vector<double> x(n);
    vector<double> y(n);
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
    }
    for(int i=0;i<n;i++){
        dis = sqrt(pow(x[i],2) + pow(y[i],2));
        if(dis<=d){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 6432
alf=[chr(ord('a') + i) for i in range(26)]

s=input()

for i in s:
    if i in alf:
        alf.remove(i)

if len(alf) > 0:
    print(s+alf[0])
else:
    if s=='zyxwvutsrqponmlkjihgfedcba':
        print(-1)
        exit()
    else:
        ans=[]
        for i in range(1,27):
            for j in ans:
                if s[-i]<j:
                    print(s[:26-i]+j)
                    exit()
            ans.append(s[-i])
            ans.sort()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i];
	}
	sort(ALL(a));
	for(int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextInt();
  string s, t; cin >> s >> t;
  REP(i, N) {
    cout << s[i] << t[i];
  }
  cout << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll H1, M1, H2, M2, K;

int main()
{
  std::cin >> H1 >> M1 >> H2 >> M2 >> K;

  std::cout << H2*60+M2-(H1*60+M1)-K << std::endl;

  return 0;
}

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

#define rin(i,a,b) for(int i=(a);i<=(b);++i)
#define irin(i,a,b) for(int i=(a);i>=(b);--i)
#define trav(i,a) for(int i=head[a];i;i=e[i].nxt)
#define Size(a) (int)a.size()
#define pb push_back
#define mkpr std::make_pair
#define fi first
#define se second
#define lowbit(a) ((a)&(-(a)))
typedef long long LL;

using std::cerr;
using std::endl;

inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=2005;

int n,ecnt,head[MAXN];
char s[MAXN];

struct Edge{
	int to,nxt;
}e[MAXN<<1];

inline void add_edge(int bg,int ed){
	++ecnt;
	e[ecnt].to=ed;
	e[ecnt].nxt=head[bg];
	head[bg]=ecnt;
}

int root,f[MAXN],g[MAXN],h[MAXN];
bool flag;

void dfs(int x,int pre){
	f[x]=g[x]=0;
	h[x]=s[x]=='1';
	trav(i,x){
		int ver=e[i].to;
		if(ver==pre)continue;
		dfs(ver,x);
		f[x]+=f[ver]+h[ver];
		g[x]+=g[ver]+h[ver];
		h[x]+=h[ver];
	}
	if(x==root){
		if(f[x]&1)flag=false;
		else{
			int temp=-1,other=0;
			trav(i,x){
				int ver=e[i].to;
				if(ver==pre)continue;
				if(f[ver]+h[ver]>(f[x]>>1))temp=ver;
			}
			if(temp==-1)return;
			trav(i,x){
				int ver=e[i].to;
				if(ver==pre||ver==temp)continue;
				other+=g[ver]+h[ver];
			}
			if(other<f[temp]+h[temp])flag=false;
		}
	}
	else{
		int temp=-1;
		trav(i,x){
			int ver=e[i].to;
			if(ver==pre)continue;
			if(f[ver]+h[ver]>(f[x]>>1))temp=f[ver]+h[ver];
		}
		if(temp==-1)f[x]&=1;
		else f[x]=temp-(f[x]-temp);
	}
}

int main(){
	n=read();
	scanf("%s",s+1);
	rin(i,2,n){
		int u=read(),v=read();
		add_edge(u,v);
		add_edge(v,u);
	}
	int ans=1e9;
	rin(i,1,n){
		root=i;flag=true;dfs(i,0);
		if(flag)ans=std::min(ans,g[i]>>1);
	}
	printf("%d\n",ans<1e9?ans:-1);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 105;
int n, mn = inf, a[N], cnt[N], mx = -inf;
void bad() {
	cout << "Impossible";
	exit(0);
}
void good() {
	cout << "Possible";
	exit(0);
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	fw (i, 0, n) cin >> a[i], mn = min(mn, a[i]), mx = max(mx, a[i]), cnt[a[i]]++;
	fw (i, 0, n) if (a[i] > 2 * mn) bad();
	bool startbad = 0;
	if (n == 2 && cnt[1] == 2) good();
	if (cnt[1] > 1) bad();
	fw (i, mn, 2 * mn + 1) {
		if (cnt[i] == 0) startbad = 1;
		if (startbad && cnt[i] > 0) bad();
	}
	//Missing case: cnt[1 -> (mx + 1) / 2] > 2.
	fw (i, mn, (mx + 1) / 2 + 1) if (cnt[i] > 2) bad();
	if (!(mx & 1) && cnt[mx >> 1] > 1) bad();
	good();
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int
main()
{
    int x, y, r;

    scanf("%d %d", &x, &y);

    if (x < y) {
        r = x;
        x = y;
        y = r;
    }

    while (y > 0) {
        r = x % y;
        x = y;
        y = r;
    }

    printf("%d\n", x);
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define v vector<ll>
#define vv vector<v>
#define p pair<ll,ll>
ll inf=1e17;
ll mod=1e9+7;
int main()
{
 	int n,m;
 	cin>>n>>m;
 	vector<string> arr(n+1);
 	for (int i=1; i<=n; i++)
 	{
 		cin>>arr[i];
 		arr[i]="a"+arr[i];
 	}   
 	vv dp(n+1,v(m+1,0));
 	dp[1][1]=1;
 	for (int i=1; i<=n;i++)
 	{
 		for (int j=1; j<=m; j++)
 		{
 			if (i==1 && j==1)
 				continue;
 			if (arr[i][j]=='.')
 				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
 		}
 	}
 	cout<<dp[n][m]<<endl;
	return 0;
}

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

int main()
{
vector<vector<int>> A(3,vector<int>(3));vector<vector<bool>> check(3,vector<bool>(3,false));
for(int i=0;i<3;i++)for(int j=0;j<3;j++)scanf("%d ",&A[i][j]);
int N;scanf("%d",&N);;
vector<int> B(N);
for(int i=0;i<N;i++)scanf("%d",&B[i]);
for(int i=0;i<3;i++)for(int j=0;j<3;j++)for(int k=0;k<N;k++)if(A[i][j]==B[k])check[i][j]=true;
string ans="No";
for(int i=0;i<3;i++)if((check[i][0]&&check[i][1]&&check[i][2])||(check[0][i]&&check[1][i]&&check[2][i]))ans="Yes";
if((check[0][0]&&check[1][1]&&check[2][2])||(check[0][2]&&check[1][1]&&check[2][0]))ans="Yes";
printf("%s\n",ans.c_str());
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstdlib>
#include <bitset>
#include <algorithm>
#include <queue>
using namespace std;

int main() {
	
	double r;
  cin>>r;
	cout << 2*r * 3.14159 << endl;


	return 0;
}

Measured memory_bytes: 3776
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

bool match(const std::string& s, const std::string& t) {
    std::cerr << s << "   " << t << std::endl;
    if (s.size() < t.size()) {
        return false;
    }

    for (size_t i = 0; i < t.size(); ++i) {
        if (s[i] != '?' && s[i] != t[i]) {
            return false;
        }
    }
    std::cerr << " match!" << std::endl;
    return true;
}

int main()
{
    std::string S, T;
    std::cin >> S >> T;

    std::cerr << S << "   " << T << std::endl;

    std::vector<std::string> cands;
    for (size_t i = 0; i < S.size(); ++i) {
        if (match(S.substr(i), T)) {
            auto u = S;
            u.replace(i, T.size(), T);
            std::replace(u.begin(), u.end(), '?', 'a');
            cands.push_back(u);
        }
    }

    if (cands.empty()) {
        std::cout << "UNRESTORABLE" << std::endl;
    }
    else {
        std::sort(std::begin(cands), std::end(cands));
        std::cout << cands[0] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<ll> A(N);
  for(int i=0;i<N;++i) cin>>A[i];
  for(int i=1;i<N;++i) A[i] += A[i-1];
  int index1, index11, index2, index22;
  ll P, Q, R, S;
  ll maxnum, minnum;
  ll ans = big;
  for(int i=0;i<N;++i) {
    index1 = upper_bound(A.begin(), A.begin()+i, A[i]/2)-A.begin();
    index2 = upper_bound(A.begin()+i+1, A.end(), A[i]+(A[N-1]-A[i])/2)-A.begin();
    for(int j=-1;j<=1;++j) {
      for(int k=-1;k<=1;++k) {
        index11 = index1 + j;
        index22 = index2 + k;
        if(0<=index11 && index11<i && i<index22 && index22<N) {
          P = A[index11];
          Q = A[i]-A[index11];
          R = A[index22]-A[i];
          S = A[N-1]-A[index22];
          maxnum = max(P, max(Q, max(R, S)));
          minnum = min(P, min(Q, min(R, S)));
          ans = min(ans, maxnum-minnum);
        }
      }
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4812
#include<cstdio>
int e[100][100],n,m;
int ax[4]={0, 1, 0, -1},ay[4]={1, 0, -1, 0};
int dfs(int x, int y){
  int i,w=1;
  for(int i=0;i<4;i++){
    int nx = x + ax[i];
    int ny = y + ay[i];
    if(nx < 0 || nx >= n || ny < 0 || ny >= m){
      continue;
    }
    e[x][y] = 0;
    if(e[nx][ny] == 1){
      int num=dfs(nx, ny) + 1;
      if(num>w){
         w=num;
      }
    }
    e[x][y] = 1;
  }
  return w;
}
 int main(){
  while(1){
    int ans=0;
    scanf("%d %d",&m,&n);
    if(!m){
      break;
    }
     for(int i = 0;i < n;i++){
      for(int j=0;j<m;j++){
        scanf("%d",e[i]+j);
      } 
   }
   for(int i = 0;i < n;i++){
      for(int j = 0;j < m;j++){
     if(e[i][j]){
       int num=dfs(i, j);
      if(num>ans){
        ans=num;
      }
    }
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1056
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
	LL i,j,k,n,p,ans=0;
	LL a[50],way[5001]={0};
	bool b[5001];
	cin>>n>>p;
	for(i=0;i<n;i++)	cin>>a[i];
	sort(a,a+n);
	way[0]=1;
	for(j=0;j<n;j++)
	{
		for(i=5000;i>=0;i--)
		{
			if(i-a[j]<0)	break;
			way[i]+=way[i-a[j]];
		}
	}
	j=p%2;
	for(i=j;i<=5000;i=i+2)
		b[i]=true;
	for(i=0;i<=5000;i++)
	{
		if(b[i])
		{
			ans=ans+way[i];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define allr(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
// #define pi 3.1415926535897932384626433832
#define mod 1000000007
//#define mod 998244353
#define inf 1000000000
#define pr1(a) cout << a << endl
#define pr2(a,b)cout << a <<  " " <<b<< endl
#define pr3(a,b,c) cout << a <<" " << b << " " << c << endl

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

int gcd(int a, int b){
    if(b==0)return a;
    return gcd(b,a%b);
}

vector<int> prefix_function(string s) {
    int n = (int)s.length();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        //we will try to shorten the match string length until we revert to the beginning of match (index 1)
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}
void solve(){

    int n;
    cin >> n;

    map<string, int> m;

    while(n--){
        string s;
        cin >> s;

        m[s]++;
    }

    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
} 

signed main() 
{   
    IOS;
    int t = 1;
    // cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


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

using namespace std;

int f[123456];

bool prime(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return x > 1;
}

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  for (int i = 1; i <= 100000; i++) {
    f[i] = f[i - 1] + (prime(i) && prime((i + 1) / 2));
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    printf("%d\n", f[r] - f[l - 1]);
  }
  return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            int N;int K;
            Multi(out N, out K);
            var S = GetStr().ToCharArray();
            S[K-1] = S[K-1].ToString().ToLower()[0];
            var ans = new string(S);

            Console.Write(ans);
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  string S;
  cin>>S;
  string SS;
  rep(i,S.size()) if(S[i]!='x') SS+=S[i];
  string RR=SS;
  reverse(all(SS));
  if(SS!=RR){
    cout<<-1<<endl;
    return 0;
  }
  VI X(SS.size()+1);
  int P=0;
  int cnt=0;
  rep(i,S.size()){
    if(S[i]=='x'){
      cnt++;
    }else{
      X[P]=cnt;
      P++;
      cnt=0;
    }
  }
  X[P]=cnt;
  int ans=0;
  rep(i,X.size()/2) ans+=abs(X[i]-X[X.size()-1-i]);
  cout<<ans<<endl;
}

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

int N,x;
int a[100005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(7);
    cout << fixed;

    cin >> N >> x;
    for(int i=0;i<N;i++){
        cin >> a[i];
    }

    sort(a,a+N);
    for(int i=0;i<N;i++){
        x -= a[i];
        if(x<0){
            cout << i << endl;
            return 0;
        }
    }
    if(x>0){
        cout << N-1 << endl;
    }else{
        cout << N << endl;
    }
    return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

const int mod = 1e9 + 7;

signed main() {
  int a, b, k;
  std::cin >> a >> b >> k;
  if (a + k - 1 >= b - k + 1) {
    FOR(i, a, b + 1) { print(i); }
  } else {
    REP(i, k) { print(i + a); }
    FOR(i, b - k + 1, b + 1) { print(i); }
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define mod 1000000007
typedef long long ll;
ll ans(int m, ll n){
    if(n==0) return 1;
    ll h = ans(m,n/2);
    if(n%2==0){
        return h%mod * h%mod % mod;
    }
    return h%mod * h%mod * m%mod;
}
int main(void){
    int m; ll n;
    cin >> m >> n;
    cout << ans(m, n) << endl;
    return 0;
}



Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int solve(int a,int b,int c){
    if(c==0)return 0;
    if(b<=c&&b<=a)return b;
    return 0;
}

int main(){
    string s;
    cin>>s;
    int ans=0;
    static int J[2000000]={},O[2000000]={},I[2000000]={};
    if(s[0]=='J')J[0]=1;
    for(int i=1;i<s.size();i++){
//        cout<<s[i-1]<<" "<<J[i-1]<<" "<<O[i-1]<<" "<<I[i-1]<<endl;
        if(s[i]=='J'){
            if(O[i-1]!=0){
                ans=max(ans,solve(J[i-1],O[i-1],I[i-1]));
                J[i]=1;
            }
            else{
                J[i]=J[i-1]+1;
                O[i]=O[i-1];
                I[i]=I[i-1];
            }
        }else if(s[i]=='O'){
            if(J[i-1]!=0&&I[i-1]==0){
                J[i]=J[i-1];
                O[i]=O[i-1]+1;
                I[i]=I[i-1];
            }else{
                ans=max(ans,solve(J[i-1],O[i-1],I[i-1]));
            }
        }else if(s[i]=='I'){
            if(O[i-1]!=0){
                J[i]=J[i-1];
                O[i]=O[i-1];
                I[i]=I[i-1]+1;
            }
            else{
                ans=max(ans,solve(J[i-1],O[i-1],I[i-1]));
            }
        }
    }
    ans=max(ans,solve(J[s.size()-1],O[s.size()-1],I[s.size()-1]));
    cout<<ans<<endl;
}

Measured memory_bytes: 18564
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int a,b,n;
int main()
{
	get3(n,a,b);
	if((b-a)%2==1)puts("Borys");
	else puts("Alice");
	return 0;
}

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

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

    int a[n - 1];
    long long sum;
    cin >> a[0];
    sum = a[0];
    for (int i = 1; i < n - 1; i++) {
        cin >> a[i];
        sum += min(a[i], a[i - 1]);
    }
    sum += a[n - 2];
    cout << sum << "\n";
}


Measured memory_bytes: 256
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var A = one[1] - 1;
  var B = one[2] - 1;
  var C = one[3] - 1;
  var D = one[4] - 1;
  var s = nextCharArray();
  if(D < C){
    //AをBより右に行かせる
    //Bが...の真ん中に移動させてから。
    while(!(s[B - 1] == "." && s[B - 1] == "." && s[B + 1] == ".") && B < D){
      if(s[B + 1] == "."){
        B++;
        continue;
      }
      if(s[B + 2] == "."){
        B += 2;
        continue;
      }
      myout("No");
      return;
    }
    s[B] = "#";
    while(A < C){
      if(s[A + 1] == "."){
        A++;
        continue;
      }
      if(s[A + 2] == "."){
        A += 2;
        continue;
      }
      myout("No");
      return;
    }
    while(B < D){
      if(s[B + 1] == "."){
        B++;
        continue;
      }
      if(s[B + 2] == "."){
        B += 2;
        continue;
      }
      myout("No");
      return;
    }
  }else{
    while(B < D){
      if(s[B + 1] == "."){
        B++;
        continue;
      }
      if(s[B + 2] == "."){
        B += 2;
        continue;
      }
      myout("No");
      return;
    }
    while(A < C){
      if(s[A + 1] == "."){
        A++;
        continue;
      }
      if(s[A + 2] == "."){
        A += 2;
        continue;
      }
      myout("No");
      return;
    }
  }
  
  myout("Yes");
}

Measured memory_bytes: 9548
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
    int a, b;
    cin >> a >> b;
    cout << ((b - a) * (b - a - 1) / 2 - a);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = 0;
  rep2(b, k + 1, n + 1) {
    ll i = b - k;
    ans += n / b * i;
    ans += max(0LL, n % b + min(0LL, -k + 1));
  }
  cout << ans << endl;
}

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

using namespace std;

int n, ans[100005];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        ans[x] = i;
    }
    for (int i = 1; i <= n; i++) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1152
i = int(input())
def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors

l = []
for x, y in zip(sorted(make_divisors(i)), sorted(make_divisors(i),reverse=True)):
	l.append(x + y - 2)
print(min(l))


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

void swap( int &a, int &b )
{
	int t=a;
	a=b;
	b=t;
}

int partition(int arr[], size_t arr_s, size_t left, size_t right)
{
	if( right >= arr_s ){
		cout<<"Error"<<endl;
		return -1;
	}


	size_t i=left-1;

	for( size_t j=left; j<right; j++ ){
		if( arr[j] <= arr[right] ){
			++i;
			swap( arr[j], arr[i] );
		}
	}
	swap( arr[right], arr[i+1] );
	return i+1; //??????i??????pivot ??\??????????????\??£???????????????????????????
}
	

int main()
{
	int *arr;
	size_t arr_s;
	cin>>arr_s;
	arr=new int[arr_s];
	for( size_t i=0; i<arr_s; i++ ){
		cin>>arr[i];
	}

	size_t pivot_i=partition(arr, arr_s, 0, arr_s-1);

	if( 0!=pivot_i ){
		cout<<arr[0]<<flush;
	}else{
		cout<<'['<<arr[0]<<']'<<flush;
	}
	for( size_t i=1; i<arr_s; i++ ){
		if( i!=pivot_i ){
			cout<<' '<<arr[i]<<flush;
		}else{
			cout<<' '<<'['<<arr[i]<<']'<<flush;
		}
	}
	cout<<endl;
}

Measured memory_bytes: 1576
open Str

type dllist = {value : int option; mutable prev : dllist ref; mutable next : dllist ref}
       
let read_list () =
  split (regexp " +") (read_line ())
                                                 
let () =
  let n = read_int () in
  let rec tn = {value = None; prev = ref tn; next = ref tn} in
  let insert x =
    let nn = {value = Some x; prev = ref tn; next = ref tn} in
    let nnn = !(tn.next) in
    nn.next <- tn.next;
    nn.prev <- nnn.prev;
    tn.next <- ref nn;
    nnn.prev <- ref nn
  in
  let find x =
    let rec loop n =
      let nn = !(n.next) in
      match nn.value with
        None -> raise Not_found
      | Some y -> if x = y then nn else loop nn in
    loop tn
  in
  let delete x = try
      let n = find x in
      let pn = !(n.prev) in
      let nn = !(n.next) in
      pn.next <- n.next;
      nn.prev <- n.prev
    with
      _ -> ()
  in
  let delete_first () =
    let dn = !(tn.next) in
    let nn = !(dn.next) in
    tn.next <- dn.next;
    nn.prev <- dn.prev
  in
  let delete_last () =
    let dn = !(tn.prev) in
    let pn = !(dn.prev) in
    tn.prev <- dn.prev;
    pn.next <- dn.next
  in
  let print_dll () =
    let rec loop n ls =
      let nn = !(n.next) in
      match nn.value with
        None -> List.rev ls
      | Some x -> loop nn (x :: ls) in
    loop tn [] |> List.map string_of_int |> String.concat " " |> print_endline
  in
  let rec iter x =
    if x = 0 then print_dll ()
    else
      let s = read_list () in
      match s with
        "deleteFirst" :: _  -> delete_first (); iter (x-1)
      | "deleteLast" :: _ -> delete_last (); iter (x-1)
      | "insert" :: n :: _ -> insert (int_of_string n); iter (x-1)
      | "delete" :: n :: _ -> delete (int_of_string n); iter (x-1)
      | _ -> failwith "ddl"
  in iter n

Measured memory_bytes: 123900
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
C = Counter(A)
T = []
F = []
for e in C:
    if C[e] >= 4:
        F.append(e)
    if C[e] >= 2:
        T.append(e)
ans = 0
for e in F:
    ans = max(ans,e**2)
T = sorted(T)
if len(T) >= 2:
    ans = max(ans,T[-1]*T[-2])
print(ans)


Measured memory_bytes: 18600
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))
e_list = [a for a in a_list if a % 2 == 0]

if not e_list:
    ans = "APPROVED"
else:
    ee_list = [e for e in e_list if e % 3 == 0 or e % 5 == 0]
    ans = "APPROVED" if len(ee_list) == len(e_list) else "DENIED"

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

enum State { FIRST, INCREASE, DECREASE };

int main(void) {
	int N, i, A[2], count = 1, state = FIRST;

	scanf("%d", &N);
	scanf("%d", &A[0]);
	for (i = 0; i < N - 1; i++) {
		scanf("%d", &A[1]);
		switch (state) {
		case FIRST:
			if (A[0] < A[1])
				state = INCREASE;
			else if (A[0] > A[1])
				state = DECREASE;
			break;

		case INCREASE:
			if (A[0] > A[1]) {
				state = FIRST;
				count++;
			}
			break;

		case DECREASE:
			if (A[0] < A[1]) {
				state = FIRST;
				count++;
			}
			break;
		}
		A[0] = A[1];
	}

	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MOD = 1e9+7;
//ll memo[2001];
//ll dfs(ll now){
//    ll& ret = memo[now];
//    if(ret != -1) return ret;
//    ret = 0;
//    if(now < 3) return ret;
//    ret = 1;
//    for(int i = 3; i <= now; i++){
//        ll L = i, R = now-i;
//        if(R < 3) break;
//
//        cout << now << " " << L << " " << R << endl;
//
//        ret *= dfs(L)*dfs(R)%MOD;
//        ret %= MOD;
//    }
//    ret += 1;
//
//    return ret;
//}
       
template<class Type>
Type solve(Type res = Type()){
    ll S; cin >> S;
//    fill(memo,memo+2001,-1);
//
//    res = dfs(S);
//    for(int i = 0; i <= S;i++){
//        cout << i << " : " << memo[i] << endl;
//    }
    
    ll N = S;//(S+2)/3;
    auto dp = make_v<ll>(N+1,S+1);
    dp[0][0] = 1;
    for(int i = 0; i < N;i++){
        for(int j = 0; j <= S; j++){
            if(dp[i][j] == 0) continue;
            for(int k = 3; j+k <= S; k++){
                dp[i+1][j+k] += dp[i][j];
                if(dp[i+1][j+k]>=MOD) dp[i+1][j+k]-=MOD;
            }
        }
    }
    
    for(int i = 0; i <= N;i++){
        (res += dp[i][S])%=MOD;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 34460
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int a = sc.nextInt();
			String op=sc.next();
			int b = sc.nextInt();

			if(op.equals("?")) {
				break;
			}else if(op.equals("+")) {
				System.out.println(a + b);
			}else if(op.equals("-")) {
				System.out.println(a - b);
			}else if(op.equals("*")) {
				System.out.println(a * b);
			}else if(op.equals("/")) {
				System.out.println(a / b);
			}
		}
	}
}


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


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

  int n, h;
  cin >> n >> h;

  vector<int> a(n), b(n);
  for (int i=0; i<n; i++) {
    cin >> a[i] >> b[i];
  }
  
  int max_a = *max_element(a.begin(), a.end());
  sort(b.rbegin(), b.rend());

  int ans = (h+max_a-1) / max_a;
  int sum = 0;
  for (int i=0; i<n; i++) {
    sum += b[i];
    ans = min(ans, ((max(0, h-sum)+max_a-1) / max_a) + (i+1));
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String[] line = br.readLine().split(" ");
		int r = Integer.parseInt(line[0]);
		int c = Integer.parseInt(line[1]);
		int[][] rc = new int[r+1][c+1];
		for(int i = 0; i < r; i++){
			String[] str =br.readLine().split(" ");
			for(int j = 0; j < c; j++){
				rc[i][j] = Integer.parseInt(str[j]);
				rc[i][c] +=  Integer.parseInt(str[j]);
			}
		}
		for(int i = 0; i < c+1; i++){
			for(int j = 0; j < r; j++){
				rc[r][i] += rc[j][i];
			}
		}
		for(int i = 0; i < r+1; i++){
			for(int j = 0; j < c+1; j++){
				//System.out.print(rc[i][j]+" ");
				sb.append(rc[i][j]);
        if(j != c) sb.append(" ");
			}
			//System.out.println();
			sb.append("\n");
		}
		System.out.print(sb);
		
	}
}

Measured memory_bytes: 27580
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/

int main()
{
	cin >> n;
	ll d[100][100];
	REP(i, n) REP(j, n) d[i][j] = 0;
	REP(i,n)
	{
		cin >> w >> k;
		REP(j, k) {
			cin >> h;
			d[i][h - 1] = 1;
		}
	}
	
	REP(i, n) {
		REP(j, n)
		{
			if (j) cout << ' ';
			cout << d[i][j];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3252
import sys

n = int(sys.stdin.readline())

for line in sys.stdin:
    line = line.strip()
    L = len(line)
    cand = set()
    for i in xrange(L):
        head = line[:i]
        tail = line[i:]
        cand.add(head + tail)
        cand.add(head[::-1] + tail)
        cand.add(head + tail[::-1])
        cand.add(head[::-1] + tail[::-1])
        cand.add(tail + head)
        cand.add(tail[::-1] + head)
        cand.add(tail + head[::-1])
        cand.add(tail[::-1] + head[::-1])
    print len(cand)

Measured memory_bytes: 4288
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

vector<int>a[100000];
vector<int>b[100000];

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

	int x, y;
	rep(i, 0, m) {
		cin >> x >> y;
		a[x].push_back(y);
		a[y].push_back(x);
	}

	int now, groupnumber = 0;
	vector<bool>done(n + 1, 0);//すでにgroup化されているか
	vector<int>ans(n + 1, 0);//groupのサイズを代入する配列
	vector<int>groupnum(n + 1);//groupごとにグループナンバーを定義
	queue<int>que;
	rep(i, 1, n+1) {
		if (done[i] == true)continue;
		vector<int>group;//groupの人をpush_back

		done[i] = true;
		group.push_back(i);
		for (auto nx : a[i]) {
			que.push(nx);
			done[nx] = true;
			group.push_back(nx);
		}
		while (!que.empty()) {
			now = que.front();
			que.pop();
			for (auto nx : a[now]) {
				if (done[nx] == true)continue;
				que.push(nx);
				done[nx] = true;
				group.push_back(nx);
			}
		}
		for (auto s : group) {
			ans[s] = group.size();
			groupnum[s] = groupnumber;
		}
		groupnumber++;
	}

	rep(i, 0, k) {
		cin >> x >> y;
		if (groupnum[x] == groupnum[y]) {
			b[x].push_back(y);
			b[y].push_back(x);
		}
	}
	rep(i, 1, n + 1)
		cout << ans[i] - a[i].size() - b[i].size() - 1 << " ";
}

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

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

template <long long mod> class modint {
  private:
    long long _num;
    modint set(long long num) {
        _num = num % mod;
        return *this;
    }

  public:
    modint() { _num = 0; }
    modint(long long num) { _num = num % mod; }

    modint operator=(long long x) { return set(x % mod); }
    modint operator+(long long x) { return modint<mod>(_num + (x % mod)); }
    modint operator-(long long x) { return modint<mod>(_num - (x % mod)); }
    modint operator*(long long x) { return modint<mod>(_num * (x % mod)); }
    modint operator+=(long long x) { return set(_num + (x % mod)); }
    modint operator-=(long long x) { return set(_num - (x % mod)); }
    modint operator*=(long long x) { return set(_num * (x % mod)); }

    explicit operator int() { return _num; }
    friend ostream &operator<<(ostream &os, const modint<mod> &x) {
        os << x._num;
        return os;
    }
};
using mint = modint<MOD>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    vector<int> v(n);
    map<int, int> mp;
    mint ans = 0;
    REP(i, n) cin >> v[i];
    REP(i, n) {
        FOR(j, i + 1, n) {
            if (v[i] > v[j]) {
                ans += (k + 1) * k / 2;
            } else if (v[i] < v[j]) {
                ans += (k - 1) * k / 2;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256