akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    ll a,b;
    cin >> a >> b;
    ll cnt=0;
    while(1){
        if(abs(a-cnt)==abs(b-cnt)){
            cout << cnt << endl;
            return 0;
        }
        if(cnt>1000000001){
            cout << "IMPOSSIBLE" << endl;
            return 0;
        }
        cnt++;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;

int main()
{
    string l;
    while (cin >> l) {
        int ans = 0;
        if (l == "0") {
            break;
        }
        for (int i = 0; i < l.length(); i++) {
            int n;
            n = l[i] - '0';
            ans += n;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3180
a = list(input())
ar = [["+","-"],["+","-"],["+","-"]]
count = 0
t = 0
for x in ar[0]:
    for y in ar[1]:
        for z in ar[2]:
            count += int(a[0])
            if x == "+":
                count += int(a[1])
            elif x == "-":
                count -= int(a[1])
            if y == "+":
                count += int(a[2])
            elif y == "-":
                count -= int(a[2])
            if z == "+":
                count += int(a[3])
            elif z == "-":
                count -= int(a[3])
            if count == 7 and t ==0:
                print(a[0]+x+a[1]+y+a[2]+z+a[3]+"=7")
                t += 1
            count = 0

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,AC=0,TLE=0,WA=0,RE=0;
    string s;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        if(s=="AC") AC++;
        if(s=="TLE") TLE++;
        if(s=="WA") WA++;
        if(s=="RE") RE++;
    }
    cout<<"AC x"<<' '<<AC<<endl;
    cout<<"WA x"<<' '<<WA<<endl;
    cout<<"TLE x"<<' '<<TLE<<endl;
    cout<<"RE x"<<' '<<RE<<endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<stack>
#include<set>
#include<vector>
using namespace std;

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

    vector<vector<int>> before(n+1), after(n+1);

    int a, b;
    int number = 1;
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        before[a].push_back(number);
        after[b].push_back(number);
        number++;
    }

    set<int> danger, safe;

    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(after[i].size() != 0){
            bool breakbridge = false;
            for(int j = 0; j < after[i].size(); j++){
                int x = after[i][j];
                if(danger.find(x) != danger.end()){
                    breakbridge = true;
                }else{
                    // already separated by broken bridges
                }
            }
            if(breakbridge){
                ans++;
                danger.clear();
            }
        }

        if(before[i].size() != 0){
            for(int j = 0; j < before[i].size(); j++){
                danger.insert(before[i][j]);
            }
        }
        
    }

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

Measured memory_bytes: 11772
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <math.h>

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

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
bool isOutOfBounds(int y, int x, int h, int w) {
    return y < 0 || y >= h || x < 0 || x >= w;
}

int main() {
    vi prime = {2};
    for (int i=3; i<=123456*3; i++) {
        REP(j, prime.size()) {
            if (i % prime[j] == 0) break;
            if (j == prime.size() - 1) prime.push_back(i);
        }
    }

    int n;
    while (cin >> n) {
        if (n == 0) break;

        int i0 = 0;
        while (prime[i0] <= n) i0++;
        int i = 1;
        while (prime[i0+i] <= 2*n) i++;

        cout << i << endl;
    }

    return 0;
}

Measured memory_bytes: 3188
//secreterror
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0;i<n;i++)
#define rev(i, n) for(ll i=n-1;i>=0;i--)
#define forr(i, x, y) for(ll i=x;i<y;i++)
#define f first
#define s second
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vpii vector<pair<int,int>>

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

    vector<ll>arr(n);
    rep(i,n) cin>>arr[i];

    vector<ll>dp(n+1,INT_MAX);

    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(arr[0]-arr[1]);

    for(int i=3;i<=n;i++){
        for(int j=k;j>=1;j--){

            if(i-j>=1){
                dp[i]=min(dp[i],dp[i-j]+abs(arr[i-1]-arr[i-j-1]));
            }

        }
    }
    cout<<dp[n]<<endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++)
    {
        cin >> d[i];
    }
    sort(ALL(d));
    cout << d[n / 2] - d[n / 2 - 1] << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M, K;
string S;
vi va, vb;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

