akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define isSquare(x) (sqrt(x)*sqrt(x) == x)
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;

static const int MAX=3005;

ll MOD;
ll fact[MAX], fact_inv[MAX];

ll comb(ll n, ll r){
    return (fact[n] * fact_inv[r]) % MOD * fact_inv[n-r] % MOD;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}//mod mでの逆元aを計算

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    iosetup;
    int p; IN(p);
    MOD = p;
    vector<int> a(p);
    rep(i, 0, p) cin >> a[i];

    fact[0] = 1;
    for(int i = 0; i < MOD - 1; i++) fact[i+1] = fact[i] * (i+1) % MOD;
    fact_inv[MOD-1] = modpow(fact[MOD-1], MOD - 2, MOD);
    for(int i = MOD - 2; i >= 0; i--) fact_inv[i] = fact_inv[i+1]*(i+1) % MOD;

    cout << a[0];
    rep(i, 1, p){
        ll ans = 0;
        rep(j, 0, p) if(a[j] == 1){
            if(((p-1-i)&1) == 0) ans -=(comb(p-1, i) * modpow(j,p-1-i, p));
            else ans += comb(p-1, i) * modpow(j, p-1-i, p);
        }
        // cerr << ans << endl;
        ans %= p;
        if(ans < 0) ans += p;
        cout << " ";
        cout << ans;
    }
    cout << endl;
    
    return 0;
}

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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int n,m;cin>>n>>m;
  int cnt[n+1] ={};
  int a,b;
  rep(i, m){
    cin>>a>>b;
    cnt[a]++;
    cnt[b]++;
  }

  int odd = 0;
  rep(i, n+1){
    if (cnt[i]%2==1) odd++;
  }

  cout << (odd<=1 ? "YES" : "NO") << endl;



  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 1024
n = int(input()) 
t = [int(i) for i in input().split()] 
c = []
for i in range (n):
  a = 0
  b = t[i]
  while b%2 == 0:
    b = b/2
    a += 1
  c.append(a)
print(min(c))
    

Measured memory_bytes: 2940
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if(n<=9){
      if(n==2||n==4||n==5||n==7||n==9){
        System.out.println("hon");
      }else if(n==0||n==1||n==6||n==8){
        System.out.println("pon");
      }else{
        System.out.println("bon");
      }
    }else if(n>=10 && n<=99){
      int l = n/10;
      int m = n-l*10;
      if(m==3){
        System.out.println("bon");
      }else if(m==0||m==1||m==6||m==8){
        System.out.println("pon");
      }else{
        System.out.println("hon");
      }
    }else{
      int x = n/100;
      int y = (n-x*100)/10;
      int z = n-(x*100+y*10);
      if(z==2||z==4||z==5||z==7||z==9){
        System.out.println("hon");
      }else if(z==0||z==1||z==6||z==8){
        System.out.println("pon");
      }else{
        System.out.println("bon");
      }
    }
  }
}


Measured memory_bytes: 35784
from heapq import heappop, heappush

n = int(input())
g = [[] for i in range(n)]
for i in range(n):
    u, k, *l, = map(int, input().split())
    for j in range(k):
        v, c = l[j*2], l[j*2+1]
        g[u].append([v, c])

'''
ダイクストラ法による単一始点最短経路
二分ヒープ（優先度付きキュー）による高速化
'''
d = [2**64]*n
d[0] = 0
h = []
heappush(h, (0, 0))

m = [False]*n
while len(h) > 0:
    c, u = heappop(h)
    m[u] = True
    if d[u] < c:
        continue
    for gv, gc in g[u]:
        if not m[gv] and d[u]+gc < d[gv]:
            d[gv] = d[u]+gc
            heappush(h, (d[u]+gc, gv))

for i in range(n):
    print(f"{i} {d[i]}")



Measured memory_bytes: 76700
import java.util.Scanner;

class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int w=sc.nextInt();
int n=sc.nextInt();
int[] k=new int[w];
for(int i=0;i<w;i++){
k[i]=i+1;
}
for(int j=0;j<n;j++){
String[] line=sc.next().split(",");
int p=Integer.parseInt(line[0]);
int q=Integer.parseInt(line[1]);
int r=k[p-1];
k[p-1]=k[q-1];
k[q-1]=r;
}
for(int l=0;l<w;l++){
System.out.println(k[l]);
}
}
}

