akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);

#define N 4e7
#define nl "\n"
#define f first
#define s second
#define pi acos(-1.0)
#define MOD 1000000007
#define pb push_back

typedef long long ll;
typedef double db;

using namespace std;

int main()
{
    io;
    //freopen("in.txt" , "r" , stdin);
    //freopen("out.txt" , "w" , stdout);

    ///Let the showdown begin

    string s;
    cin >> s;

    int sz = s.size();
    ll sum = 0;
    for(int i=0 ; i<sz ; i++)
    {
        sum += s[i] - '0';
    }
    //cout << sum << nl;

    if(sum % 9 == 0)
        cout << "Yes" << nl;
    else
        cout << "No" << nl;

    ///Happily DONE
    return 0;
}


Measured memory_bytes: 3720
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());
        var a = ReadLine().Split().Select(int.Parse).ToArray();
        var q = int.Parse(ReadLine());
        int[] w = new int[100001];
        long l = 0;
        for(int i = 0; i < n; i++)
        {
            w[a[i]]++;
            l += a[i];
        }
        for(int i = 0; i < q; i++)
        {
            var b = ReadLine().Split().Select(int.Parse).ToArray();
            l += (long)(b[1] - b[0]) * w[b[0]];
            w[b[1]] += w[b[0]];
            w[b[0]] = 0;
            WriteLine(l);
        }
    }
}


Measured memory_bytes: 31124
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 3e3;
int n;
string s;
ll DP[N], DP2[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> s;
  DP[0] = 1;
  FOR(i, 1, n){
    if(s[i-1] == '<'){
      DP2[0] = 0;
      FOR(j, 1, i+1) DP2[j] = (DP2[j-1] + DP[j-1]) % MOD;
      swap(DP, DP2);
    }else{
      FORR(j, i-1, 0) DP[j] = (DP[j+1] + DP[j]) % MOD;
    }
  }
  ll ans = 0;
  FOR(i, 0, n) ans += DP[i];
  cout << ans % MOD << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll a, b, c;
  while (cin >> a >> b >> c) {
    if (a!=-1 || b!=-1 || c!=-1) {
      if (a==-1 || b==-1) {
        cout << 'F' << endl;
      } else if (a+b >= 80) {
        cout << 'A' << endl;
      } else if (a+b >= 65) {
        cout << 'B' << endl;
      } else if (a+b >= 50) {
        cout << 'C' << endl;
      } else if (a+b >= 30) {
        if (c >= 50) {
          cout << 'C' << endl;
        } else {
          cout << 'D' << endl;
        }
      } else {
        cout << 'F' << endl;
      }
    }
  }
}


Measured memory_bytes: 3080
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main() {
  int a[4],b[4];
  
  while(cin>>a[0]){
    rep(i,3) cin>>a[i+1];
    rep(i,4) cin>>b[i];
    int h=0,v=0;
    
    rep(i,4){
      if(a[i]==b[i]) h++;
    }
    rep(i,4){
      rep(j,4){
        if(a[i]==b[j]) v++;
      }
    }
    
    cout<<h<<" "<<v-h<<endl;

  }
  
  return 0;
}


Measured memory_bytes: 2988
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int A, B, T;
  cin >> A >> B >> T;
  cout << (T / A) * B << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>

