akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

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

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  string s;cin>>s;
  vector<int> a(n,0);
  rep(i,n-1){
    a[i+1] = a[i];
    if(s[i] == 'W'){
      a[i+1]++;
    }
  }
  vector<int> b(n,0);
  for(int i = n-1;i > 0;--i){
    b[i-1] = b[i];
    if(s[i] == 'E'){
      b[i-1]++;
    }
  }
  vector<int> ans(n);rep(i,n)ans[i] = a[i] + b[i];
  sort(all(ans));
  print(ans[0]);
  return 0;
}

Measured memory_bytes: 4244
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){
    int x,a,b;
    cin >> x >> a >> b;
    cout << (x-a)%b << endl;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;


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


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

int main(){
int q;
int l,r;
cin>>q;
bitset<100010>a(0);
for(int i=2;i<100010;i++){
a.set(i);
}
for(int i=0;i<100010;i++){
    if(a[i]){
        for(int j=i*2;j<100010;j+=i){
            a.reset(j);
        }
    }
}

vector<long long>ruiseki(100011);
for(int i=0;i<100010;i++){
        ruiseki[i+1]=ruiseki[i];
        if(a[i]&&a[(i+1)/2]){
            ruiseki[i+1]++;
        }
}
for(int i=0;i<q;i++){
    cin>>l>>r;
    cout<<ruiseki[r+1]-ruiseki[l]<<endl;
}
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int N;
vector<string> vec;

void dfs(string s){
  if(s.size() == N){
    vec.push_back(s);
    return;
  } 
  if(s.empty()){
    dfs(s + 'a');
  }
  char s1 = *max_element(s.begin(), s.end()) + 1;
  for(char i = 'a'; i <= s1; i++){
    dfs(s + i);
  } 
}

int main(){
  cin >> N;
  string s = "";
  dfs(s);
  for(int i = 0; i < vec.size(); i++) cout << vec[i] << endl;
}




Measured memory_bytes: 9588
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    return

#B
def B():
    return

#C
def C():
    s = S()
    t = S()
    ansa = []
    anslis = []
    lisans = []
    for i in range(len(s)):
        for j in range(len(t)):
            if 0 <= i + j < len(s) and (s[i + j] == t[j] or s[i + j] == "?"):
                continue
            break
        else:
            ansa.append((i, i + j))
    if len(ansa) == 0:
        print("UNRESTORABLE")
        return
    for ans in ansa:
        a = ""
        for num in range(len(s)):
            i = s[num]
            if ans[0] <= num <= ans[1]:
                i = t[num-ans[0]]
            a += i
        anslis.append(a)
    for ans in anslis:
        k = ""
        for i in ans:
            if i == "?":
                k += "a"
            else:
                k += i
        lisans.append(k)
    lisans.sort()
    print(lisans[0])
        
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


#A
"""
r = I()
g = I()
print(2*g-r)
"""

#B
"""
n = I()
k = I()
ans = 1
for i in range(n):
    ans = min(ans * 2, ans + k)
print(ans)
"""



    


#D
"""
n = I()
t = LI()
v = LI()
"""
if __name__ == "__main__":
    C()


Measured memory_bytes: 39920
main :: IO ()
main = do
    {--
        # 入力
            r <- readLn -- 入力が一行に一文字の場合
            as <- map read . words <$> getLine -- 一行に入力が複数ある場合


        # Solver
            putStrLn $ show $ solve a b -- solveの返り値がString型の場合
            putStrLn $ solve a b

    --}

    as <- map read . words <$> getLine -- 一行に入力が複数ある場合

    putStrLn $ show $ solve as -- showの返り値がString型の場合



solve :: [Int] -> Int
solve [n, i] = n - i + 1


{-- その他 備忘録
    # 型変換
       int 2 float: fromIntegral
       float 2 int: round 四捨五入
                    floor 床関数
                    ceiling 天井関数
       int 2 string: show

    # モジュール
        Data.List: sort
--}


Measured memory_bytes: 508
n = int(input())
W = list(map(int,input().split()))
W_2 = W[:]
sorted_W = sorted(W)
cost = 0
for i in range(n):
    if i==0:
        while W[i]!=sorted_W[i]:
            a=W.index(sorted_W[i])
            b=W.index(sorted_W[a])
            W[a],W[b]=W[b],W[a]
            W_2[a],W_2[b]=W_2[b],W_2[a]
            cost+=W[a]+W[b]
    else:
        cost1=0
        cost2=0
        while W[i]!=sorted_W[i]:
            a=W.index(sorted_W[i])
            b=W.index(sorted_W[a])
            W[a],W[b]=W[b],W[a]
            cost1+=W[a]+W[b]
        c = W_2.index(sorted_W[i])
        W_2[0],W_2[c]=W_2[c],W_2[0]
        cost2+=W_2[0]+W_2[c]
        while W_2[0]!=sorted_W[0]:
            a=W_2.index(sorted_W[0])
            b=W_2.index(sorted_W[a])
            W_2[a],W_2[b]=W_2[b],W_2[a]
            cost2+=W_2[a]+W_2[b]
        if cost1<=cost2:
            W_2=W[:]
            cost+=cost1
        else:
            W=W_2[:]
            cost+=cost2
print(cost)


Measured memory_bytes: 5640
A, B, C, D=map(int, input().split())
def func(c):
    global A, B
    return B//c-(A-1)//c

def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

def lcm(a,b):
    return (a*b)//gcd(a,b)

print((B-A+1)-func(C)-func(D)+func(lcm(C,D)))

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

typedef vector<int> vi;
typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<pii > vii;
typedef vector<vi > vvi;


int i, afs;
string s;
int main() {
    cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	for (int i = 1; i <= 9;i++) {
		for (int j = 1; j <= 9;j++) {
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
}

Measured memory_bytes: 3164
#include <stdio.h>
using namespace std;
int main()
{
	long long a,b,x;
	scanf("%lld%lld%lld",&a,&b,&x);
	if(a>0)
    {
        printf("%lld",(b/x)-(a-1)/x);
    }
    else
    {
        printf("%lld",(b/x)+1);
    }

}


Measured memory_bytes: 128
#include <cstdio>
int n;
int A[20];

bool solve(int i, int m) {
  if (m == 0) return true;
  if (i == n) return false;
  return (solve(i + 1, m) || solve(i + 1, m - A[i]));
}

int main() {
  int i, q, m;
  scanf("%d\n", &n);
  for (i = 0; i < n; ++i)
    scanf("%d\n", &A[i]);
  scanf("%d\n", &q);
  for (i = 0; i < q; ++i) {
    scanf("%d\n", &m);
    if (solve(0, m))
      printf("yes\n");
    else
      printf("no\n");
  }
  return 0;
}

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

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

  int n;
  cin >> n;
  int a[100000];
  rep(i, n) cin >> a[i];

  ll ans = 1LL<<62;
  ll sum[100001] = {};

  // parity
  rep(p, 2) {
    ll cnt = 0;
    rep(i, n) {
      int border = 1+(p+i)%2*-2;
      sum[i+1] = sum[i] + a[i];
      if (border == 1 && sum[i+1] >= border) continue;
      if (border == -1 && sum[i+1] <= border) continue;
      cnt += abs(border-sum[i+1]);
      sum[i+1] = border;
    }
    ans = min(ans, cnt);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

void No() {
    cout << -1 << ln;
    exit(0);
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(N+1);
    rep(i,N+1) cin >> A[i];

    if (N==0) {
        cout << (A[0]==1 ? 1 : -1) << ln;
        return 0;
    }
    if (A[0]) No();
    vector<ll> r(N+1),MAX(N+1);
    r[0] = 1;
    ll ans = 1;
    for (int i = N-1; i >= 0; i--) {
        MAX[i] = MAX[i+1]+A[i+1];
    }
    rep(i,N) {
        if (r[i]*2 < A[i+1]) No();
        if (i != N-1 and r[i]*2==A[i+1]) No();
        r[i+1] = r[i]*2-A[i+1];
        chmin(r[i+1],MAX[i+1]);
        ans += r[i+1] + A[i+1];
    }

    cout << ans << ln;
}

Measured memory_bytes: 5900
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

//modしながら塁乗
ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int n;cin>>n;

  int a[n];
  REP(i,n){
    int t;cin>>t;
    a[i] = t;
  }
  int ans = 0;
  REP(i,n-1){
    if(a[i]==a[i+1]){
      ans++;
      a[i+1] = ans * -1;
    }
  }

 
  cout<<ans<<endl;

  return 0;
}

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

int a, b, c;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> a >> b >> c;
	bool ok = false;
	for (int i = 1; i <= b; i++) {
		if ((a*i)%b == c) ok = true;
	}
	cout << (ok ? "YES" : "NO") << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string pref = "";
  string suff = "";
  string s; cin >> s;
  int rev = 0;
  int q; cin >> q;
  for(int i = 0; i < q; ++i) {
    int x; cin >> x;
    if(x == 1) {
      rev ^= 1;
    } else {
      string p;
      cin >> x >> p;
      if(x == 1) {
        if(rev) suff += p;
        else pref += p;
      } else {
        if(rev) pref += p;
        else suff += p;
      }
    }
  }
  if(rev) {
    reverse(s.begin(), s.end());
    swap(pref, suff);
  }
  reverse(pref.begin(), pref.end());
  cout << pref << s << suff << '\n';
  return 0;
}


Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N = 2e5 + 6 ;
#define int long long int

vector<int> adj[N] ; 
bool vis[N] ;
int cnt ;

void dfs(int s) {
    vis[s] = true ; 
    cnt++ ; 
    for(auto x : adj[s]) 
    if(!vis[x]) dfs(x) ;
}


int32_t main() {
    IOS ;
    // int t ; cin >> t ; while(t--) {}
    int n, m ; cin >> n >> m ;
    while(m--) {
        int x, y ; cin >> x >> y ; 
        adj[x].push_back(y) ;
        adj[y].push_back(x) ;
    }
    
    memset(vis, false, sizeof(vis)) ;
    int res = 0 ;
    for(int i=1; i<=n; i++) 
    if(!vis[i]) {
        cnt = 0 ; 
        dfs(i) ; 
        res = max(res, cnt) ;
    }
    cout << res ;
    
    return 0 ;
}


Measured memory_bytes: 20964
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline-------------------------------------------
    N = int(input())
    A = map(int,input().split())
    p = len(set(A))
    if (N - p) % 2 == 0:
        print(p)
    else:
        print(p-1)
if __name__ == "__main__":
    main() #endline===============================================

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


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


  ll n = s.size();


  rep(i, n){
    if(i%2 == 0){
      if(s[i] == 'L'){
        cout << "No" << endl;
        return 0;
      }
    }
    else{
      if(s[i] == 'R'){
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;



  return 0;
}


Measured memory_bytes: 256
<?php
function sum($n) {
    $s = 0;
    while ($n > 0) {
        $s += $n % 10;
        $n /= 10;
    }
    return $s;
}

list($n, $a, $b) = explode(' ', fgets(STDIN));
$total = 0;
for ($i = 1; $i <= $n; $i++) {
    $s = sum($i);
    if ($s >= $a && $s <= $b) {
        $total += $i;
    }
}
echo $total;
?>

Measured memory_bytes: 3828
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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

	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	if(a[0] != a[1]){
		cout << a[0] << endl;
	}else{
		cout << a[2] << endl;
	}
}


Measured memory_bytes: 896
use std::collections::HashMap;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let input = read_vec::<usize>();
    let (n, q) = (input[0], input[1]);

    let mut hm = HashMap::new();

    for _ in 1..n {
        let ab = read_vec::<usize>();
        let (a, b) = (ab[0]-1, ab[1]-1);
        (*hm.entry(a).or_insert(vec![])).push(b);

        (*hm.entry(b).or_insert(vec![])).push(a);
    }

    let mut counter = vec![0; n];

    for _ in 0..q {
        let px = read_vec::<usize>();
        let (p, x) = (px[0]-1, px[1]);

        counter[p] += x;
    }

    let mut visited = vec![false; n];
    dfs(0, 0, &hm, &mut visited, &mut counter);

    let ans = counter.iter().map(|&i| format!("{}", i)).collect::<Vec<_>>().join(" ");
    
    println!("{}", ans);
}

fn dfs(
    i: usize, 
    c: usize, 
    tree: &HashMap<usize,Vec<usize>>, 
    visited: &mut Vec<bool>,
    v: &mut Vec<usize>) {
    if visited[i] {
        return;
    }
    visited[i] = true;
    v[i] += c;
    for &next in tree.get(&i).unwrap().iter() {
        dfs(next, v[i], tree, visited, v);
    }
}

Measured memory_bytes: 59732
import math
a,b,h,m = map(int,input().split())

#角度
H = 360 * (h / 12) + 30 * (m / 60)
M = 360 * (m / 60)
sa = abs(H-M)

if sa < 180:
    x = sa
else:
    x = 360 - sa
#余弦定理
c = a**2 + b**2 - 2*a*b*math.cos(math.radians(x))
print(c**0.5)


Measured memory_bytes: 9528
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N, string S) {
  int s = 0, res = 0;
  for (char c: S) {
    if (c == 'I') ++s;
    else --s;
    chmax(res, s);
  }
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	string S;
	scanf("%lld", &N);
	cin >> S;
	solve(N, S);
	return 0;
}


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

using namespace std;

typedef long long ll;
const int mxn = 1e5;
int K;

bool belong(int fi, int imps[], int n) {
  for (int i = 0; i<n;i++) {
    if (fi == imps[i]) {
      return true;
    }
  }
  return false;
}

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

  cin >> K;

  int fi = K%10;
  int imps[6] = {0,2,4,5,6,8};
  if (belong(fi, imps,6)) {
    cout << "-1" << endl;
  }
  else {
    ll value = K;
    int res = 0;
    while (value!=0) {
      while (value%10!=7)
        value+=K;
      while (value%10==7){
        value/=10;
        res++;
      }
    }
    cout << res << endl;
  }

}


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

int main(){
  int W,H,N;
  cin >> W >> H >> N;
  vector<int> x(N);
  vector<int> y(N);
  vector<int> a(N);
  for(int i = 0;i < N;i++)
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  vector<vector<bool>> p(H + 1,vector<bool>(W + 1,true));
  for(int i = 0;i < N;i++){
    if(a.at(i) == 1){
      for(int j = 0;j <= H;j++){
        for(int k = 0;k < x.at(i);k++){
          p.at(j).at(k) = false;
        }
      }
    }
    if(a.at(i) == 2){
      for(int j = 0;j <= H;j++){
        for(int k = x.at(i) + 1;k <= W;k++){
          p.at(j).at(k) = false;
        }
      }
    }
    if(a.at(i) == 3){
      for(int j = 0;j <= W;j++){
        for(int k = 0;k < y.at(i);k++){
          p.at(k).at(j) = false;
        }
      }
    }
    if(a.at(i) == 4){
      for(int j = 0;j <= W;j++){
        for(int k = y.at(i) + 1;k <= H;k++){
          p.at(k).at(j) = false;
        }
      }
    }
  }
  int countx = 0,county = 0;
  for(int i = 0;i <= W;i++){
    county = 0;
    for(int j = 0;j <= H;j++){
      if(p.at(j).at(i) == true)
        county++;
    }
    if(county != 0)
      break;
  }
  for(int i = 0;i <= H;i++){
    countx = 0;
    for(int j = 0;j <= W;j++){
      if(p.at(i).at(j) == true)
        countx++;
    }
    if(countx != 0)
      break;
  }
  if((countx == 0)&&(county == 0)){
    cout << 0 << endl;
    return 0;
  }
  cout << (countx - 1) * (county - 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int ans;
  REP(i,5) {
    int x;
    cin >> x;
    if(x==0) ans=i+1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;
int main(){
  int kazu = 0;
  cin >> kazu;
  vector<vector<int>> kou(kazu,vector<int>(3));
  for(int i = 0;i <= kazu - 1;i++){
    for(int j = 0;j <= 2;j++){
      cin >> kou[i][j];
    }
  }
  vector<vector<long long>> dp(kazu,vector<long long>(3));
  for(int i = 0;i <= kazu - 1;i++){
    for(int j = 0;j <= 2;j++){
      dp[i][j] = 0;
    }
  }
  for(int i = 0;i<= 2;i++){
    dp[0][i] = kou[0][i];
  }
  for(int i = 1;i <= kazu - 1;i++){
    for(int j = 0;j <= 2;j++){
      for(int k = 0;k <= 2;k++){
        if(k != j){
          dp[i][j] = max(dp[i - 1][k] + kou[i][j],dp[i][j]);
        }
      }
    }
  }
  cout << max({dp[kazu - 1][0],dp[kazu - 1][1],dp[kazu - 1][2]}) << endl;
  return 0;
}

Measured memory_bytes: 11136
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.DP
{
    class EDPC_S
    {
        public const int mod = 1000000007;

        public static void Main()
        {
            var k = Console.ReadLine().Select(i => (byte)(i - '0')).ToArray();
            var d = int.Parse(Console.ReadLine());

            var dp = new long[k.Length + 1, d];


            var r = 0;
            for (int h = 0; h < k.Length; h++)
            {
                for (int i = 0; i < d; i++)
                {
                    for (int j = 0; j <= 9; j++)
                    {
                        int ij = (i + j) % d;
                        dp[h + 1, ij] = (dp[h + 1, ij] + dp[h, i]) % mod;
                    }
                }
                for (int j = 0; j < k[h]; j++)
                    dp[h + 1, (r + j) % d]++;
                r = (r + k[h]) % d;
            }

            var result = (dp[k.Length, 0] - 1 + (r == 0 ? 1 : 0)) % mod;
            Console.WriteLine(result);
        }
    }
}


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

const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	string s;cin>>s;
	if(s.back()!='s')cout<<s<<"s"<<endl;
	else cout<<s<<"es"<<endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(void)
{
  int i,k,n;
  scanf("%d%d", &k, &n);
  int a[n];
  for(i=0;i<n;i++) {
  scanf("%d",&a[i]);
  }
  int l[n];
  for(i=0;i<n-1;i++){
  l[i]=a[i+1]-a[i];
  }
  l[n-1]=k+a[0]-a[n-1];
  int max=l[0];
  for(i=0;i<n;i++){
  if(l[i]>max)
    max=l[i];
  }
  int t=0;
  for(i=0;i<n;i++){
  t = t + l[i];
  }
  t = t - max;
  printf("%d",t);
  
  return 0;
}

Measured memory_bytes: 3280
#include<bits/stdc++.h>
// sakib malik
#define MOD (int)(1e9 + 7)
using namespace std;

long long fact(int n){
    long long ans = 1;
    for(long long i = 1; i <= n; i++){
        ans = (ans * i%MOD)%MOD;
    }
    return ans;
}

int main(){
    int n, m;
    cin >> n >> m;
    int total = (m + n);
    if(!(total&1)){
        if(max(m, n) > total/2){
            cout << 0;
            return 0;
        }
        long long ans = ((long long)(fact(total / 2) * fact(total / 2))%MOD * 2ll)%MOD;
        cout << ans;
    }
    else{
        if(max(m, n) > (total + 1)/2){
            cout << 0;
            return 0;
        }
        int a = min(m, n);
        int b = max(m, n);
        long long ans = ((long long)fact(a) * fact(b))%MOD;
        cout << ans;
    }


}

Measured memory_bytes: 3604
S = input()
N = len(S)
mod = 10**9 + 7

dp = [[0] * 13 for _ in range(N+1)]
dp[0][0] = 1

for i in range(N):
    if S[i] == '?':
        for j in range(10):
            for k in range(13):
                dp[i+1][(k*10+j)%13] += dp[i][k] % mod
    else:
        for k in range(13):
            dp[i+1][(k*10+int(S[i]))%13] += dp[i][k] % mod
            
print(dp[-1][5] % mod)            

Measured memory_bytes: 61788
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int main() {
    ll n,k;
    bool d[10];
    std::cin >> n>>k;
    Fill(d,true);
    for (int i = 0; i < k; i++) {
        ll tmp;
        std::cin >> tmp;
        d[tmp]=false;
    }
    for (int i = n; i <= 999999; i++) {
        string str_n = to_string(i);
        bool ok = true;
        for (int j = 0; j < str_n.length(); j++) {
            // std::cout << str_n[j]-'0'<< std::endl;
            if(!d[str_n[j]-'0']){
                ok = false;
                break;
            }
        }
        // std::cout << i << std::endl;
        if(ok){
            std::cout << i << std::endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int N, H, W;
  cin >> N >> H >> W;
  cout << (N - W + 1) * (N - H + 1) << endl;
  return 0;
}


Measured memory_bytes: 256
s=int(input())
a=[]
a.append(s)
c=0
while c==0:
    if s%2==0:
        a.append(s//2)
    elif s%2==1:
        a.append(3*s+1)
    s=a[-1]
    for i in range(len(a)-1):
            if s==a[i]:
                c=len(a)
print(c)



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

using namespace std;
using ll = long long;

const int N = 82;

int n, m;
int a[N][N], b[N][N];
const int M = 13000;

bitset<2*M> dp[N][N];

int main() {

	scanf("%d %d", &n, &m);

	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++)
		scanf("%d", &a[i][j]);
	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++)
		scanf("%d", &b[i][j]);

	dp[n][m - 1][M] = 1;
	dp[(n - 1)][m][M] = 1;
	for(int i = n - 1; i >= 0; i--) {
		int id = i % 2, id1 = (i + 1) % 2;
		for(int j = m - 1; j >= 0; j--) {
			int diff = abs(a[i][j] - b[i][j]);
			dp[i][j]  = dp[i+1][j] >> diff;
			dp[i][j] |= dp[i+1][j] << diff;
			dp[i][j] |= dp[i][j + 1] >> diff;
			dp[i][j] |= dp[i][j + 1] << diff;
		}
	}

	int ans = 1e9;

	for(int d = 0; d < 2 * M; d++) {
		if(dp[0][0][d]) {
			ans = min(ans, abs(d - M));
		}
	}

	assert(ans < M);

	printf("%d\n", ans);
}


Measured memory_bytes: 21120
#include <stdio.h>
#define SIZE 10000
int main() {
    int n,a[SIZE],i,count=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(i=1;i<=n;i++){
        if(a[i]!=i){
            count++;
        }
    }
    if(count<=2){
         printf("YES\n");
    }
    else{
         printf("NO\n");
    }
   
    return 0;
}


Measured memory_bytes: 1648
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		scan.close();
		for (int a = 1; a < 10; a++) {
			for (int b = 1; b < 10; b++) {

				if (a * b == n) {
					System.out.println("Yes");
				return;
				}
			}
		}
		System.out.println("No");
	}
}

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

int main(){
    int N, i, j, flag = 0;
    vector <string> str;
    string tmp;

    cin >> N;

    for(i = 0; i < N; i++){
        cin >> tmp;
        str.push_back(tmp);
    }

    for(i = 0; i < N; i++){
        if(i > 0){
            if(str[i - 1][str[i - 1].size() - 1] != str[i][0]){
                flag = 1;
            }
            for(j = 0; j < i; j++){
                if(str[i] == str[j]){
                    flag = 1;
                }
            }
            if(flag == 1){
                break;
            }
        }
    }

    if(flag == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;

void main(){
	auto ip = readln.split.to!(int[]), A=ip[0], B=ip[1];

	if(A<6) writeln(0);
	else if(A<13) writeln(B/2);
	else writeln(B);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n, need;
    while (cin >> n && n) {
        cin >> need;
        int sum = 0;
        rep(i, n) {
            int a; cin >> a;
            sum += min(need / n, a);
        }
        out(sum);
    }
}




Measured memory_bytes: 3016
#include<stdio.h>

using namespace std;

int H[251];

bool isin(int i, int n){
    return i >= 1 && i <= n;
}

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


    for(int i = 1; i <= n; i++){
        scanf("%d", &H[i]);
    }

    for(int i = 1; i <= n; i++){
        printf("node %d", i);

        printf(": key = %d", H[i]);

        if(isin(i / 2, n)){
            printf(", parent key = %d", H[i/2]);
        }

        if(isin(2 * i, n)){
            printf(", left key = %d", H[2 * i]);
        }

        if(isin(2 * i + 1, n)){
            printf(", right key = %d", H[2 * i + 1]);
        }

        printf(", \n");
    }
}


Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
typedef long long ll;
using namespace std;

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

  ll l, r; cin >> l >> r;
  int ans = 1e9;
  for(ll i = l; i < l+2019 && i < r; ++i) {
    for(ll j = r; j > r-2019 && i < j; --j) {
      int i_mod = i%2019;
      int j_mod = j%2019;

      ans = min(ans, i_mod*j_mod%2019);
    }
  }
  cout << ans << '\n';
  return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int W,H,x,y;
	cin>>W>>H>>x>>y;

	int m=1;
	if(W%2||W/2!=x)m=0;
	if(H%2||H/2!=y)m=0;
	printf("%.20f %lld\n",0.5*W*H,m);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    long long int x,temp=100,i=0;
    bool flag=true;
    scanf("%lld",&x);
    while(temp<x){
        temp=temp*1.01;
        i++;
    }
    printf("%lld",i);
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define    For(i,n) for(int i=0;i<n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    nl     "\n"
#define    test   int t;cin>>t;for(int l=0;l<t;l++)
#define    End    return 0
#define    gt     greater<int>()
#define    ll     long long int

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

    //test
    {
        ll n,c=0;
        cin>>n;
        ll a[n];
        For(i,n)cin>>a[i];
        for(int i=0;i<n-1;i++)
        {
            if(a[i]>a[i+1]){
                c+=a[i]-a[i+1];
                a[i+1]=a[i];
            }
        }
        cout<<c;
    }
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    ll N;
    cin >> N;
    ll dp[100005][3];

    fill_n(*dp, 100005 * 3, -LLINF);
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        char op;
        ll A;
        if (i == 0) op = '+';
        else cin >> op;
        cin >> A;
        if (op == '-') A = -A;

        chmax(dp[i + 1][0], dp[i][0] + A);
        chmax(dp[i + 1][1], dp[i][1] - A);
        chmax(dp[i + 1][2], dp[i][2] + A);
        if (op == '-') {
            chmax(dp[i + 1][1], dp[i][0] + A);
            chmax(dp[i + 1][2], dp[i][1] - A);
        }
        chmax(dp[i + 1][1], dp[i][2] + A);
    }
    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
    return (0);
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vll A(N);
    rep(i, N) cin >> A[i];
    int bit_num = 61;
    vint bit_on_num(bit_num, 0);
    rep(i, bit_num) {
        rep(j, N) {
            if (((A[j] >> i) & 0x01) != 0) bit_on_num[i]++;
        }
    }
    ll ans = 0;
    vll ans_bit_on_num(bit_num, 0);
    rep(i, N) {
        rep(b, bit_num) {
            bool bit_on = false;
            if (((A[i] >> b) & 0x01) != 0) {
                bit_on = true;
            }
            if (bit_on == true) {
                bit_on_num[b]--;
                ans_bit_on_num[b] += (N - 1 - i) - bit_on_num[b];
            }
            else {
                ans_bit_on_num[b] += bit_on_num[b];
            }
            
        }
    }
    ll m = 1000000007;
    rep(b, bit_num) {
        ans += (((1LL << b) % m) * (ans_bit_on_num[b] % m)) % m;
        ans %= m;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] start = new int[3] { 0, 0, 0 };
            int[] goal = new int[3];
            int t = 0;
            int dist = 0;
            string ans = "Yes";
            for (int i = 0; i < n; i++)
            {
                goal = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                t = goal[0] - start[0];
                dist = Math.Abs(goal[1] - start[1]) + Math.Abs(goal[2] - start[2]);
                if ((t - dist) < 0 || (t - dist) % 2 != 0)
                {
                    ans = "No";
                    break;
                }
                start = goal;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 17336
# ABC 110: B – 1 Dimensional World's Tale
n, m, x, y = [int(s) for s in input().split()]
wants_x = [int(s) for s in input().split()]
wants_y = [int(s) for s in input().split()]

wants_x.append(x)
wants_x.sort()

wants_y.append(y)
wants_y.sort()

print('War' if x >= y or max(wants_x) >= min(wants_y) else 'No War')

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

public class Main{
    
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	
	int n=Integer.parseInt(br.readLine());
	int ans=0;
	
	for(int i=0;i<n;i++){
	    int a=Integer.parseInt(br.readLine());
	    if(isPrime(a)){
		ans++;
	    }
	}
	System.out.println(ans);

	
    }
    static boolean isPrime(int n){

	if(n==1)
	    return true;
	
	
	for (int i = 2; i * i <= n; i++) {
	    if(n % i == 0)
		return false;
	}
	return true;
    }
}



Measured memory_bytes: 30368
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		
		if( a == 5 && b == 5 && c == 7){
			
			System.out.println("YES");
			
		} else if( a == 7 && b == 5 && c == 5){
			
			System.out.println("YES");
			
		} else if( a == 5 && b == 7 && c == 5){
			
			System.out.println("YES");
			
		} else {
			
			System.out.println("NO");
			
		}
	}
}

Measured memory_bytes: 21332
import math
a,b,X = map(int, input().split())
x = X/(a**2)

if x<=b/2:
        t = 2*a*x/(b**2)
        print(90-math.degrees(math.atan(t)))

else:
        if a**2*b==X:
                print(0)
        else:
                t = a/(2*b-2*x)
                print(90-math.degrees(math.atan(t)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables ***************/
int c[3][3];
/**********************************************/

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

    REP(i, 3) REP(j, 3) cin >> c[i][j];

    int a[3], b[3];
    a[0] = 0;
    REP(i, 3) b[i] = c[0][i];
    REP(i, 3) a[i] = c[i][0] - b[0];
/*
    REP(i, 3) cout << a[i] << " ";
    cout << endl;
    REP(i, 3) cout << b[i] << " ";
    cout << endl;
*/
    int ans[3][3];
    REP(i, 3) REP(j, 3) ans[i][j] = a[i] + b[j];

    REP(i, 3) REP(j, 3){
        if(ans[i][j] != c[i][j]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

int main()
{
    string s;
    cin >> s;
    cout << s.substr(0, 4) << " " << s.substr(4) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
    int n;
    int i;
    cin>>n;
    std::vector<int> p(n);
    rep(i,n){
        cin>>p[i];
    }
    int count=1;
    rep(i,n-1){
        if(p[i+1]<p[i]+1){
            count+=1;
        }else{
            p[i+1]=p[i];
        }
    }
    cout<<count;
    return 0;

}

Measured memory_bytes: 1024
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

using ll = long long int;
using namespace std;

int main(){
  ll N, X, Y;
  cin >> N >> X >> Y;
  X--;
  Y--;

  std::vector<long long int> count(N);
  long long int dist;
  for(ll i = 0; i < N; i++){
    for(ll j = i+1; j < N; j++){
      if(i <= X){
        if(j <= X) dist = j-i;
        else if(X < j && j < Y) dist = X-i + min(j-X, Y-j+1);
        else dist = X-i+1+j-Y;
      }
      else if(X < i && i < Y){
        if(X < j && j < Y) dist = min(j-i, Y-X+1-(j-i));
        else dist = min(j-i, j-Y+(i-X+1));
      }
      else{
        dist = j-i;
      }
      count[dist]++;
    }
  }
  count[1] = N;
  cerr << "Answer:" << endl;
  for(ll i = 1; i < N; i++){
    cout << count[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

A,P= LI()

kakera = A * 3
print((P+kakera)//2)

Measured memory_bytes: 9152
X, K, D = map(int ,input().split())

if K * D < abs(X):
    ans = abs(X) - K * D
else:
    if abs(X) < D:
        if K % 2 == 0:
            ans = abs(X)
        else:
            ans= abs(abs(X) - D)
    else:
        if abs(X) // D % 2 == 0:
            if K % 2 == 0:
                ans = abs(X) % D
            else:
                ans = abs(abs(X) % D - D)
        else:
            if K % 2 == 0:
                ans = abs(abs(X) % D - D)
            else:
                ans = abs(X) % D

print(ans)

Measured memory_bytes: 9144