Measured memory_bytes: 17332
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1LL<<62;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    map<int,int> ct;
    rep(i,n) {
        int x; cin >> x;
        ct[x+1]++; ct[x]++; ct[x-1]++;
    }
    int ans = 0;
    for (auto itr = ct.begin(); itr != ct.end(); itr++) {
        ans = max(ans,itr->second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4736
/*💚💚💚 ITS A SLOW PROCESS BUT QUITING WONT SPEED IT UP 💚💚💚*/

#include<bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <complex>
#include <cctype>

using namespace std;

/*-------------define----------------------------*/
#define ff              first
#define ss              second
#define ll             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ceilval(a,b)    (a+b-1)/ b
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define cf(x)            ll x; cin>>x; while(x--)

/*---------------bak****i end-----------------------*/


void zaroorat()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}


int main()

  {
      zaroorat();


        ll n,k;
        cin>>n>>k;
        ll arr[n];
        for (ll i = 0; i < n; i++) {
          cin>>arr[i];
        }
        sort(arr,arr+n);
        ll su=0;
        ll i=0;
        while(k>0){
          su+=arr[i];
          i++;
          k--;
        }

        cout<<su<<endl;




    return 0;
  }


Measured memory_bytes: 3640
// finish date: 2018/07/16
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>>
        vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    string S;
    cin >> S;
    int N = S.size();
    int c1 = 0;
    int c2 = 0;
    int c3 = 0;
    rep(i, N) {
        if (S[i] == 'a') c1++;
        else if (S[i] == 'b') c2++;
        else c3++;
    }
    int ma = max({c1, c2, c3});
    int mi = min({c1, c2, c3});
    if (ma - mi <= 1) cout << "YES" << endl;
    else cout << "NO" << endl;


    return 0;
}



Measured memory_bytes: 512
def solve(s):
    pos_num, neg_num = 0, 0
    for string in s:
        if string == "1":
            pos_num += 1
        else:
            neg_num += 1

    return 2 * min(pos_num, neg_num)


def main():
    s = input()

    ans = solve(s)
    print(ans)


main()


Measured memory_bytes: 3188
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( ) 
* special cases (n=1?)
* overflow (ll vs int?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

// Author:: Subash Singha Roy
// Institution:: Jalpaiguri Government Engineering College

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (int)(1e9+7)
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) int t;cin >>t;while(t--)
#define pb(i) push_back(i)
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll> 
#define ff first
#define ss second
#define inf 999999999999999999
ll mult(ll a,ll b, ll p=mod){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = mod) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2, p);}
bool sa(const pair<int,int> &a,const pair<int,int> &b){return (a.second<b.second);}
bool fd(const pair<int,int> &a,const pair<int,int> &b){return (a.first>b.first);}
bool sd(const pair<int,int> &a,const pair<int,int> &b){return (a.second>b.second);}

int main(){
fio
ll n,ww;
cin>>n>>ww;
ll w[n+5],val[n+5];
fr(i,1,n+1){
    cin>>w[i]>>val[i];
}
ll k[n+2][ww+2];
fr(i,0,n+1){
    fr(j,0,ww+1){
        if(i==0 || j==0){
            k[i][j]=0;
        }
        else if(w[i]<=j){
           k[i][j]=max((val[i]+k[i-1][j-w[i]]),k[i-1][j]);
        }
        else{
            k[i][j]=k[i-1][j];
        }
    }
}
cout<<k[n][ww];
rr;}

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

int main() {
  int a[3];
  for (int i = 0; i < 3; i++)
  cin >> a[i];
  
  sort(a, a+3);
  
  int ans = a[1]-a[0] + a[2]-a[1];
  cout << ans << endl;
}

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

#define MAX 100000
#define INF (1<<30)
#define BLACK 0
#define GRAY 1
#define WHITE 2

int n;
vector< pair<int,int> > graph[MAX];
int d[MAX];

// プロトタイプ宣言
void dijkstra(int r);
// ここまで

int v,e;
int main(){
	int r;
	cin>>v>>e>>r;
	int s,t,cost;
	for(int i=0;i<e;i++){
		cin>>s>>t>>cost;

		graph[s].push_back( make_pair(t,cost) );
	}

	dijkstra(r);

	for(int i=0;i<v;i++){
		if(d[i]==INF)cout<<"INF"<<endl;
		else cout<<d[i]<<endl;
	}

	return 0;
}