int main(void)
{
char S[2];

  int i;
  
  for(i=0;i<3;i++)
  {
scanf("%c", &S[i]);
  }
if(S[0]==S[1]||S[0]==S[2]||S[1]==S[2])
{
printf("No");
}
  else
  {
  printf("Yes");
  }
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
int main()
{
    ll n,ans=0;
    cin>>n;
    map<ll,ll> mp;
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            mp[i]++;
            n/=i;
        }
    }
    if(n!=1) mp[n]++;
    for(auto p:mp){
        ll i=1;
        while(p.second-i>=0){
            p.second-=i;
            i++;
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF=1e18;
vector<ll> x[210005];
vector<ll> used(210005,0);
vector<ll> c(2);


void dfs(ll t){
  //used[n][t]=1;
  if (t>=100005)c[0]++;
  if (t<100005)c[1]++;
  used[t]=1;
  for(ll to:x[t]){
    if (used[to])continue;
    dfs(to);
  }
}


int main() {
  ll N;
  cin >> N;
  vector<P> v(N);


  rep(i,N){
    ll a1,b1;
    cin>>a1>>b1;
    a1--;b1+=100005;
    v[i]=make_pair(a1,b1);
    x[a1].push_back(b1);
    x[b1].push_back(a1);
  }
ll ans=0;
  rep(i,N){

    dfs(v[i].first);
  //  cout<<"i"<<i<<cx<<" "<<cy<<endl;
    ans+=c[0]*c[1];
    c[0]=0;c[1]=0;

  }

  ans-=N;
  cout<<ans;

}


Measured memory_bytes: 17428
from collections import defaultdict
if __name__ == '__main__':
    S = str(input())
    T = str(input())
    
    count = defaultdict(str)
    count2 = defaultdict(str)
    flag = True
    for i in range(len(S)):
        s = S[i]
        t = T[i]
        if count[t] != '':
            if count[t] != s:
                flag = False
        else:
            if count2[s] != '':
                if count2[s] != t:
                    flag = False
            else:
                count[t] = s
                count2[s] = t
    if flag:
        print('Yes')
    else:
        print('No')

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

#define int long long
#define MOD ((int)1e9+7)

#define MAX 200

int N, T, L, B;

signed  main(){
  cout<<fixed<<setprecision(7);

  while(true){
    int temp[MAX] = {};
    double dp[MAX][MAX] = {};
    double ans = 0;
    int Lose[MAX] = {}, Back[MAX] = {};
    
    cin>>N>>T>>L>>B;

    if(!N&&!T&&!L&&!B) break;

    for(int i = 0; i < L; i++){
      cin>>Lose[i];
      temp[Lose[i]] = 1;
    }

    for(int i = 0; i < B; i++){
      cin>>Back[i];
      temp[Back[i]] = 2;
    }

    dp[0][0] = 1;

    for(int i = 1; i <= T; i++){
      for(int j = 0; j < N; j++){
	for(int k = 1; k <= 6; k++){
	  int tt; 
	  if(k+j >= N+1) tt = N-(k+j-N);
	  else tt = j+k;
	  //if(j+k != tt)cout<<j<<" "<<k<<" "<<tt<<" "<<N<<" "<<j+k<<" "<<endl;

	  if(temp[tt] == 2){
	    dp[i][0] += dp[i-1][j]/6.0;
	  } else if(temp[tt] == 1){
	     dp[i+1][tt] += dp[i-1][j]/6.0;
	  } else {
	    dp[i][tt] += dp[i-1][j]/6.0;
	  }
	  
	}
      }
      // for(int ii = 0; ii <= N; ii++) cout<<dp[i][ii]<<" ";cout<<endl;
      // cout<<dp[i][N]<<endl;
      ans += dp[i][N];
    }
    cout<<ans<<endl;
  }
  

  return 0;
}



Measured memory_bytes: 3604
def cin
  gets.split.map(&:to_i)
end

# ex. cumsum([1,2,2,4,5]) => [0,1,3,5,9,14]
def cumulate(raw)
  raw.each_with_object([0]) { |v, a| a << a.last + v }
end

n, k = cin
p = cin

s = cumulate(p)
ans = s[k]

(k..n).each do |j|
  sum = s[j] - s[j - k]
  ans = sum if sum > ans
end

puts (ans + k) / 2.0

Measured memory_bytes: 16644
import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;
import std.math;
import std.container;

void main() {
  auto S = readln.chomp;
  char c = S[0];
  int ans = 0;
  foreach (s; S)
    if (s != c) {
      ans += 1;
      c = s;
    }
  writeln(ans);
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    ll x; cin >> x;
    ll c = 100;
    int y = 0;
    while(c < x){
        c *= 1.01;
        y++;
    }
    cout << y << endl;
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

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

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    ll a,b,c,d;
    rep(n){
        cin >> a >> b >> c >> d;

        if(a < b || b > d){
            cout << "No" << endl;
            continue;
        }
        if(b <= c){
            cout << "Yes" << endl;
            continue;
        }

        ll g = gcd(b, d);
        cout << (a%g+b-g > c ? "No" : "Yes") << endl;
    }
}


Measured memory_bytes: 256
//#pragma GCC optimize(2)
//ÄÏ¾©ÊÐµÚÈýÇøOIÎ¯ÌáÐÑÄú£º
//´úÂëÇ§ÍòÌõ£¬-O2µÚÒ»Ìõ¡£
//-O2²»¹æ·¶£¬³¬Ê±Á½ÐÐÀá¡£
// Happy TLE and WA every day!
// by: zxb
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define pb              push_back
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
#define read            ZXBs_fast_input
#define write           ZXBs_fast_output
//#define usingFiles
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool write(int x){
	if(x >= 10) write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	string s;
	int a, b, c, d;
	cin >> s;
	a = s[0] - '0'; b = s[1] - '0'; c = s[2] - '0'; d = s[3] - '0'; 
	if(a+b+c+d == 7) cout << a << '+' << b << '+' << c << '+' << d << "=7\n";
	else if(a+b+c-d == 7) cout << a << '+' << b << '+' << c << '-' << d << "=7\n";
	else if(a+b-c+d == 7) cout << a << '+' << b << '-' << c << '+' << d << "=7\n";
	else if(a+b-c-d == 7) cout << a << '+' << b << '-' << c << '-' << d << "=7\n";
	else if(a-b+c+d == 7) cout << a << '-' << b << '+' << c << '+' << d << "=7\n";
	else if(a-b+c-d == 7) cout << a << '-' << b << '+' << c << '-' << d << "=7\n";
	else if(a-b-c+d == 7) cout << a << '-' << b << '-' << c << '+' << d << "=7\n";
	else if(a-b-c-d == 7) cout << a << '-' << b << '-' << c << '-' << d << "=7\n";
	return 0;
}


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

using i64 = int64_t;

int main() {
  int n;
  cin >> n;
  vector<int> dp(n + 1, n);
  dp[0] = 0;
  vector<int> c = {1};
  for (int d = 6; d <= n; d *= 6) c.push_back(d);
  for (int d = 9; d <= n; d *= 9) c.push_back(d);
  for (int d : c) {
    for (int i = 0; i <= n - d; i++) {
      dp[i + d] = min(dp[i + d], dp[i] + 1);
    }
  }
  cout << dp[n] << '\n';
}

Measured memory_bytes: 3764
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

rotate90 = transpose . reverse

main = do
    n <- getInt
    replicateM n getInt >>= print . (`div` n) . sum 

Measured memory_bytes: 8224
def ii():
    return int(input())
def mi():
    return map(int, input().split())
def li():
    return list(mi())

n, k = mi()
c1 = c2 = 0
for i in range(1, n + 1):
    c1 += i % k == 0
    c2 += k % 2 == 0 and i % k == k // 2
ans = c1 ** 3 + c2 ** 3
print(ans)


Measured memory_bytes: 39280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());
        var s = ReadLine();
        var w = s;
        for(int i = 0; i + i < s.Length; i++)
        {
            w = w.Replace("()", "");
        }
        var l = w.Count(x => x == ')');
        var r = w.Count(x => x == '(');
        for(int i = 0; i < l; i++)
            s = '(' + s;
        for(int i = 0; i < r; i++)
            s = s + ')';
        WriteLine(s);
    }
}