void input() {
}
void solve() {
  cin>>N;
  cout<<(double)N*2*3.141592653589<<endl;

}
signed main() {
  cout << setprecision(12);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 3800
x,y,a,b,c = map(int, input().split())

s_a = [int(i) for i in list(input().split())]
s_b = [int(i) for i in list(input().split())]
s_c = [int(i) for i in list(input().split())]

s_a.sort(reverse = True)
s_b.sort(reverse = True)
s_c.sort(reverse = True)

x_a = s_a[0:x]
x_b = s_b[0:y]


sum_a = x_a + x_b + s_c
sum_a.sort(reverse = True)
sum_a = sum_a[0:x+y]
print(sum(sum_a))

Measured memory_bytes: 22592
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n, m;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> m;
	vector<int> s, t;
	FOR(i, m) {
		int a, b;
		cin >> a >> b;
		if (a == 1 && b != n) s.push_back(b);
		else if (a != 1 && b == n) t.push_back(a);
	}
	if (s.empty() || t.empty()) {
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}
	sort(ALL(s));
	sort(ALL(t));

	bool ok = false;
	int j = 0;
	FOR(i, s.size()) {
		while (t[j] < s[i] && j < t.size()) j++;
		if (j == t.size()) break;
		if (t[j] == s[i]) ok = true;
	}
	if (ok) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
pair<int, int>a[123465]; int n;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i].first >> a[i].second;
	sort(a, a + n);
	for (int i = 0; i < n; i++)cout << a[i].first << ' ' << a[i].second << endl;
}