void dijkstra(int r){
	priority_queue< pair<int,int> > PQ;
	int color[MAX];
	for(int i=0;i<v;i++){
		d[i]=INF;
		color[i]=WHITE;
	}

	d[r]=0;
	PQ.push(make_pair(0,r));		// （重み、ノード番号）
	color[r]=GRAY;


	while(PQ.empty()==false){
		pair<int,int> f=PQ.top();	PQ.pop();
		int from = f.second;
		color[from]=BLACK;

		if(d[from] < f.first*(-1) )continue;

		for(pair<int,int> next:graph[from]){
			int to=next.first;
			int w=next.second;
			if(color[to]==BLACK) continue;

			if(d[to]>d[from]+w){
				d[to]=d[from]+w;

				PQ.push( make_pair(d[to]*(-1), to) );
				color[to]=GRAY;
			}
		}
	}
}



Measured memory_bytes: 13396
/*input
100000 5
*/
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
int const mod = 1e9+7;
int power(int x, int y, int mod = 2e18){ int ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
int gcd(int a , int b){if(a==0)return b;return gcd(b%a,a);}

signed main() {
  IOS;
  double n,k;
  cin>>n>>k;
  long double ans = 0 ; 
  for(int i=1;i<=n;i++){
    if(i>=k){
      ans += 1.0/n;
      continue;
    }
    int ct = 0 ; 
    int N = i ;
    while(N<k){
      ct++;
      N*=2;
    }
    ans += (1/(n*(1<<ct)));
  }
  cout << setprecision(30)<<fixed;
  cout << ans << endl ;
return 0;
}

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;
typedef long double ld;



void solve() {
	ll x;
	cin >> x;
	ll st = 100;
	int ptr = 0;
	while (st < x) {
		ll add = st / 100ll;
		st += add;
		++ptr;
	}
	cout << ptr << endl;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
	return 0; 
}

Measured memory_bytes: 3616
n = input()
A = list(map(int, input().split()))

def Chk(a, pos):
    cnt = 0
    tmp = 0

    for a in A:
        tmp += a

        if pos and tmp < 1:
            cnt += 1 - tmp
            tmp = 1
        elif not pos and tmp > -1:
            cnt += 1 + tmp
            tmp = -1

        pos = not pos
    return cnt

print(min(Chk(A, True), Chk(A, False)))

Measured memory_bytes: 14332
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 5005, M = 205 ;
using namespace std ;
int n, m, g[N][M], top[M], st[M][N]; ll  a[N], f[N], bit[N] ;
inline void add(int l, int r, ll x) { bit[l] += x, bit[r + 1] -= x ; }
int main() {
	scanf("%d%d", &n, &m) ;
	rep(i, 2, n) scanf("%lld", &a[i]) ;
	a[1] = 0 ; rep(i, 2, n) a[i] += a[i - 1] ;
	rep(i, 1, n) rep(j, 1, m) scanf("%d", &g[i][j]) ;
	ll ans = 0 ;
	rep(i, 1, m) top[i] = 0, st[i][0] = n + 1 ;
	rep(i, 1, n) f[i] = - a[i] ;
	for (int l = n ; l; -- l) {
		rep(i, 1, n) bit[i] = 0 ; 
		rep(i, 1, m) {
			for ( ; top[i] && g[l][i] >= g[st[i][top[i]]][i] ; -- top[i]) add(st[i][top[i]], st[i][top[i] - 1] - 1, - g[st[i][top[i]]][i]) ;
			st[i][++ top[i]] = l ;
			add(st[i][top[i]], st[i][top[i] - 1] - 1, g[st[i][top[i]]][i]) ;
		}
		rep(i, 2, n) bit[i] += bit[i - 1] ;
		rep(i, l, n) f[i] += bit[i], ans = max(ans, f[i] + a[l]) ;
	}
	printf("%lld\n", ans) ;
	return 0 ;
}

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

int main() {
  string a_s, b_s;
  
  cin >> a_s >> b_s;
  
  int input = stoi(a_s + b_s);
  
  float sqrt_input = sqrt(input);
  
  if (pow(sqrt_input, 2.0) == input) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define fi first
#define se second
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0)
#define go_t int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
typedef tree<pair<ll,ll>,null_type,less<pair<ll,ll>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // order_of_key
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf = 0x3f3f3f3f3f3f3f3fll;//4x10e18
const int maxx = 3000000 , mod = 1000000007;
#define PI 3.14159265
int main()
{
    fastio;
    int k,a,b;
    cin>>k>>a>>b;

    for(int i=1;;i++)
    {
        if((k*i)>=a && (k*i)<=b)
        {
            cout<<"OK"<<endl;
            return 0;
        }
        else if((k*i)>b)
        {
            cout<<"NG"<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

#define int long long

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

signed main(){
    int n, m; cin>>n>>m;
    vector<int> s(n), t(m);
    for(int i=0; i<n; i++) cin>>s[i];
    for(int i=0; i<m; i++) cin>>t[i];

    vector<vector<ll>> dp(2010, vector<ll>(2010, 0));
    ll num = 1;
    for(int i=0; i<n; i++){
        if(s[i] == t[0]){
            num++; 
        }
        
        dp[1][i+1] = num;
    }

    num = 1;
    for(int i=0; i<m; i++){
        if(s[0] == t[i]){
            num++;
        }
        
        dp[i+1][1] = num;
    }


    for(int i=1; i<m; i++){
        for(int j=1; j<n; j++){
            if(s[j] == t[i]){
                (dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j]) %= MOD;
            }
            else{
                (dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j] - dp[i][j] + MOD) %= MOD;
            }
        }
    }

    cout << dp[m][n] % MOD << endl;
}

Measured memory_bytes: 31872
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: chars
    }
    if (n[0] == n[1] || n[2] == n[3]) && n[1] == n[2] {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define r_rep(i, n) for(int i = n; i >= 0; i--)
#define ll long long int
#define pb push_back

const long long INF = 1LL << 60;
vector<ll> hint(100000);

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

void init(){
  rep(i, 100000){
    hint[i] = (i+1)*(i+2)/2;
  }
}

int main() {
  ll a, ans = 0;
  cin >> a;
  init();
  map<ll, ll> dictionary = prime_factor(a);

  for (const auto& [key, value] : dictionary){
    // cout << key << " => " << value << "\n";
    rep(i, 100000){
      if (value < hint[i]){
        ans += i;
        break;
      }
    }
  }
  print(ans);
}


Measured memory_bytes: 3460
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	lli a,b,v,w,t;
	cin >> a >> v >> b >> w >> t;
	if( a== b){
		cout << "YES" <<newl;
		return;
	}
	if(w >= v){
		cout << "NO" << newl;
		return;
	}
	lli c = abs(a - b);
	lli x = abs(v - w);
	if(c <= x * t) cout << "YES" << newl;
	else cout << "NO" << newl;

	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3648
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 1000000007

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{
    int n, m, k;
    cin >> n >> m >> k;

    vector<int> a(n);
    vector<int> b(m);

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

    for(int i = 0; i < m; i++)
    {
        cin >> b[i];
    }

    ll L = 0;
    ll R = 0;

    ll count = 0;

    while(count + a[L] <= k)
    {
        count += a[L];
        L++;
        if(L == n)
        {
            break;
        }
    }

    if(L == n || count < k)
    {
        while(count + b[R] <= k)
        {
            count += b[R];
            R++;
             if(R == m)
            {
                break;
            }
        }
    }


    if(R == m && L == n)
    {
        cout << n + m << "\n";
        return;
    }

    ll ans = L + R;

    //debug(R);
    //debug(L);

    L--;

    while(L >= 0 && R < m)
    {
        count -= a[L];
        L--;

        while(count + b[R] <= k)
        {
            count += b[R];
            R++;
            if(R == m)
            {
                break;
            }
        }

        //debug(ans);
        ans = max(ans, L + R + 1);
    }

    cout << ans << "\n";
 
}

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

    int T = 1;
    //cin >> T;
    
    while (T--)
    {
        solve();
    }
    
    return 0;
}



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

using namespace std;

int main(){

	int n, flag=0;

	cin>> n;

	for(int i=1;i<10;i++){
		if(n%i==0 && 0<n/i && n/i<10) flag=1;
	}

	if(flag) cout<< "Yes" <<endl;
	else cout<< "No" <<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int n,k;
    cin>>n>>k;
    if(2*k-1>n){
        cout<<-1<<endl;
        return 0;
    }
    vector<pair<int,pair<int,int>>> p;
    for(int i=0;i<(n+1)/2;i++){
        int a=k+i;
        int b=k+n+n-(n+1)/2+i;
        p.push_back({a+b,{a,b}});
    }
    for(int i=0;i<n-(n+1)/2;i++){
        int a=k+(n+1)/2+i;
        int b=k+n+i;
        p.push_back({a+b,{a,b}});
    }
    sort(p.begin(),p.end());
    for(int i=0;i<n;i++){
        cout<<p[i].second.first<<" "<<p[i].second.second<<" "<<k+2*n+i<<endl;
    }
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

int main() {
	int N, M; cin >> N >> M;
	vector<int> p(N);
	rep(i, N) scanf("%d", &p[i]), p[i]--;
	union_find uf(N);
	while (M--) {
		int i, j; scanf("%d%d", &i, &j), i--, j--;
		uf.unite(i, j);
	}
	vector<vector<int>> a(N), b(N);
	rep(i, N) {
		int k = uf.find(i);
		a[k].pb(i), b[k].pb(p[i]);
	}
	int ans = 0;
	rep(k, N) if (!a[k].empty()) {
		set<int> st(b[k].begin(), b[k].end());
		for (int x: a[k]) if (st.count(x)) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 11904
import heapq
n,k=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
x=[l[i][0] for i in range(n)]
x.sort()
y=[l[i][1] for i in range(n)]
y.sort()
ans=[]
for i1 in range(n):
  for i2 in range(i1+1,n):
    for i3 in range(n):
      for i4 in range(i3+1,n):
        ct=0
        for i5 in range(n):
          if x[i1]<=l[i5][0]<=x[i2] and y[i3]<=l[i5][1]<=y[i4]:ct+=1
        if ct>=k:
          ans.append(abs(x[i1]-x[i2])*abs(y[i3]-y[i4]))
heapq.heapify(ans)
print(heapq.heappop(ans))

Measured memory_bytes: 113116
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	m := make(map[string][][2]int)
	for i := 0; i < n; i++ {
		s, p := Scan(), iScan()
		m[s] = append(m[s], [2]int{p, i + 1})
	}
	name := make([]string, 0, n)
	for k, _ := range m {
		name = append(name, k)
	}
	sort.Strings(name)
	for _, v := range name {
		sort.Slice(m[v], func(i, j int) bool { return m[v][i][0] > m[v][j][0] })
		for _, w := range m[v] {
			fmt.Println(w[1])
		}
	}
}


Measured memory_bytes: 1772
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iterator>
#include <algorithm>
#include <map>
#include <string.h>
#include <vector>
#include <cmath>
#include <deque>
#include <iomanip>

using namespace std;
#define range(a) a.begin(), a.end()
#define rep(i, c) for(int i = 0; i < (int)c; i++)
typedef long long ll;

template <typename T> ostream& operator<<(ostream& out, vector<T> &v){
  for (int i = 0; i < (int)v.size(); i++) {
    out<<v[i]<<' ';
  }
  return out;
}

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

  // float n; cin >> n;
  //
  // cout << n * 2 * 3.141592653589 << endl;

  // int n, m; cin >> n >> m;
  // vector<int> a(m);
  // int sum = 0;
  // rep(i, m){
  //   cin >> a[i];
  //   sum += a[i];
  // }
  // if(sum == n) cout << 0 << endl;
  // else if (sum < n) cout << n - sum << endl;
  // else cout << -1 << endl;

  int n; cin >> n;
  vector<int> a(n + 10, 0);
  vector<int> ans(n + 10, 0);
  a.push_back(0);
  for(int i = 1; i < n; i++){
    cin >> a[i];
    ans[a[i]]++;
  }
  for(int i = 0; i < n; i++){
    cout << ans[i + 1] << endl;
  }








  return 0;
}


Measured memory_bytes: 5576
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <math.h>
using namespace std;
typedef long long int ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define FOREQ(i, a, b) for (int i = (a); i <= (b); i++)
#define REPEQ(i, n) FOREQ(i, 0, n)

int main()
{
  int A, B, X;
  cin >> A >> B >> X;

  if (A <= X && X <= A + B)
  {
    printf("YES\n");
  }
  else
  {
    printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 256
#グラフの初期化
import itertools

n, m = map(int, input().rstrip().split())
mylist = [[0 for j in range(n)] for i in range(n)]

for i in range(m):
    a, b = map(int, input().rstrip().split())
    mylist[a-1][b-1] = 1

vist = [i for i in range(1, n)]

result = 0
for v in itertools.permutations(vist):
    index = 0
    mylist2 = mylist[:]
    past = 0
    for i in v:
        a = min(past, i)
        b = max(past, i)
        if mylist2[a][b] != 1:               
            break
        past = i
        index += 1
    if index == n-1:
        result += 1
        
print(result)

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

int main(){
    long long X;
    cin >> X;
    for(long long a =0; pow(a,5)-pow(a-1,5)<=X; a++){
        for(long long b = 0; b < a; b++){
            if(pow(a,5) - pow(b,5) == X){
                cout << a << " "<< b << endl;
                return 0;
            }
        }
        for(long long b =0; pow(b,5) >= -X; b--){
            if(pow(a,5) - pow(b,5) == X){
                cout << a << " "<< b << endl;
                return 0;
            }
        }
    }            
}

Measured memory_bytes: 4024
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int N;
    cin >>N;
    cout<<N*N*N<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int sol, v[20], c[20];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> v[i];
    for (int i = 0; i < n; ++i)
        cin >> c[i];

    for (int i = 0; i < n; ++i)
        if (v[i] > c[i])
            sol += v[i] - c[i];
    cout << sol;
}


Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    nameCount = [0] * 5
    N = int(input())
    for _ in range(N):
        s = input().strip("\n")
        if s[0] == "M": nameCount[0] += 1
        elif s[0] == "A": nameCount[1] += 1
        elif s[0] == "R": nameCount[2] += 1
        elif s[0] == "C": nameCount[3] += 1
        elif s[0] == "H": nameCount[4] += 1
        else: continue
    Ans = 0
    for i in range(3):
        for j in range(i+1, 4):
            for k in range(j + 1, 5):
                Ans += nameCount[i] * nameCount[j] * nameCount[k]
    print(Ans)


    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
#define ll long long
#define NUM 1000000007

int main(){
    int n;
    cin >> n;
    ll ans=3;
    int tile[n][2];
    bool secondary=false;
    bool ispreV=false;
    for(int i=0;i<n;i++){
        char a;
        cin >>a;
        tile[i][0]=(int)a;
    }
    for(int i=0;i<n;i++){
        char a;
        cin >>a;
        tile[i][1]=(int)a;
        if (tile[i][0]==tile[i][1]){//縦か？
            if(ispreV){
                ans=(ans*2)%NUM;
                secondary=true;
            }else{
                ans=ans;
                secondary=true;
            }
            ispreV=true;
        }else if (i>0 && tile[i][0]==tile[i-1][0]){//横か？
            if(ispreV){
                ans=(ans*2)%NUM;
            }else if(secondary){
                ans=(ans*3)%NUM;
            }else{
                ans=6;
                secondary=true;
            }
            ispreV=false;
        }
    }
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// AOJ 0143 Altair and Vega
// 2017.8.8 bal4u@uu
// 2017.11.1 retry

#include <stdio.h>

char buf[102], *p;
int getint()
{
	int n = 0;
	if (*p == '-') {
		p++;
		while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
		return -n;
	}
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int atSameSide(int x1, int y1, int x2, int y2, int xa, int ya, int xb, int yb)
{
	long long sa, sb;

	sa = (x2 - x1) * (ya - y1) + (y2 - y1) * (x1 - xa);
	sb = (x2 - x1) * (yb - y1) + (y2 - y1) * (x1 - xb);
//	if (sb == 0 || sa == 0) while (1);  				// xb,yb in line
	return (sa > 0 && sb > 0 || sa < 0 && sb < 0);      // xa,ya xb,yb at same side
}

int main()
{
	int n;
	int x1, y1, x2, y2, x3, y3, xk, yk, xs, ys;
	int kin, sin;

	fgets(p=buf, 10, stdin); n = getint();
	while (n-- > 0) {
		fgets(p=buf, 100, stdin);
		x1 = getint(), p++, y1 = getint(), p++;
		x2 = getint(), p++, y2 = getint(), p++;
		x3 = getint(), p++, y3 = getint(), p++;
		xk = getint(), p++, yk = getint(), p++;
		xs = getint(), p++, ys = getint();

		kin = atSameSide(x1, y1, x2, y2, x3, y3, xk, yk) &
			  atSameSide(x2, y2, x3, y3, x1, y1, xk, yk) &
			  atSameSide(x3, y3, x1, y1, x2, y2, xk, yk);
		sin = atSameSide(x1, y1, x2, y2, x3, y3, xs, ys) &
		  	  atSameSide(x2, y2, x3, y3, x1, y1, xs, ys) &
			  atSameSide(x3, y3, x1, y1, x2, y2, xs, ys);
		puts((kin ^ sin) ? "OK" : "NG");
	}
	return 0;
}

Measured memory_bytes: 1628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n;
vector<int>b,ans;
int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
		int x;
		scanf("%d",&x);
		b.PB(x);
	}
    while(b.size()>0){
		bool ok=false;
		for(int i=b.size()-1;i>=0;i--){
			if(b[i]==i+1){
				ok=true;
				b.erase(b.begin()+i);
				ans.PB(i+1);
				break;
			}
		}
		if(!ok)break;
	}
	if(ans.size()!=n)printf("-1\n");
	else{
		for(int i=n-1;i>=0;i--)printf("%d\n",ans[i]);
	}
}


Measured memory_bytes: 256
module Main where

import Numeric
import Data.Functor

main :: IO ()
main = do
  { [a,b] <- getInts
  ; let (q,r) = divMod a b
  ; let s = fromIntegral  a / fromIntegral b
  ; putStrLn . unwords $ [show q, show r, showFFloat Nothing s ""]
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

done :: IO ()
done = return ()

Measured memory_bytes: 3876
#include<bits/stdc++.h>		
using namespace std;
int maxn=0,sum=0;
int n;
char c;
int main(){
	cin>>n;
	for(int i=1; i<=n; i++){
		cin>>c;
		if(c=='I') maxn=max(maxn,++sum);
		if(c=='D') --sum;
	}
	cout<<maxn<<endl;
}

Measured memory_bytes: 256
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

N = int(input())

div = make_divisors(N)
ans = len(str(N))
ans = min(ans,len(str(div[-1])))
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define REP(i,a,b) for(i=a;i<=b;i++)
using namespace std;
int main () {
  int a, b, c, i, count = 0;
  cin >> a >> b >> c;
  REP(i, a, b) {
    if (c % i == 0) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3096
import scala.io.Source

object Main{
  def main(args: Array[String]){
    val line =
      for{
        in <- Source.stdin.getLines.toList
      } yield in.map(c => c.toLower)

    def numOfChar(s: String, c:Char):Int = {
      if(s.indexOf(c) == -1) 0
      else if(s.indexOf(c) >= 0) 1 + numOfChar(s.drop(s.indexOf(c)).tail, c)
      else 0
    }

    ('a' to 'z').foreach(c => println(c + " : " + numOfChar(line.mkString,c)))
  }
}

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

bool check(string s){
  sort(s.begin(),s.end());
  if(s=="AADINNUY")return true;
  return false;
}

void change(int x){
  string t="AIZUNYAN";
  for(int i=0;i<(int)t.size();i++,x++)s[x]=t[i];
}

int main(){
  cin>>s;
  for(int i=0;i<(int)s.size()-7;i++)
    if(check(s.substr(i,8)))change(i),i+=7;
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 1212
n = gets.to_i

n1 = n % 10
n2 = ((n - n1) / 10) % 10
n3 = (n - n1 - n2 * 10) / 100

answer = 0

if n1 == 7 then
  answer = answer + 1
end
if n2 == 7 then
  answer = answer + 1
end
if n3 == 7 then
  answer = answer + 1
end
  
if answer == 0
  print "No"
else
  print "Yes"
end

Measured memory_bytes: 14336
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x[] = new int[52];
		for(int i=0; i<52; i++){
			x[i]=0;
		}
		for(int i=0; i<n; i++){
			String str =sc.next();
			int num = sc.nextInt();
			if(str.equals("S")){
				num=num+0;
			}else if(str.equals("H")){
				num=num+13;
			}else if(str.equals("C")){
				num=num+26;
			}else if(str.equals("D")){
				num=num+39;
			}
			x[num-1]=1;
		}
		for(int i=1; i<53; i++){
			int num = i;
			if(x[i-1]==0){
				if(i<14){
					System.out.println("S"+ " " + num);
				}else if(i>13 && i<27){
					num=num-13;
					System.out.println("H" + " " + num);
				}else if(i>26 && i<40){
					num=num-26;
					System.out.println("C" + " " + num);
				}else if(i>39){
					num=num-39;
					System.out.println("D" + " " + num);
				}
			}
		}
	}
}

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

using namespace std;

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

    vector<int> L(N);
    int sum=0;

    for(int i=0;i<L.size();i++){
        cin >> L[i];
        sum+=L[i];
    }

    for(int i=0;i<L.size();i++){
        if(sum-2*L[i]<=0){
            cout << "No" << endl;
            exit(0);
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  const int MOD=1e9+7;
  const int N=2e5+2;

  
    
  int32_t main()
  {
    /*#ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/
       IOS
       int n,x,t;
       cin>>n>>x>>t;
       int prod = (n%x==0)? n/x:n/x+1;
       cout<<prod*t;
        return 0;
  }
       

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;


int main(void){
    // Your code here!
    string s;
    cin >> s;
    
    string t;
    vector<int> counts;
    int cnt = 0;
    
    for (int i=0; i<s.size(); i++){
        if(s[i] != 'x'){
            t += s[i];
            counts.push_back(cnt);
            cnt = 0;
        }else{
            cnt++;
        }
    }
    counts.push_back(cnt);
    string t2 = t;
    reverse(t2.begin(), t2.end());
    
    if (t2 != t){
        cout << -1 << endl;
        return 0;
    }
    
    int res = 0; 
    for (int i=0; i< counts.size() / 2; i++){
        res += abs(counts[i] - counts[counts.size() - 1 - i]);
    }
    cout << res << endl;
}


Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define int long long 
using namespace std;
typedef pair<int,int> ii;

int cnt[1000005];

signed main(){
	//freopen("i.txt","r",stdin);
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	int n; cin >> n;
	for(int i = 0;i < n;i++){
		int x; cin >> x;
		cnt[x]++;
	}
	
	int ans = 0;
	
	for(int i = 1;i <= 1000000;i++){
		if(cnt[i] == 0) continue;
		
		for(int j = i+i;j <= 1000000;j += i){
			cnt[j] = 2;
		}
		if(cnt[i] == 1) ans++;
	}
	
	cout << ans;
}



Measured memory_bytes: 11452
#include <stdio.h>

typedef long long int LL;

LL n, x, ans;

void f(LL a, LL b) {
	if(b == 0) { return; }
	
	ans += a / b * b * 2 - (a % b == 0 ? b : 0);
	f(b, a % b);
	
	return;
}

int main() {
	scanf("%lld%lld", &n, &x);
	
	ans += n;
	f(x, n - x);
	
	printf("%lld", ans);
	
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define IO {ios_base::sync_with_stdio(false); cin.tie(0);}
#define ll   long long
#define pi pair<ll,ll>
int main()
{
    IO;
    ll i, j, k, l=0, n, m, h, mod=1e9+7, cnt=0, mx = 0, t, ans=0, tc=0,r , b;

        cin>>n;
        for(i=1; i<=n; i++){
            cin>>j; if(i%2 && j%2) cnt++;
        }
        cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int calculate_pattern(int , int );

int main(void){
	int konstante, sum;
	int pattern;

	scanf("%d %d", &konstante, &sum);
	
	pattern = calculate_pattern(konstante, sum);

	printf("%d\n", pattern);

	return 0;
}

int calculate_pattern(int konstante, int sum){
	int x, y, z;
	int pattern = 0;

	for (x = 0; x <= konstante; x++){
		for (y = 0; y <= konstante; y++){
			z = sum - x - y;
			if (0 <= z&&z <= konstante){
				pattern++;
			}
		}
	}
	return pattern;
}

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

int main(){
  int n;
  long long a[100000];
  long long sum=0, sum2=0;
  int ptt;
  int i;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a+n, greater<int>());
  //5 4 4
  //4 5 4 = 2
  //
  if(n==3){
    sum=a[0]+a[1]-a[2]*2;
    sum2=a[0]*2-a[1]-a[2];
    cout << max(sum, sum2) << '\n';
    return 0;
  }
  if(n==2){
    sum=a[0]-a[1];
    cout << sum << '\n';
    return 0;
  }

  if(n%2==1){
    ptt=n/2;
    for (i=0; i < ptt; i++) {
      sum+=(2*a[i]);
    }
    sum-=a[i];
    i++;
    sum-=a[i];
    i++;
    for(;i<n;i++){
      sum-=(2*a[i]);
    }
    ptt=n/2-1;
    for (i=0; i < ptt; i++) {
      sum2+=(2*a[i]);
    }
    sum2+=a[i];
    i++;
    sum2+=a[i];
    i++;
    for(;i<n;i++){
      sum2-=(2*a[i]);
    }
    if(sum<sum2){
      sum=sum2;
    }

  }else{
    ptt=n/2-1;
    for (i=0; i < ptt; i++) {
      sum+=(2*a[i]);
    }
    sum+=a[i];
    i++;
    sum-=a[i];
    i++;
    for(;i<n;i++){
      sum-=(2*a[i]);
    }
  }


  cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int A,B,C,D;
	public void solve() {
		A = nextInt();
		B = nextInt();
		C = nextInt();
		D = nextInt();

		int ans = 0;
		if(A <= C && D <= B){
			ans = D - C;
		}else if(C <= A && B <= D){
			ans = B - A;
		}else if(B <= C || D <= A){
			ans = 0;
		}else{
			ans = Math.min(B, D) - Math.max(A,C);
		}

		out.println(ans);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 23252