Measured memory_bytes: 18864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int a, b, c, d, e, k; cin >> a >> b >> c >> d >> e >> k;
    if (e-a>k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

ll sz = 2e6 + 5;

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];

	set<ll> st;
	rep(i, n) st.insert(a[i]);
	unordered_map<ll, ll> ump;
	rep(i, n) ump[a[i]]++;

	VecB ok(sz, true);

	for(ll i : st){
		for (ll j = 2; j * i < sz; ++j){
			ok[j * i] = false;
		} 
	}

	ll ans = 0;
	rep(i, n){
		if (ok[a[i]] && ump[a[i]] == 1) ans++;
	}
	co(ans);

	return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,a,ans=1;
map<int,int,greater<int>> m;

main() {
    cin >> n;
    rep(i,n) cin >> a,m[a]++;
    int hoge = n-1;
    for(;hoge > 0;hoge-=2) {
        if (m[hoge] != 2) {
            cout << 0 << endl;
            return 0;
        }
    }
    if (n%2 && m[0] != 1) {
        cout << 0 << endl;
        return 0;
    }
    rep(i,n/2) {
        ans *= 2;
        ans = ans%MOD;
    }
    cout << ans << endl;
}




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


using namespace std;
using ll = long long;

const int sz = 1e6 + 10;
int sp[sz];