Measured memory_bytes: 5044
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int p=sc.nextInt();
        long M0=0,M1=0;
        for (int i = 0; i < n; i++) {
            if(sc.nextInt()%2==0)M0++;else M1++;
        }
        long ans=0;
        long temp=0;
        if(p==0){
            for (long i = 0; i <= M0; i++) {
                ans+=comb(M0,i);
            }
            long i=0;
            while(i*2<=M1){
                temp+=comb(M1,i*2);
                i++;
            }
        }else{
            long i=0;
            while(i*2+1<=M1){
                ans+=comb(M1,2*i+1);
                i++;
            }
            for (long j = 0; j <= M0; j++) {
                temp+=comb(M0,j);
            }
        }
        out.println(ans*temp);
    }
    static long comb(long a,long b){
        if(b==0)return 1;
        return comb(a-1,b-1)*a/b;
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 998244353;

ll n,s;
ll a[3005];
ll ans;
ll dp[3005][3005][3];
int main() {

  cin >> n >> s;

  for(int i = 0; i < n; i++) cin >> a[i];

  dp[0][0][0] = 1;

  for(int i = 0; i < n; i++) {
    for(int j = s; j >= 0; j--) {
      if(j-a[i] >= 0) {
	dp[i+1][j][1] += dp[i][j-a[i]][0];
	dp[i+1][j][1] %= mod;
	dp[i+1][j][2] += dp[i][j-a[i]][1];
	dp[i+1][j][2] %= mod;
	dp[i+1][j][1] += dp[i][j-a[i]][1];
	dp[i+1][j][1] %= mod;
	dp[i+1][j][2] += dp[i][j-a[i]][0];
	dp[i+1][j][2] %= mod;
      }
      dp[i+1][j][0] += dp[i][j][0];
      dp[i+1][j][0] %= mod;
      dp[i+1][j][1] += dp[i][j][1];
      dp[i+1][j][1] %= mod;
      dp[i+1][j][2] += dp[i][j][1];
      dp[i+1][j][2] %= mod;
      dp[i+1][j][1] += dp[i][j][0];
      dp[i+1][j][1] %= mod;
      dp[i+1][j][2] += dp[i][j][2];
      dp[i+1][j][2] %= mod;
    }
  }

  

  /* for(int i = 0; i <= n; i++) {
    for(int j = 0; j <= s; j++) {
      for(int k = 0; k < 3; k++) {
	cout << "dp["<<i<<"]["<<j<<"]["<<k<<"] = "<<dp[i][j][k] << endl;
      }
    }
    }*/
  cout << dp[n][s][2] % mod << endl;
}

  


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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main() {

    string s, t;
    cin >> s >> t;

    for ( long long int i = 0; i < s.size(); i++ ) {
        if ( s[i] != t[i] ) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;

}


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

D=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(D)]
T=[int(input()) for i in range(D)]

ANS=0
LAST=[0]*26
for i in range(D):
    t=T[i]
    ANS+=S[i][t-1]
    LAST[t-1]=i+1

    for j in range(26):
        ANS-=C[j]*(i+1-LAST[j])

    print(ANS)
    


Measured memory_bytes: 9320
n, k = map(int, input().split())
a = list(map(int, input().split()))

a_sorted = sorted(a)

bit = [0] * 2001

inversion = 0
for i in range(n):
  bit[a[i]] += 1
  s = 0
  for j in range(a[i]+1):
    s += bit[j]
  inversion += i + 1 - s
  
inversion *= k
  
for i in range(n):
  inversion += (a_sorted.index(a[i]) * k * (k - 1)) // 2
  
print(inversion % int(10**9 + 7))

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

signed main(){
  int a, b;
  cin >> a >> b;

  set<int> as;
  rep(i, 2, a/i+1){
    while(a%i == 0){
      a /= i;
      as.insert(i);
    }
  }
  if(a != 1) as.insert(a);

  int ans = 1;
  for(int i : as){
    if(b%i == 0) ans++;
  }

  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define sc second
#define fr first
#define mk make_pair
#define ll long long
#define ii pair<int,int>
#define mp make_pair
using namespace std;
int n,k;
int memo[100005][4];
int a[100005][3];
int solve(int i,int last)
{
    if(i == n)
    {
        return 0;
    }
    int &ret = memo[i][last];
    if(ret != -1)
        return ret;
    ret = 0;
    for(int j=0;j<3;j++)
    {
        if(j!=last)
            ret = max(ret , a[i][j]+solve(i+1,j));
    }
    return ret;
}
int main()
{
    memset(memo,-1,sizeof(memo));
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    cout<<solve(0,3);
}


Measured memory_bytes: 10752
from collections import deque

N, M = map(int, input().split(" "))
edges = {k: set() for k in range(N)}
for i in range(M):
    x, y, z = map(int, input().split(" "))
    x -= 1
    y -= 1
    edges[x].add(y)
    edges[y].add(x)

nodes = list(range(N))
# print(edges)
ans = 0
i = 0
seen = set()
while i < len(nodes):
    n = nodes[i]
    i += 1
    if n in seen:
        continue

    ans += 1
    Q = deque()
    Q.append(n)
    while Q:
        s = Q.pop()
        if s in seen:
            continue
        seen.add(s)
        for t in edges[s]:
            Q.append(t)

print(ans)


Measured memory_bytes: 91364
{-# LANGUAGE ScopedTypeVariables #-}
import Data.List
import Control.Applicative

main = interact process

process input0
 = replicate (w+1) '#' ++
   (input2 >>= \c -> if c == '\n' then "#\n#" else [c]) ++
   replicate (w+1) '#' ++ "\n"
  where
    (h::Int,input1):_ = reads input0
    (w::Int,input2):_ = reads input1

Measured memory_bytes: 1020
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
using namespace std;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;



int main(void){
    ll d,n;
    cin>>d>>n;
    long long ans=n*pow(100,d);
    if(n==100)ans+=pow(100,d);
    
    cout<<ans;
}

Measured memory_bytes: 256
x = int(input())
a = 0
b = 0
if not x == 0:
  for i in range(1000):
    for j in range(-100,1000):
      if i**5 - j**5 == x:
        a = i
        b = j
      if a != 0 or b != 0:
        break
    if a != 0 or b != 0:
        break
    
print(str(a)+" "+str(b))


Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) (v).erase( unique(all(v), (v).end() );
#define SZ(x) ((ll)(x).size()) // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define INF 1000000000000
#define MOD 1000000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ll = long long;
using ull = unsigned long long;

template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return true;}return false;}

const char newl = '\n';

ll qp(ll a,ull b){ll ans=1;do{if(b&1u)ans*=a;a*=a;}while(b>>=1u);return ans;}
ll qp(ll a,ull b,ll mod){ll ans=1;do{if(b&1u)ans=ans*a%mod;a=a*a%mod;}while(b>>=1u);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


int main() {
    ll n;
    cin >> n;
    vector<ll> vec;
    rep(i, n) {
        ll x;
        cin >> x;
        vec.push_back(x);
    }

    sort(vec.begin(), vec.end(), greater<>());

    ll conf = 0;
    rep(i, n - 1) {
        conf += vec[(i+1) / 2];
    }

    cout << conf << newl;


    return 0;
}


Measured memory_bytes: 4960
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int ans = a+b+c - max({a,b,c});
  cout << ans << endl; 
  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main(void) {
    int i;
    int kaisu;
    int num;
    long int min=1000000,max=-1000000,sum=0;

    
    scanf("%d", &kaisu);
    for(i = 0; i < kaisu; i++) {
        scanf("%d", &num);

        sum+=num;
        if(num < min) {
            min = num;
        }
        if(num > max) {
            max = num;
        }
    }

    printf("%ld %ld %ld\n", min, max, sum);
    
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int h,w;
char grid[600][600];
char gri2[600][600];
void iterate(int flg){
	int curline=0,curpos=1,pline=0,ppos=0,dx=1;
	int res=0;
	while(curline<h){
		if(curpos==w||curpos<0){
			curline++;
			if(curpos==w)
				curpos=w-1;
			if(curpos<0)
				curpos=0;
			if(curline==h)
				break;
			dx*=-1;
		}
		if(grid[pline][ppos]%2==1){
			res++;
			grid[pline][ppos]--;
			grid[curline][curpos]++;
			if(flg){
				printf("%d %d %d %d\n",pline+1,ppos+1,curline+1,curpos+1);
			}
		}
		ppos=curpos;
		pline=curline;
		curpos+=dx;
	}
	if(!flg){
		printf("%d\n",res);
	}
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++)
			cin>>grid[i][j];
		for(int j=0;j<w;j++){
			gri2[i][j]=grid[i][j];
		}
	}
	iterate(0);
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			grid[i][j]=gri2[i][j];
		}
	}
	iterate(1);
	return 0;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ce = 0;
    int cw = 0;
    rep(i,n){
        if(s[i] == 'E')ce++;
        else cw++;
    }
    int ans = 1e9;
    int e = ce;
    int w = 0;
    rep(i,n){
        if(s[i] == 'E') e--;
        ans = min(ans,e+w);
        if(s[i] == 'W') w++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 900
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;
    static CF_Reader in;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new CF_Reader();

        for (int i = 1; i < 6; i++) {
            if (in.intNext() == 0) {
                out.println(i);
                break;
            }
        }

        out.close();
    }


    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}




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