int main() {
    ll n;
    cin >> n;
    ll res = 0;
    for(ll i = 1; i <= n; i++) {
        ll tmp = n / i;
        tmp = i * tmp * (tmp + 1) / 2;
        res += tmp;
    }
    cout << res << "\n";

}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 100;
const int MOD = 1000000007;

void doc() {
    freopen("OB.inp","r",stdin);
    freopen("OB.out","w",stdout);
}

int n, cha[maxN], depth[maxN], h[maxN], sib[maxN];
vector<int> a[maxN];

void DFS(int u){
    for(int v : a[u]){
        depth[v] = depth[u] + 1;
        DFS(v);
        h[u] = max(h[u], h[v] + 1);
    }
}

void solve() {
    cin >> n;
    memset(cha, -1, sizeof(cha));
    memset(sib, -1, sizeof(sib));
    for(int i = 0; i < n; i++){
        int x, left, right;
        cin >> x >> left >> right;
        if (left != -1){
            a[x].push_back(left);
            cha[left] = x;
        }
        if (right != -1){
            a[x].push_back(right);
            cha[right] = x;
        }

        if (left != -1 && right != -1){
            sib[left] = right;
            sib[right] = left;
        }
    }

    int root = 0;
    while (cha[root] != -1) root++;

    DFS(root);

    for(int u = 0; u < n; u++){
        cout << "node " << u << ": parent = " << cha[u] << ", sibling = " << sib[u];
        cout << ", degree = " << (int)a[u].size() << ", depth = " << depth[u];
        cout << ", height = " << h[u] << ", ";
        if (u == root) cout << "root";
        else
            if (a[u].size() == 0) cout << "leaf";
            else cout << "internal node";
        cout << '\n';
    }
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
   // doc();
    solve();
}



Measured memory_bytes: 6312
#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 n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<int> suff(n);
    suff[n-1]=a[n-1];
    for(int i=n-2;i>=0;i--){
        suff[i]=(suff[i+1]+a[i])%mod;
    }
    ll ans=0;
    for(int i=0;i<n-1;i++){
        ans=ans+(a[i]*suff[i+1])%mod;
        ans%=mod;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
const int nax=1e5+1;
vector<int> edges[nax];
int vis[nax];
int dist[nax];
int inDegree[nax];

void dfs(int a){
    if(vis[a])return;
    vis[a]=true;

    for(int b:edges[a]){
        dist[b]=max(dist[b],dist[a]+1);
        --inDegree[b];
    if(inDegree[b]==0)dfs(b);

    }
}



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

    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        inDegree[y]++;
        edges[x].push_back(y);
    }
    for(int i=1;i<=n;i++){
        if(!vis[i] && inDegree[i]==0){
            dfs(i);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,dist[i]);
    }

    cout<<ans<<"\n";

}