int main() {
    int A, B;
    cin >> A >> B;
    if (A==1) A=14;
    if (B==1) B=14;

    if (A>B) {
        cout << "Alice" << endl;
    }
    else if (B>A) {
        cout << "Bob" << endl;
    }
    else {
        cout << "Draw" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(){
  int k,a,b;
  cin>>k;
  cin>>a>>b;
  
  for(int i=a;i<=b;i++){
    if(i%k==0){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  
  cout<<"NG"<<endl;
  
  return 0;
}

Measured memory_bytes: 3628
import sys
from collections import deque

H, W = map(int, input().split())

Map = [[] for _ in range(H)]
reached = [[-1]*W for _ in range(H)]
route = [[False]*W for _ in range(H)]

q = deque()
check = False
b = 0
for y in range(H):
    for x in input():
        Map[y].append(x)
        if x=="#":
            b += 1

def BFS(x, y, pre):
    global check

    if x>=W or y>=H or x<0 or y<0 or Map[y][x]=="#" or reached[y][x]>=0:
        return

    reached[y][x] = pre + 1

    if x==(W-1) and y==(H-1):
        ans =H * W - reached[y][x] + 1 - b - 2
        print(ans)
        sys.exit()

    else:
        q.append((x + 1, y, pre + 1))
        q.append((x - 1, y, pre + 1))
        q.append((x, y + 1, pre + 1))
        q.append((x, y - 1, pre + 1))

q.append((0,0,-1))
while q:
    BFS(*q.popleft())
print(-1)




Measured memory_bytes: 3436
#include <iostream>
using namespace std;
int main() {
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if ((x-r >= 0 && x+r <= W) && (y-r >= 0 && y+r <= H))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3096
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main(void)
{
	int i,j,k,cnt,ff=0,mx=-1;
	char s[200001];
	cin >> s;
	for(i = 0; i < strlen(s); i++) {
		if(s[i] == 'A' && ff == 0) {
				cnt = 1;
				ff = 1;
		}
		else if(s[i] == 'Z' && ff == 1) {
				cnt++;
				mx = max(mx,cnt);
		}
		else if(ff == 1) cnt++;
	}
	cout << mx << endl;
}
	

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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) for(int i=int(n-1);i>=0;i--)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    int n,b; cin >> n >> b;
    int res = 0;
    while(n) n /= b, res++;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define ll long long int

ll mod=1e9+7;

int main(){
    int h,w;
    cin>>h>>w;
    vector<string> grid(h);
    for(int i=0;i<h;i++)cin>>grid[i];
    vector<vector<ll>> dp(h+1,vector<ll> (w+1));
    dp[0][1]=1;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(grid[i-1][j-1]=='.'){
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
                dp[i][j]%=mod;
            }
        }
    }
    cout<<dp[h][w]<<"\n";
    return 0;
}

Measured memory_bytes: 12964
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n, m;
    cin >> n >> m;
    using P = pair<int, int>;
    multiset<P> st;
    rep(i, n) {
        int a;
        cin >> a;
        st.emplace(a, 1);
    }
    rep(i, m) {
        int b, c;
        cin >> b >> c;
        st.emplace(c, b);
    }
    int now = 0;
    ll sum = 0;
    while (now < n) {
        P p = *st.rbegin();
        sum += 1LL * p.first * min(n - now, p.second);
        now += min(n - now, p.second);
        auto it = st.end();
        it--;
        st.erase(it);
    }
    cout << sum << endl;
}


Measured memory_bytes: 12976
#include <stdio.h>

int linearSearch(int A[],int n,int key)
{
  int i;
  for(i=0;i<n;i++)
    {
      if(A[i]==key)
	{
	  return 1;
	}
    }
return 0;
}

int main ()
{
  int i,n,n2,A[10000],key,judge=0;

  scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d",&A[i]);
    }
  
    scanf("%d",&n2);
      for(i=0;i<n2;i++){
	scanf("%d",&key);
      
     
    if(linearSearch(A,n,key))
      {
	judge++;
      }
      }
    printf("%d\n",judge);
    return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

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

int main()
{
    ll a,b;
    cin >> a >> b;
    cout << max({a+b,a-b,a*b}) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007
#define INF 1000000000
#define LLINF 2000000000000000000LL

int m,n;
int mm[10][10]={0};
int ch_y,ch_x;
int mo4[] = {0,1,0,-1,0};
int max_v = 1;

//map<pair<pair<int,int>,int>,int> memo;

//int memo[10][10][1<<23]={0};

int dfs(int y,int x,int v){
    int ret = 0;
    //pair<pair<int,int>,int> p = {{y,x},v};
    //if(memo[p]) return memo[p];
    
    //fprintf(stderr,"(%2d,%2d) : %d\n",x,y,v);
    
    for(int i=0;i<4;i++){
        int tox = x,toy = y;
        
        while(1){
            tox += mo4[i];
            toy += mo4[i+1];
            
            if(tox<0 || m<=tox || toy<0 || n<=toy) break;
            
            
            if(mm[toy][tox]==0) continue;
            
            if(mm[toy][tox]==-1){
                if(max_v == v){
                    return 1;
                }else{
                    continue;
                }
            }
            
            if(mm[toy][tox]&v) continue;
            
            ret += dfs(toy,tox,v|mm[toy][tox]);
            break;
        }
    }
    
    //fprintf(stderr,"memo[%2d][%2d][%2d] = %lld\n",x,y,v,ret%mod);
    /*
    if(__builtin_popcount(ret) <= 18)
        memo[p] = ret;
    */
    return ret;
}


void calc(int m,int n){
    
    //memset(memo,0,sizeof(memo));
    
    //memo.clear();
    
    max_v = 1;
    
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&mm[i][j]);
            
            if(mm[i][j]==1){
                mm[i][j] = max_v;
                max_v*=2;
            }else if(mm[i][j]==2){
                mm[i][j] = -1;
                ch_y = i;
                ch_x = j;
            }
        }
    }
    
    max_v--;
    
    printf("%d\n",dfs(ch_y,ch_x,0));
    
    return;
}