Measured memory_bytes: 9984
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a>=d||c>=b)
    cout<<"0"<<endl;
  else
  {
    cout<<min(b,d)-max(a,c)<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
// #define int long long

#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

const int MAX = 100000 + 10;

int main() {
  int r, g, b;
  int n;
  cin >> r >> g >> b;
  n = 100 * r + 10 * g + b;
  if (n % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int x, y;
   
	while(1)
	{
       cin >> x >>y;
		if(x==0&&y==0)
        	break;
        if(0<=x&&y<=10000)
        {
         if(x<y)
          {
             cout << x << " " << y <<endl;
          }
         else if(x>y)
          {
             cout << y << " " << x <<endl;
          }
          else 
          {
             cout << x << " " << y <<endl;
          }
        	
        }
	}
      return 0;
}
       
        

Measured memory_bytes: 1160
// AOJ DPL_1_B: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B

package main

import (
	"fmt"
)

type Item struct {
	v, w int
}

func main() {
	var N, W int
	fmt.Scanf("%d %d", &N, &W)

	items := make([]Item, N+1)
	items[0] = Item{}

	var v, w int
	for i := 1; i <= N; i++ {
		fmt.Scanf("%d %d", &v, &w)
		items[i] = Item{v, w}
	}

	dp := make([][]int, N+1)
	for i := 0; i <= N; i++ {
		a := make([]int, W+1)
		dp[i] = a
	}

	for i := 1; i <= N; i++ {
		for j := 1; j <= W; j++ {
			if items[i].w <= j {
				pick := dp[i-1][j-items[i].w] + items[i].v
				notpick := dp[i-1][j]
				dp[i][j] = max(pick, notpick)
			} else {
				dp[i][j] = dp[i-1][j]
			}
		}
	}

	fmt.Println(dp[N][W])
}

func max(x, y int) int {
	if x >= y {
		return x
	}
	return y
}



Measured memory_bytes: 9704
while 1:
	n,m,a = map(int,raw_input().split())
	if n == 0: break
	amida = [[] for i in range(n)]
	for i in range(m):
		h,p,q = map(int,raw_input().split())
		amida[p-1].append([h,q])
		amida[q-1].append([h,p])
	for i in range(n):
		amida[i] = sorted(amida[i],reverse=True)
	y = 1001
	while 1:
		for i in range(len(amida[a-1])):
			if amida[a-1][i][0] < y:
				y = amida[a-1][i][0]
				a = amida[a-1][i][1]
				break
		else:
			break
	print a

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

using namespace std; 
 
int main(void) 
{ 
  	cin.tie(0); 
 	ios::sync_with_stdio(false); 
  
  	int n,t,T,res=0; 
  	vector <int> v; 
  
  	cin >> n >> T; 
  	for(int i=0;i<n;i++) 
  	{	 
    	cin >> t; 
    	v.push_back(t); 
  	} 
  	int lo = v[0],hi=v[0]; 
  	int diff = 0;

  	for(int i=1;i<n;i++) 
  	{	 
  		//cout << lo << ' ' << hi << ' ' << v[i] << ' ' << diff << '\n';
    	if(v[i]<hi) 
    	{ 
      		hi = v[i]; 
    	}	 
    	else 
    	{ 
      		hi = max(hi,v[i]);
    	}
    	lo = min(lo,v[i]);
       	diff = max(diff,(hi-lo));    		 
  	} 
  
  	if(lo!=hi) 
  	{ 
    	diff = max(diff,(hi-lo));
  	} 
  	
  	//cout << diff << '\n';
  	priority_queue <int,vector<int>,greater<int>> pque;

  	pque.push(v[0]);
  	for(int i=1;i<v.size();i++)
  	{
  		if(v[i]-pque.top()==diff)
  		{
  			res++;
  		}
  		pque.push(v[i]);
  	}

  	priority_queue <int> pque2;

  	int res2 = 0;
  	pque2.push(v[n-1]);
  	for(int i=n-2;i>=0;i--)
  	{
  		if(pque2.top()-v[i]==diff)
  		{
  			res2++;
  		}
  		pque2.push(v[i]);
  	}  	

  	//cout << res << ' ' << res2 << ' ' << T/2 << '\n';
  	cout << min(res,res2) << endl;
  
 	 return 0;
} 

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

using namespace std;

typedef long long ll;

#define INF 0x7fffffff

int main(){
  ll n, w;
  cin>>n>>w;
  vector<ll> weight(n+1);
  vector<ll> value(n+1);
  
  for(int i=1; i<=n; i++){
    cin>>weight[i]>>value[i];
  }
  vector<ll> knapsack(100001);
  for(int i=1; i<=100000; i++) knapsack[i] = INF;
  for(int i=1; i<=n; i++){
    for(int j=100000; j>=0; j--){
      if(value[i] <= j) 
      knapsack[j] = min(weight[i] + knapsack[j-value[i]], knapsack[j]);
      else break;
    }
  }
  ll ans =-1;
  for(int i=100000; i>=0; i--){ 
    if(knapsack[i]<=w){
      ans = i;
      break;
    }
  } 
  cout<<ans<<endl;
  return 0;
}


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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int[] v = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int x = v[i] - c[i];
            if (x < 0) {
                continue;
            }
            ans += x;
        }
        System.out.println(ans);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

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

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

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

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

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 21332
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,h,w;
  cin >> n >> h >> w;
  int cnt=0;
  for(int i=0;i<n;i++){
    int a,b;
    cin >> a >> b;
    if(h<=a&&w<=b) cnt++;
  }
  cout << cnt << "\n";
  
  return 0;
}