int main(){
    while(1){
        scanf("%d%d",&m,&n);
        if(m==0) break;
        calc(m,n);
    }
}

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

int main(){
  string s;
  cin>>s;
  if(s=="SUN")cout<<7<<endl;
  else if(s=="MON")cout<<6<<endl;
  else if(s=="TUE")cout<<5<<endl;
  else if(s=="WED")cout<<4<<endl;
  else if(s=="THU")cout<<3<<endl;
  else if(s=="FRI")cout<<2<<endl;
  else cout<<1<<endl;
}

Measured memory_bytes: 256
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    A,B,C,D,E,F = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    per = -1
    for a in range(0,F+1,100*A):
        for b in range(0,F+1,100*B):
            if a+b == 0:
                break
            for c in range(0,F+1,C):
                for d in range(0,F+1,D):
                    if a+b+c+d>F:
                        break
                    elif (c+d)/(a+b)>E/100:
                        break
                    else:
                        if per < (c+d)/(a+b+c+d):
                            per = (c+d)/(a+b+c+d)
                            cnt = [a+b+c+d, c+d]
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt[0],cnt[1])


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

const int N=100005;
const long long MOD=1e9+7;
int n;
long long dp[3005][3005],ans;
char str[N];

int main()
{
	scanf("%d%s",&n,str);
	dp[1][1]=1;
	for(int i=2;i<=n;i++)
	{
		if(str[i-2]=='<')
		{
			for(int j=2;j<=i;j++)
			{
				dp[i][j]=(dp[i][j-1]+dp[i-1][j-1])%MOD;
			}
		}
		else
		{
			for(int j=i-1;j>=1;j--)
			{
				dp[i][j]=(dp[i][j+1]+dp[i-1][j])%MOD;
			}
		}
	}
	for(int i=1;i<=n;i++) ans=(ans+dp[n][i])%MOD;
	printf("%lld\n",ans);
}

Measured memory_bytes: 69120
N = int(input())
L = list("abcdefghijklmnopqrstuvwxyz")
a = 1
while N > 26**a:
    N = N - 26**a
    a += 1

pre = []
for i in reversed(range(1,a)):
    r = (N-1) // 26**i
    pre.append(r)
    N = int(N%(26**i))

ans = ''
for i in pre:
    ans += L[i]
print(ans+L[N-1])

Measured memory_bytes: 9152
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ll ret   = a[0] - 1;
    ll price = 2;
    for (int i = 1; i < n; ++i) {
        if (a[i] == price)
            price++;
        else {
            if (a[i] % price == 0) {
                ret++;
                a[i] -= price + 1;
            }
            ret += a[i] / price;
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <cmath>
#include<algorithm>
//#include <bits/stdc++.h>

typedef long double ld;
typedef long long ll;

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
 //   freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
    ld n,t,x;cin>>n>>x>>t;
    ll v = ceil(n/x)*t;
    cout<<v;
    return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

#define INF 1<<29

using namespace std;

int main(void) {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());
	//cout << "s:" << s << "t:" << t;
	if (s < t) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,m=map(int, readline().rstrip().split())
    aa=list(map(int, readline().rstrip().split()))
    aa=sorted(aa,reverse=True)
    sth=sum(aa)
    yn(aa[m-1]>=sth/(4*m))
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 6340
def main():
    log_no, cut_max = [int(x) for x in input().split()]
    logs = [int(x) for x in input().split()]
    bin_l, bin_r = 0, 10 ** 9
    while bin_r - bin_l > 1:
        bin_mid = (bin_l + bin_r) // 2
        cut_count = sum((log - 1) // bin_mid for log in logs)
        if cut_count <= cut_max:
            bin_r = bin_mid
        else:
            bin_l = bin_mid
    print(bin_r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 30988
using System;
using System.Collections.Generic;
using System.Linq;
namespace AOJ {
  public class AOJ {
    public static void Main(string[] args) {
      double r = double.Parse(Console.ReadLine());
      Console.WriteLine("{0} {1}", r * r * Math.PI, 2 * r * Math.PI);
    }
  }
}

Measured memory_bytes: 9348
//DPCoded
	//

#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef set<int> si;
typedef set<string> ss;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef pair<int, int> ii;

	//#define FILEINOUT
#ifdef FILEINOUT
ifstream In("Input.txt");
ofstream Out("Output.txt");
#else
#define In cin
#define Out cout
#endif

vi v;

int check(int n) {
	int s = 0;
	for (int l : v) {
		if (l > n) s += l / n;
	}
	
	return s;
}

int main() {
	
	int n;
	In >> n;
	
	int k;
	In >> k;
	
	for (int i = 0; i < n; i++) {
		int t;
		In >> t;
		v.push_back(t);
	}
	
	int l = 1;
	int r = 1000000000;
	int m;
	
	while (l + 1 < r) {
		m = (l + r) / 2;
		
		int need = check(m);
		
		if (need > k) l = m;
		else r = m;
	}
	
	if (check(l) <= k) Out << l;
	else Out << r;
	Out << endl;
	
	
	return 0;
}


Measured memory_bytes: 3872
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;
 
void testCase() {
    db l;
    cin >> l;
    db x = l/3;
    db y = (l-x)/2;
    db z = (l-x-y);
    db ans = x*y*z;
    cout << fixed << setprecision(15) << ans << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

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

int main()
{
  string o, e, ans;
  ans = "";
  cin >> o >> e;

  for (int i = 0; i < o.size(); i++)
  {
    cout << o[i];
    if (i < e.size())
    {
      cout << e[i];
    }
  }
  cout << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int N = 4010;
const int MAX_N = 3000009;
#define ll long long
int a[30], b[30];
struct Node {
	int fi, sc, tr;
};
vector<Node> mp[MAX_N];
const int mod1 = 10000007;
const int mod2 = 38424785;
const int mod3 = MAX_N;
const int pp1 = 324;
const int pp2 = 94589;
char s1[N], s2[N];
int len1, len2;
ll p1[30], p2[30];
int main() {
	p1[0] = p2[0] = 1;
	for (int i = 1; i <= 26; i++)
		p1[i] = p1[i - 1] * pp1 % mod1;
	for (int i = 1; i <= 26; i++)
		p2[i] = p2[i - 1] * pp2 % mod2;
	cin >> s1 >> s2;
	len1 = strlen(s1);
	len2 = strlen(s2);
	ll h1, h2;
	int  res = 0;
	for (int i = 0; i < len1; i++) {
		memset(a, 0, sizeof(a));
		for (int j = i; j < len1; j++) {
			a[s1[j] - 'a']++;
			h1 = h2 = 0;
			for (int k = 0; k < 26; k++)
				if (a[k]) {
					h1 += a[k] * p1[k];
					h1 %= mod1;
					h2 += a[k] * p2[k];
					h2 %= mod2;
				}
			ll H = (h1 << 15) ^ h2;
			H %= mod3;
			//if (i == 0 && j == len1 - 1)
			//	printf("1H % lld % lld %lld \n", h1, h2, H);
			mp[H].push_back((Node){(int)h1, (int)h2, j - i});
		}
	}
	for (int i = 0; i < len2; i++) {
		memset(b, 0, sizeof(b));
		for (int j = i; j < len2; j++) {
			b[s2[j] - 'a']++;
			h1 = h2 = 0;
			for (int k = 0; k < 26; k++)
				if (b[k]) {
					h1 += b[k] * p1[k];
					h1 %= mod1;
					h2 += b[k] * p2[k];
					h2 %= mod2;
				}
			ll H = (h1 << 15) ^ h2;
			H %= mod3;
			//printf("%d %d----\n", i, j);
			//if (i == 0 && j == len1 - 1)
			//	printf("2H % lld % lld %lld \n", h1, h2, H);
			for (int k = 0; k < mp[H].size(); k++)
				if (mp[H][k].fi == h1 && mp[H][k].sc == h2 &&
					mp[H][k].tr == j - i) {
					res = max(res, j - i + 1);
				}
		}
	}
	cout << res << endl;
	return 0;
}

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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const long long int MOD = 1e9 + 7;
const int MAXN = 2e5 + 10, MAX_FACTORIAL = 1e6 + 10;

ll REM( ll a )
{
	a %= MOD;
	if ( a < 0 )
	   a += MOD;
	return a;
}

ll ADD( ll a, ll b )
{
	return REM( REM( a ) + REM( b ) );
}

ll SUB( ll a, ll b )
{
	return REM( REM( a ) - REM( b ) );
}

ll MUL( ll a, ll b )
{
	return REM( REM( a ) * REM( b ) );
}

ll POT( ll n, ll k )
{
	if ( k == 0 )
		return 1;

	ll ret = POT( n, k / 2 );
	ret = MUL( ret, ret );

	if ( k % 2 )
		return MUL( ret, n );
	return ret;
}

ll DIV( ll a, ll b )
{
	return MUL( a, POT( b, MOD - 2 ) );
}

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

ll fact[ MAX_FACTORIAL ];
void factorials( )
{
	fact[ 0 ] = 1;
	FOR( i, 1, MAX_FACTORIAL )
	{
		fact[ i ] = MUL( fact[ i - 1 ], i );
	}
}

ll CHOOSE( ll n, ll k )
{
	return DIV( fact[ n ], MUL( fact[ k ], fact[ n - k ] ) );
}

string a, b;

int main()
{
	cin >> a >> b;
	cout << b << a << "\n";
	return 0;
}


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

//?#define FILE_AS_IO
#define SYNC_IO ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);

int main() {
#ifdef FILE_AS_IO
    freopen("1.in","r",stdin);
    freopen("1.out","w",stdout);
#endif
    SYNC_IO;
    
    int n;
    cin>>n;
    if (n >= 30) cout<<"Yes";
    else cout<<"No";
    
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

ll modpow(ll a,ll n,ll m=inf){
    ll res=1;
    while(n){
        if(n&1)res=res*a%m;
        a=a*a%m;
        n>>=1;
    }
    return res;
}

int main(){
    ll n,k;cin>>n>>k;
    vll num(k+1);
    ll ans=(ll)0,res,sum;
    for(ll i=k;i>0;i--){
        res=k/i;
        sum=modpow(res,n);
        for(ll j=2*i;j<=k;j+=i){
            sum-=num[j];
            if(sum<0)sum+=inf;
        }
        num[i]=sum;
        ans+=i*sum;ans%=inf;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4000
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <cstdio>

using namespace std;
using namespace atcoder;

using mint = modint998244353;

struct S {
    mint a;
    int size;
};

struct F {
    mint a, b;
};

S op(S l, S r) { return S{l.a + r.a, l.size + r.size}; }

S e() { return S{0, 0}; }

S mapping(F l, S r) { return S{r.a * l.a + r.size * l.b, r.size}; }

F composition(F l, F r) { return F{r.a * l.a, r.b * l.a + l.b}; }

F id() { return F{1, 0}; }

int main() {
    int n, q;
    scanf("%d %d", &n, &q);

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

    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);

    for (int i = 0; i < q; i++) {
        int t;
        scanf("%d", &t);
        if (t == 0) {
            int l, r;
            int c, d;
            scanf("%d %d %d %d", &l, &r, &c, &d);
            seg.apply(l, r, F{c, d});
        } else {
            int l, r;
            scanf("%d %d", &l, &r);
            printf("%d\n", seg.prod(l, r).a.val());
        }
    }
}


Measured memory_bytes: 19256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.lang.*;

public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] s = br.readLine().split(" ", 0);
        int n = Integer.parseInt(s[0]);
        int q = Integer.parseInt(s[1]);
        
        Stack[] stacks = new Stack[n];
        for (int i = 0; i < n; i++) {
            stacks[i] = new Stack();
        }
        
        String[] l;
        String command;
        int t, x;
        for (int i = 0; i < q; i++) {
            l = br.readLine().split(" ", 0);
            command = l[0];
            t = Integer.parseInt(l[1]);
            switch (command) {
                case "0":
                    x = Integer.parseInt(l[2]);
                    stacks[t].push(x);
                    break;
                case "1":
                    stacks[t].top();
                    break;
                case "2":
                    stacks[t].pop();
                    break;
            }
        }
    }
}

class Stack {
    ArrayList<Integer> a;
    
    Stack() {
        a = new ArrayList<Integer>();
    }
    
    void push(int x) {
        a.add(x);
    }
    
    void top() {
        int size = a.size();
        if (size != 0) {
            System.out.println(a.get(a.size() - 1));
        }
    }
    
    void pop() {
        int size = a.size();
        if (size != 0) {
            a.remove(a.size() - 1);
        }
    }
}


Measured memory_bytes: 67416
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x1 = sc.nextInt();
    int y1 = sc.nextInt();
    int x2 = sc.nextInt();
    int y2 = sc.nextInt();
    int x3 =0,x4 =0,y3 =0,y4 =0;
    int x = Math.abs(x1 - x2);
    int y = Math.abs(y1 - y2);
    if (x1 == x2 && y1 > y2) {
      x3 = x1 + y; y3 = y2;
      x4 = x1 + y; y4 = y1;
    }
    if (x1 == x2 && y1 < y2) {
      x3 = x1 - y; y3 = y2;
      x4 = x1 - y; y4 = y1;
    }
    if (x1 > x2 && y1 == y2) {
      x3 = x2; y3 = y2 - x;
      x4 = x1; y4 = y2 - x;
    }      
    if (x1 < x2 && y1 == y2) {
      x3 = x2; y3 = y1 + x;
      x4 = x1; y4 = y1 + x;
    }      
    if (x1 > x2 && y1 > y2) {
      x3 = x2 + y; y3 = y2 - x;
      x4 = x1 + y; y4 = y1 - x;
    }
    if (x1 < x2 && y1 > y2) {
      x3 = x2 + y; y3 = y2 + x;
      x4 = x1 + y; y4 = y1 + x;
    }
    if (x1 > x2 && y1 < y2) {
      x3 = x2 - y; y3 = y2 - x;
      x4 = x1 - y; y4 = y1 - x;
    }
    if (x1 < x2 && y1 < y2) {
      x3 = x2 - y; y3 = y2 + x;
      x4 = x1 - y; y4 = y1 + x;
    }
    System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
  }
}

Measured memory_bytes: 22612