Measured memory_bytes: 256
from sys import setrecursionlimit
setrecursionlimit(100000)
from collections import deque

nVertices, nEdges = map(int, input().split())
g = [[] for _ in range(nVertices + 1)]
for _ in range(nEdges):
    u, v, _ = map(int, input().split())
    g[u].append(v)
    g[v].append(u)

def dfs(v):
    visited[v] = True
    for to in g[v]:
        if not visited[to]:
            dfs(to)

def bfs(v):
    visited[v] = True
    q = deque([v])
    while q:
        cur = q.pop()
        for to in g[cur]:
            if not visited[to]:
                visited[to] = True
                q.appendleft(to)

cnt = 0
visited = [False] * (nVertices + 1)
for v in range(1, nVertices + 1):
    if not visited[v]:
        bfs(v)
        cnt += 1
print(cnt)

Measured memory_bytes: 23792
S = input()
T = input()

s = len(S)
t = len(T)
ans1 = 10000000

for i in range(s - t + 1):
  ans = 0
  for j in range(t):
    if T[j] != S[i + j]:
      ans += 1
      
  ans1 = min(ans, ans1)
      
print(ans1)


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(2 * a - 1, 2 * b - 1));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{   
char s[100005];
scanf("%s", s);
int sum=0, len=strlen(s), p=0, g=0;    
for(int i=0;i<len;i++)
{if(s[i]=='g')        
{if(g>p)           
{sum++;
p++;}            
else  
g++;}        
else
{if(g>p)p++;
else{ sum--;  g++;}
} 
}
printf("%d\n", sum);
return 0;
}

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

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

    vector<int> card(n + 1);
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        card[l]++;
        card[r + 1]--;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if(i != 0) card[i] += card[i-1];
        if(card[i] == m) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#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 _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N, M; cin >> N >> M;
  vi S(N); vi T(M);
  rep(i,N) cin >> S[i];
  rep(i,M) cin >> T[i];
  vector<vector<ll>> sum(N+1, vector<ll>(M+1, 1));
  ll mod = 1000000007;
  for(int i=0; i<=N; i++){
    sum[i][0] = 1;
  }
  for(int i=0; i<=M; i++){
    sum[0][i] = 1;
  }
  for(int i=1; i<=N; i++){
    for(int j=1; j<=M; j++){
      sum[i][j] = (sum[i][j-1]+sum[i-1][j]) % mod;
      if (S[i-1]!=T[j-1]) sum[i][j] -= sum[i-1][j-1];
      sum[i][j] = (sum[i][j] + mod) % mod;
    }
  }
  cout << sum[N][M] << endl;
  return 0;
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

#define TOP_NUM 5
#define NOTOP_NUM 21

int main(){
	IO_STREAM;
	int D;	cin>>D;
	vi c(26);
	vector<pair<int,int>>cs(26);
	rep(i,0,26){
		cin>>c[i];
		cs[i].first=c[i];
		cs[i].second=i;
	}
	int s[D][26];
	int maxx[D]={0};
	rep(i,0,D){
		int m=0;
		rep(j,0,26){
			cin>>s[i][j];
			if(m<s[i][j]){
				maxx[i]=j+1;
				m=s[i][j];
			}
		}
	}

	rep(i,0,D){
		cout<<maxx[i]<<endl;
	}
	return 0;

	
	sort(all(cs));
	reverse(all(cs));
	vi top(D,1);
	rep(i,0,TOP_NUM){
		top[i]=cs[i].second+1;
	}
	vi notop(D,1);
	rep(i,0,NOTOP_NUM){
		notop[i]=cs[i+TOP_NUM].second+1;
	}

	int cnt=1;
	int nt_idx=0;
	while(1){
		rep(i,0,TOP_NUM){
			cout<<top[i]<<endl;
			cnt++;
			if(cnt>D) return 0;
		}
		rep(i,0,5){
			cout<<notop[nt_idx]<<endl;
			nt_idx++;
			if(nt_idx>=NOTOP_NUM) nt_idx=0;
			cnt++;
			if(cnt>D) return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;
 
 
 
int main(){
    int n,k;
    cin>>n>>k;
    double p[n];
    double sum=0;
    pan(i,n){
        int a;
        cin>>a;
        sum+=(double)(1+a)/(2.0);
        p[i]=sum;
    }
    double ans=p[k-1];
    for(int i=k;i<n;i++){
        ans=max(ans,p[i]-p[i-k]);
    }
    cout<<fixed<<setprecision(12)<<ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};

int main(){
  int n;
  cin >> n;
  cout << n * n* n << endl;
  return 0;
}


Measured memory_bytes: 256
ans=10**9
A=[]
n,k=[int(i) for i in input().split()]
for i in range(n):
    j=int(input())
    A.append(j)
A.sort(reverse=True)
for i in range(n-k+1):
    ans=min(ans,A[i]-A[i+k-1])
print(ans)

Measured memory_bytes: 7384
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = {-1,0,2,0,1,0,1,0,0,1,0,1,0};
        int x = sc.nextInt();
        int y = sc.nextInt();
        if(a[x]==a[y]) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23252
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();

		System.out.println(Math.PI * 2 * r);
	}

}


Measured memory_bytes: 35892
#![allow(non_snake_case)]

use proconio::input;
use proconio::fastout;

#[derive(Clone, Debug)]
struct Heap2 {
    x0: i32,
    x1: i32,
}

impl Heap2 {
    fn new() -> Heap2 {
        Heap2 {
            x0: 1,
            x1: -1,
        }
    }

    fn merge(&mut self, h: &Heap2) {
        let mut a = [self.x0, self.x1, h.x0, h.x1];
        a.sort_by(|x, y| y.cmp(x));
        self.x0 = a[0];
        self.x1 = a[1];
    }
}

#[fastout]
fn main() {
    input! {
        N: usize,
        A: [i32; 1 << N],
    }
    let M = 1 << N;
    let mut dp = vec![Heap2::new(); M];
    for i in 0..M {
        dp[i].x0 = A[i];
    }
    for i in 0..N {
        let mask = 1 << i;
        for j in 0..M {
            if j & mask == 0 {
                let tmp = dp[j].clone();
                dp[j ^ mask].merge(&tmp);
            }
        }
    }
    let mut result = 0;
    for i in 1..M {
        result = std::cmp::max(result, dp[i].x0 + dp[i].x1);
        println!("{}", result);
    }
}


Measured memory_bytes: 8992
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

long long gcd (long long a, long long b) {
    long long temp;
    while(a % b != 0) {
        temp = b;
        b = a % b;
        a = temp;
    }
    return b;
}

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

//0~nまでの中でCでもDでも割り切れない数を返す
long long not_divinable(long long n, long long C, long long D) {
    long long count = n+1;
    
    long long count_c = (long long)(n / C) + 1;
    long long count_d = (long long)(n / D) + 1;
    long long count_cd = (long long)(n / lcm(C,D)) + 1;
    return count - (count_c + count_d - count_cd);
}

int main() {
    long long A, B, C, D;

    cin >> A >> B >> C >> D;

    cout << not_divinable(B, C, D) - not_divinable(A-1, C, D) << endl;;


}

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

int main(){
    int n;
    while(cin >> n){
        int diff[100010] = {};
        rep(i,n){
            int a,b;
            cin >> a >> b;
            ++diff[a-1];
            --diff[b];
        }
        int x = 0;
        int ans = 0;
        rep(i,100010){
            x += diff[i];
            if(x >= i) ans = i;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3496
#include <bits/stdc++.h>
#define MX 32
using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;

bool comp(P p,P q)
{
	return p.second*q.first<q.second*p.first;
}
ll dp[MX];
int main()
{
	int n,T;
	scanf("%d %d",&n,&T);
	vector <int> all;
	vector <P> vx;
	for(int i=0;i<n;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		b++;
		b+=a;
		if(a==0) all.push_back(b);
		else
		{
			vx.push_back(P(a,b));
		}
	}
	sort(vx.begin(),vx.end(),comp);
	for(int i=0;i<MX;i++) dp[i]=T+1;
	dp[0]=0;
	for(int i=0;i<vx.size();i++)
	{
		P p=vx[i];
		for(int j=MX-2;j>=0;j--)
		{
			if(dp[j]>T) continue;
			dp[j+1]=min(dp[j+1],(p.first+1)*dp[j]+p.second);
		}
	}
	sort(all.begin(),all.end());
	int ret=0;
	for(int i=0;i<MX;i++)
	{
		if(dp[i]>T) continue;
		ll zan=T-dp[i];
		int pos=0;
		while(pos<all.size()&&zan>=all[pos])
		{
			zan-=all[pos];
			pos++;
		}
		ret=max(ret,pos+i);
	}
	printf("%d\n",ret);
	return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define Fast_IO() ios_base::sync_with_stdio(false);cin.tie(0)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define _ <<" "<<
const int MOD = 1000 * 1000 * 1000 + 7; // odd modulus
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
const int N = 1000 * 1000 ;
int main()
{
    Fast_IO();
    int n ;
    cin >> n ;
    map< string , int > m ;
    map<string  , vector<string>> mp ;
    for (int  i = 0 ; i < n ; ++i){
            string x , s  ;
            cin >> x ;
            s = x ;
            sort(all(x));
            m[x]++ ;
            mp[x].pb(s);


    }
    ll cnt = 0 ;
    tr( m , i ){
    if ( i.ss > 1 ){
      ll x = (ll) mp[i.ff].size()  ;
      cnt += ( x * (x - 1)  / 2 );
    }
    }


cout << cnt ;




    return 0 ;
}










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


int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    
    ll ans=0;
    if(a==0)
        ans=0;
    else if(b==0 || a>=n)
        ans=n;
    else{
        if(a+b>=n)
            ans=a;
        else if(n%(a+b)>=a)
            ans=n/(a+b)*a+a;
        else
            ans=n/(a+b)*a+n%(a+b);
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256