akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')
from math import atan, degrees

def solve():
    a, b, x = MI()

    v = pow(a, 2) * b
    h = x / pow(a, 2)
    #print(x, v)

    if 2 * x == v:
        theta = 45
    elif 2 * x > v: # 半分より多く入っている
        #print('a')
        tei = a
        # taka =
        taka = 2 * (v - x) / pow(a, 2)
        theta = degrees(atan(taka / tei))
    else:           # 半分より少ない
        tei = b
        # taka = 2 * x / b
        taka = 2 * x / (a * b)
        theta = 90 - degrees(atan(taka / tei))
    print(theta)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool f(string s){
    rep(i,0,s.size()/2){
        if(s[i]!=s[s.size()-i-1])return false;
        
    }
    return 1;
}

signed main (){
    int n,m,a,b;
    cin>>n>>m>>a>>b;
    vector<int> v(n),vv(m);
    rep(i,0,n)cin>>v[i];
    rep(i,0,m)cin>>vv[i];
    sort(all(v));
    sort(all(vv));
    rep(i,a+1,b+1){
        if(v[v.size()-1]<i && i<=vv[0]){
            cout<<"No War"<<endl;
            return 0;
        }
    }
    cout<<"War"<<endl;



}
/*
1-2
0.5-2

010
01110
00111
000000111
*/


Measured memory_bytes: 256
#include<stdio.h>

int A[1000000], n;

int binarySearch(int key) {
	int left = 0;
	int right = n-1;
	int mid;
	while(left <= right) {
		mid = (left + right) / 2;
		if(A[mid] == key) return 1;
		if(key < A[mid]) right = mid-1;
		else if(key > A[mid]) left = mid+1; 
	}
	return 0;	
}

int main() {
	int i, q, key, sum = 0;
	
	scanf("%d", &n);
    for(int i = 0; i < n; i++) { 
        scanf("%d", &A[i]);
    }
    
    scanf("%d", &q);
    for(int i = 0; i < q; i++) {
	    scanf("%d", &key);
		if( binarySearch(key)) sum++; 
	}
	printf("%d\n", sum);
	
	return 0;    
}
  

Measured memory_bytes: 2992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }


vector<int> simulate(int N, ll left, const vector<ll> &A, int start) {
    map<ll, int> s;
    vector<int> stk;
    for(ll i = start; left > 0; i++, left--) {
        ll a = A[i % N];
        if(s[a] > 0) {
            int sa = s[a];
            while(stk.size() >= sa) {
                s[stk.back()] = 0;
                stk.pop_back();
            }
        } else {
            stk.push_back(a);
            s[a] = stk.size();
        }
    }
    return stk;
}

int main() {
    int N; ll K; cin >> N >> K;
    vector<ll> A(N); cin >> A;

    vector<int> next_index(N);
    {
        map<ll, int> last;
        for(int i = N * 2 - 1; i >= 0; i--) {
            if(i < N) next_index[i] = last[A[i]];
            last[A[i%N]] = i % N;
        }
    }

    ll left = K * N;

    vector<int> visited_index(N, -1);
    vector<ll> diff_sum;
    diff_sum.push_back(0);

    int now = 0;
    while(left) { // O(N)
        if(visited_index[now] >= 0) { // O(1)
            ll sum = diff_sum.back() - diff_sum[visited_index[now] - 1];
            left = left % sum;
        }
        int next = next_index[now];
        ll diff = (next <= now ? next + N - now : next - now) + 1;
        if(diff > left) break;
        left -= diff;
        visited_index[now] = diff_sum.size();
        now = (next + 1) % N;
        diff_sum.push_back(diff + diff_sum.back());
    }

    auto ans = simulate(N, left, A, now);
    rep(i, ans.size()) cout << ans[i] << (i == ans.size() - 1 ? "\n" : " ");

    return 0;
}


Measured memory_bytes: 17908
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	cin>>n>>s;
	for(int p=0;p<4;++p){
		string t(n,'?');
		t[0]=(p%2?'S':'W');
		t[1]=(p/2%2?'S':'W');
		for(int i=1;i<=n;++i){
			int prev=(i%n==0?n-1:i-1);
			int next=(i==n-1?0:i%n+1);
			if((s[i%n]=='o'&&t[i%n]=='S')||(s[i%n]=='x'&&t[i%n]=='W')){
				t[next]=t[prev];
			}
			else t[next]=(t[prev]=='S'?'W':'S');
		}
		if(t[0]==(p%2?'S':'W')&&t[1]==(p/2%2?'S':'W')){
			cout<<t<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int x[100000];

signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(n, m);
    rep1(i, n)scanf("%d", x+i);
    rep1(i, n)x[i] += x[i - 1];

    int now = 0, res = 0;
    rep(i, m){
      int(a);
      if(a > 0)res += x[now + a] - x[now];
      else res += x[now] - x[now + a];
      now += a;
      res %= 100000;
    }
    pri(res);

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(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 itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    int A[6];
    A[0] = abs(b - a) + abs(c - b);
    A[1] = abs(c - a) + abs(b - c);
    A[2] = abs(c - b) + abs(a - c);
    A[3] = abs(a - b) + abs(c - a);
    A[4] = abs(a  -c) + abs(b - a);
    A[5] = abs(b - c) + abs(a - b);
    sort(A, A + 6);
    cout << A[0] << endl;


}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	for (int i = 111; i < 1000; i += 111) {
		if (i >= n) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=list(input())
d={"r":P,"s":R,"p":S}

ans=0
for i in range(N):
    if i>=K and T[i-K]==T[i]:
            T[i]="o"
    else:
        ans+=d[T[i]]
print(ans)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

const int MOD = 998244353;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};

vector<mint> F_{1, 1}, R_{1, 1}, I_{0, 1};

void check_fact(int n) {
  for (int i = I_.size(); i <= n; i++) {
    I_.push_back(I_[MOD % i] * (MOD - MOD / i));
    F_.push_back(F_[i - 1] * i);
    R_.push_back(R_[i - 1] * I_[i]);
  }
}

mint I(int n) { check_fact(abs(n)); return n >= 0 ? I_[n] : -I_[-n]; }
mint F(int n) { check_fact(n); return n < 0 ? 0 : F_[n]; }
mint R(int n) { check_fact(n); return n < 0 ? 0 : R_[n]; }
mint C(int n, int r) { return F(n) * R(n - r) * R(r); }
mint P(int n, int r) { return F(n) * R(n - r); }
mint H(int n, int r) { return n == 0 ? (r == 0) : C(n + r - 1, r); }


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  mint ans=0;
  for (int i=M; i<=2*M; i++) {
    ans += (H(N,i) - N*H(N,i-(M+1))) * C(N,M-(i-M)*2) - N*H(N-1,i-M)*C(N-1,M-(i-M)*2-1);
  }  
  cout << ans << endl;
}

Measured memory_bytes: 24252
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

ll C[510], S[510], F[510];

ll next(ll i, ll t) {
    if (t <= S[i])return S[i];
    if (t % F[i] == 0)return t;
    return (t / F[i] + 1) * F[i];
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    int N;
    cin >> N;
    rep(i, N - 1) {
        cin >> C[i] >> S[i] >> F[i];
    }
    for (int i = 0; i < N; i++) {
        ll a = 0;
        for (int j = i; j < N; j++) {
            if (j == N - 1) {
                break;
            }
            a = next(j, a) + C[j];
        }
        cout << a << endl;
    }
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc137/submissions/6838768からコピー


package main
 
import (
    "bufio"
    "fmt"
	"os"
	"sort"
	"strings"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func nextLine() string {
    sc.Scan()
    return sc.Text()
}
 
func main() {
	var n int
	fmt.Scan(&n)
	d := map[string]int{}
	ans := 0
	for i:=0; i<n; i++ {
		tmp := nextLine()
		strLst := strings.Split(tmp,"")
		sort.Strings(strLst)
		tmp = strings.Join(strLst,"")
		if _, ok := d[tmp]; ok {
			ans += d[tmp]
			d[tmp]++
		} else {
			d[tmp] = 1
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 11776
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int inf=1000001000;
ll INF=1e18;
ll mod=1000000007;
ll MOD=INF;


int main() {
  int n;
  cin >> n;
  vector<ll> a(n+1,0);
  for (int i=1;i<=sqrt(n)+2;i++){
      for (int j=1;j<=sqrt(n)+2;j++){
          for (int k=1;k<=sqrt(n)+2;k++){
              if (i*i+j*j+k*k+i*j+j*k+i*k>n) break;
              a[i*i+j*j+k*k+i*j+j*k+i*k]++;
          }
      }
  }
  for (int i=1;i<=n;i++) cout << a[i] << endl;
}


Measured memory_bytes: 3592
def main():
    N,M,K=map(int,input().split())

    G=[[] for i in range(N)]

    for i in range(M):
        a,b=map(int,input().split())
        G[a-1].append(b-1)
        G[b-1].append(a-1)

    B=[[] for i in range(N)]
    for i in range(K):
        c,d=map(int,input().split())
        B[c-1].append(d-1)
        B[d-1].append(c-1)
    trace=[-1 for i in range(N)]
    Group=[]

    for i in range(N):
        stack=[]
        if trace[i]==-1:
            trace[i]=0
            stack.append(i)
        Group_tmp=[]
        while len(stack)>0:
            index=stack.pop()
            Group_tmp.append(index)
            for j in G[index]:
                if trace[j]==-1:
                    trace[j]=0
                    stack.append(j)
        if len(Group_tmp)!=0:
            Group.append(Group_tmp)
    res=[0 for i in range(N)]
    GroupMarker=[-1 for i in range(N)]

    for i in range(len(Group)):
        for j in range(len(Group[i])):
            person=Group[i][j]
            GroupMarker[person]=i
            r=len(Group[i])-len(G[person])-1
            res[person]=r

    for i in range(len(B)):
        for j in range(len(B[i])):
            if GroupMarker[i]==GroupMarker[B[i][j]]:
                res[i]-=1
    res=list(map(str,res))
    print(" ".join(res))

if __name__=="__main__":
    main()





Measured memory_bytes: 128944
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

int main(void){
	while(1){
		int n, m; cin >> n;
		if(n == 0) return 0;
		cin >> m;
		string s; cin >> s;
		string ans;
		rep(i, n) ans += "IO";
		ans += "I";
		int sum = 0;
		// cout << ans << endl;
		for (int i = 0; i < m; ++i){
			if(s[i] != 'I') continue;
			// cout << s.substr(i, 2 * n + 1);
			if(ans == s.substr(i, 2 * n + 1))
				sum++;
		}
		printf("%d\n", sum);
	}
}

Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main()
{
  // ll a;
  // string b, bb;
  // cin >> a >> b;
  // b = b.erase(1, 1);
  // a = a * stoi(b) / 100;
  ll a;
  double b;
  cin >> a >> b;
  ll bb = b * 100 + 0.5;
  a *= bb;
  a /= 100;
  cout << a;
}


Measured memory_bytes: 3704
#include<stdio.h>
#define N 100000

int main(){
  int n,i,s[N],q,t,left,right,mid,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t);
    left=0;
    right=n;
    while(left<right){
      mid=(left+right)/2;
      if(s[mid]==t){
	count++;
	break;
      }
      else if(t<s[mid]){
	right=mid;
      }else{
	left=mid+1;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}



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

int main() {
   int n, k;
   cin >> n >> k;
   int d[k];
   int a[k][n];
   rep(i, k) {
      cin >> d[i];
      rep(j, d[i]) {
          cin >> a[i][j];
      }
   }

   int ans[n];

   rep(i, n) {
       ans[i] = 0;
   }

   rep(i, k) {
       rep(j, d[i]) {
           ans[a[i][j] - 1] = 1;
       }
   }

   int count = 0;
   rep(i, n) {
       if (ans[i] == 0) count++;
   }

   cout << count << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define int long long
using namespace std;

main(){
  
  int a,b,c,d,n;
  
  cin>>a>>b>>c>>d;
  cin>>n;

  if(a*2<b) b=a*2;
  if(b*2<c) c=b*2;
  if(c*2<d) d=c*2;

  int ans=0;

  ans+=n/2*d;
  n%=2;
  
  ans+=n*c;
  
  cout<<ans<<endl;
  
}


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

int main(){
    int a, b, c;
    int x, y;
    cin >> a >> b >> c  >> x >> y;
    int res= 10000000;
    // a,b ばら買い
    int p1 = a*x + b*y;
    // 全部セットで買うとき
    int p2 = 2 * c * max(x, y);
    // 必要最小限のcを買って、その他をabで埋める
    int tmp = x < y ? b : a;
    int p3 = 2 * c * min(x, y) + tmp*abs(x-y);
    res = min(p1, min(p2, p3));
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>


struct node{
  struct node *R,*L,*oya;
  int s;
} ;
typedef struct node *tree;

tree run;

void make(int x){
  tree b=NULL;
  tree a=run;
  tree c;
  
  c=malloc(sizeof(struct node));
  c->s=x;
  c->L=NULL;
  c->R=NULL;

  while(a!=NULL){
    b=a;
    if(c->s < a->s){
      a=a->L;
    }
    else a=a->R;
  }

  c->oya=b;
  if(b==NULL) run=c;
  else{
    if(c->s < b->s){
      b->L=c;
    }
    else b->R=c;
  }
}

int serch(struct node *x, int y){
  while(x!=NULL){
    if(x->s==y) return 1;
    else if(y < x->s) x=x->L;
    else x=x->R;
  }
  return -1;
}
void in(tree x){
  if(x==NULL) return;
  in(x->L);
  printf(" %d",x->s);
  in(x->R);
}

void pred(tree x){
  if(x==NULL) return;
  printf(" %d",x->s);
  pred(x->L);
  pred(x->R);
}

int main(){
  int  i, data,x,find;
  char order[20];

  scanf("%d",&data);

  for(i=0;i<data;i++){
    scanf("%s",order);

    if(order[0]=='f'){
      scanf("%d",&x);
      find=serch(run,x);
      if(find==1) printf("yes\n");
      else printf("no\n");
    }
    
    else if(order[0]=='i'){
      scanf("%d",&x);
      make(x);
    }
    else if(order[0]=='p'){
      in(run);
      printf("\n");
      pred(run);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 20456
import math

def fun(n):
    if n%2==0 and n!=2:return False
    for i in range(3,round(math.sqrt(n))+1,2):
        if n%i==0:return False
    else: return True

n=int(input())
count=0
for i in range(n):
    if fun(int(input())):
        count+=1
print(count)


Measured memory_bytes: 5684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int main(void){
    int n;cin>>n;
    int min=200001, tmp;
    int ans=0;
    rep(i,n){
        cin>>tmp;
        if(min>=tmp){ans++;min=tmp;}
    }
    co(ans);
}


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

int main(){
  int A,B;
  cin >> A >> B;
  int ans = 2000;
  for (int i=1001;i>0;i--){
    int tmp_a = i*0.08;
    int tmp_b = i*0.10;
    if (tmp_a==A && tmp_b==B){
      if (ans > i){
        ans = i;
      }
    }
  }
  if (ans == 2000){
    cout << -1 << endl;
  }else{
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif N == 1 and M != 1:
    print(M - 2)
elif M == 1 and N != 1:
    print(N - 2)
else:
    print((N-2)*(M-2))

Measured memory_bytes: 3064
program Main
    use,intrinsic :: iso_fortran_env
    implicit none

    integer(int64) n, sqn, a, b
    
    read *, n
    sqn = nint(sqrt(dble(n))) + 1
    do a=1,sqn
        if (mod(n, a) == 0) then
            b = n/a
        end if
    end do
    
    a = max(b, n/b)
    do b=1,10
        if (a < 10_int64 ** b) then
            print '(i0)', b
            exit
        end if
    end do
end program Main


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
ll f(ll n){
  ll ans = 0;
  rep(i,50){
    ll tmp = pow(2,i),cnt = 0;
    if((n / tmp) % 2 == 0){
      cnt = (n / tmp) / 2 * tmp;
      if(cnt % 2 != 0)ans += pow(2,i);
    }
    else{
      cnt = (n / tmp) / 2 * tmp + (n % tmp);
      if(cnt % 2 != 0)ans += pow(2,i);
    }
  }
  return ans;
} 
int main(){
  ll a,b;
  cin >> a >> b;
  a = max(a - 1,(ll)0);
  cout << (f(a + 1) ^ f(b + 1)) << endl;
  return 0;
}


Measured memory_bytes: 4072
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <vector>

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

template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& v) {
    os << "(" << v.first << ", " << v.second << ")";
    return os;
}

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

int main()
{
    int n;
    cin >> n;
    ll ans = 0;
    vector<int> pairs(n+1, 2);
    pairs[0] = 0;
    pairs[1] = 1;

    for (int m = 2; m * m < n; m++) {
        pairs[m * m] += 1;
        for (int j = m + 1; j <= n / m; j++) {
            pairs[m * j] += 2;
        }
    }

    for (int c = 1; c < n; c++) {
        ans += (ll)pairs[n - c];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7156
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, j, n) for (int i = j; i < n; ++i)
#define sz(s) (int)s.size()
#define F first
#define S second
#define eb emplace_back
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) {
    for (auto &vi: vec) os << vi << " "; return os;
}

int main() {
    int n;
    cin >> n;
    int even = 0, odd = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if (a % 2 == 0) even++;
        else odd++;
    }
    int cnt = 0;
    while (1) {
        if (odd <= 0 || even <= 0) break;
        if (odd > even) {
            odd -= 2; even++;
        } else {
            even--;
        }
        cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3092
# C - Traveling
# https://atcoder.jp/contests/abc086/tasks/arc089_a

# dt = ti+1 −ti
# dist = abs(xi+1 − xi)+abs(yi+1 − yi)

# キーポイント: パリティ
# x + y は毎秒ごとに必ず偶奇が入れ替わる。

n = int(input())

T = 0
X = 0
Y = 0

cnt = 0

for i in range(n):
    t,x,y= map(int,input().split())

    if abs(x-X) + abs(y-Y) <= (t-T) and (x+y)%2 == t%2:
        cnt += 1
    T,X,Y = t,x,y
print("Yes" if cnt == n else "No")
    


Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

int main(){
	
	int N, K;
	cin >> N >> K;
	
	cout << (N % K == 0 ? 0 : 1) << endl;
	
	
	
	
	
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused_macros, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap};

// Main
fn main(){
    input!{
        x: chars,
        y: chars,
        z: chars,
    }
    println!("{}{}{}", x[0],y[0],z[0]);
}




Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

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

Measured memory_bytes: 256
//
//  main.cpp
//  Test1
//
//  Created by Anson Thai on 10/4/20.
//  Copyright © 2020 Anson Thai. All rights reserved.
//

#include <iostream>

int main(int argc, const char * argv[]) {
    // insert code here...
    //std::cout << "Hello, World!\n";
    
    int n;
    
    
    std::cin >> n;
    
    int b[n-1];
    int i;
    
    //read inputs
    for (i=0;i<n-1;i++) {
        std::cin>>b[i];
    }

    //print B array
    for (i=0;i<n-1;i++) {
         //std::cout << b[i] << ' ';
    }
    //std::cout << "\n---\n";
    
    
    int a[n];
    
    a[0] = b[0];
    
    //create A array
    for (i=1;i<n-1;i++) {
        
        //a[i] = b[i];
        
        if (b[i-1] <= b[i]) {
            a[i] = b[i-1];
        } else {
            a[i] = b[i];
        }
    }
    
    a[n-1] = b[n-2];
    
    //print A array
    for (i=0;i<n;i++) {
         //std::cout << a[i] << ' ';
    }
    //std::cout << "\n---\n";

    //sum A array
    
    int sum = 0;
    for (i=0;i<n;i++) {
        sum += a[i];
    }
    
    std::cout << sum << std::endl;
    //std::cout << "\n---\n";
    
    return 0;

    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N,K;
  cin >> N >> K;
  
  int cnt = 0;
  while(true){
    if(N < K){
      //cout << N << endl;
      cnt++;
      break;
    }
    
    int mod = N % K;
    N = N / K;
    //cout << mod;
    cnt++;    
  }
  
  cout << cnt;
}

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

using namespace std;
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define PB(a) push_back(a)
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int func(int n){
  int a=0;
  while(n%2==0){n/=2;a++;}
  return a;
}
int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int ans=0;
  REP(i,a+1){
    REP(j,b+1){
      REP(k,c+1){
        if(500*i+100*j+50*k==x)ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define T 1
#define F 0
using namespace std;
int equation();
int formula();
int p,a,b,c,d,e,f,g,h,i,j,k;
string str;
int main(){
  int r;
  while(1){
    cin >> str;
    if(str=="#") break;
    int flag=0;
    for(int a1=0;a1<2;a1++){
      a=a1;
      for(int b1=0;b1<2;b1++){
	b=b1;
	for(int c1=0;c1<2;c1++){
	  c=c1;
	  for(int d1=0;d1<2;d1++){
	    d=d1;
	    for(int e1=0;e1<2;e1++){
	      e=e1;
	      for(int f1=0;f1<2;f1++){
		f=f1;
		for(int g1=0;g1<2;g1++){
		  g=g1;
		  for(int h1=0;h1<2;h1++){
		    h=h1;
		    for(int i1=0;i1<2;i1++){
		      i=i1;
		      for(int j1=0;j1<2;j1++){
			j=j1;
			for(int k1=0;k1<2;k1++){
			  k=k1;
			  p=0;
			  r=equation();
			  if(r==F){
			    flag=1;
			    break;
			  }
			}
			if(flag==1) break;
		      }
		      if(flag==1) break;
		    }
		    if(flag==1) break;
		  }
		  if(flag==1) break;
		}
		if(flag==1) break;
	      }
	      if(flag==1) break;
	    }
	    if(flag==1) break;
	  }
	  if(flag==1) break;
	}
	if(flag==1) break;
      }
      if(flag==1) break;
    }
    if(flag==0) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}
int equation(){
  int val=formula(),val1;
  if(str[p]=='='){
    p++;
    val1=formula();
    if(val==val1) return T;
  }
  return F;
}
int formula(){
  int r,r1;
  while(1){
    if(str[p]=='T'){
      p++;
      return T;
    }
    if(str[p]=='F'){
      p++;
      return F;
    }
    if(str[p]=='a'){
      p++;
      return a;
    }
    if(str[p]=='b'){
      p++;
      return b;
    }
    if(str[p]=='c'){
      p++;
      return c;
    }
    if(str[p]=='d'){
      p++;
      return d;
    }
    if(str[p]=='e'){
      p++;
      return e;
    }
    if(str[p]=='f'){
      p++;
      return f;
    }
    if(str[p]=='g'){
      p++;
      return g;
    }
    if(str[p]=='h'){
      p++;
      return h;
    }
    if(str[p]=='i'){
      p++;
      return i;
    }
    if(str[p]=='j'){
      p++;
      return j;
    }
    if(str[p]=='k'){
      p++;
      return k;
    }
    if(str[p]=='-'&&str[p+1]=='>'){
      p+=2;
      r=formula();
      p++;
      if(r1==T&&r==F) return F;
      return T;
    }
    if(str[p]=='-'){
      p++;
      r=formula();
      return 1-r;
    }
    if(str[p]=='('){
      p++;
      r1=formula();
    }
    if(str[p]=='*'){
      p++;
      r=formula();
      p++;
      if(r1==T&&r==T) return T;
      return F;
    }
    if(str[p]=='+'){
      p++;
      r=formula();
      p++;
      if(r1==F&&r==F) return F;
      return T;
    }
  }
}

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

using i64 = int64_t;

int calc_dist(int cx, int cy, int x, int y){
    return abs(cx-x) + abs(cy-y);
}

int main(){
    int n;
    cin >> n;
    vector<tuple<int, int, int>> v;
    int idx = -1;
    for(int i=0;i<n;++i){
        int x, y, h;
        cin >> x >> y >> h;
        v.emplace_back(x, y, h);
        if(idx == -1 && h > 0)idx = i;
    }

    for(int cx=0;cx<=100;++cx){
        for(int cy=0;cy<=100;++cy){
            int h = get<2>(v[idx]) + calc_dist(cx, cy, get<0>(v[idx]), get<1>(v[idx]));
            bool ok = true;
            for(int i=0;i<n;++i){
                if(i==idx)continue;
                int d = max(0, h - calc_dist(cx, cy, get<0>(v[i]), get<1>(v[i])));
                if(d != get<2>(v[i])){
                    ok = false;
                    break;
                }
            }
            if(ok){
                cout << cx << " " << cy << " " << h << endl;
                return 0;
            }
        }
    }

    assert(false);
}


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

using namespace std;

int main()
{
    int n, d, u, v, i, j, x;

    cin >> n;

    bool adjmat[n + 1][n + 1];

    for(i = 0; i <= n; i++)
    {
        for(j = 0; j <= n; j++)
            adjmat[i][j] = false;
    }

    for(i = 0; i < n; i++)
    {
        cin >> x >> d;
        for(j = 0; j < d; j++)
        {
            cin >> u;
            adjmat[x][u] = true;
        }
    }

    for(i = 1; i <= n; i++)
    {
        for(j = 1; j <= n; j++) {
            cout << adjmat[i][j];
            if(j < n)
                cout << " ";
        }
        cout << endl;
    }
}



Measured memory_bytes: 3092
N, M = map(int, input().split())
G = [[] for _ in range(N)]
G1= [[] for _ in range(N)]
H = [0]*N
for _ in range(N+M-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G1[b-1].append(a-1)
    H[b-1]+=1
def topological_sort(G, H):
    res = []
    st0 = set()
    for v, n in enumerate(H):
        if n == 0:
            st0.add(v)
    while st0:
        v = st0.pop()
        res.append(v)
        for nv in G[v]:
            H[nv]-=1
            if H[nv] == 0:
                st0.add(nv)
    return res
res = topological_sort(G, H)
index = [-1]*N
for i, v in enumerate(res):
    index[v] = i
ans = [-1]*N
for v in res[1:]:
    nv = max(G1[v], key = lambda x:index[x])
    ans[v] = nv+1
ans[res[0]] = 0
print(*ans, sep = '\n')    
            

Measured memory_bytes: 44888
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    [_, k] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    as <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    let ss = sortOn length $ group $ sort as
    print $ length $ concat $ take (length ss - k) ss


Measured memory_bytes: 55676
def listToStr(list):
    return ''.join(list)

def getChar(h, w):
    h_parity = h % 2
    w_parity = w % 2
    total_parity = (h_parity + w_parity) % 2
    
    if total_parity == 0:
        return "#"
    else:
        return "."

def getMatrix(h, w):
    result = []
    for i in range(h):
        result.append([])
        for j in range(w):
            result[i].append(getChar(i, j))
    return result

def input_parse():
    inputs = []
    while True:
        input_HW = input().split(" ")
        (h, w) = (int(input_HW[0]),int(input_HW[1]))
        if h == 0 and w == 0:
            break
        inputs.append((h, w))
    return inputs

def output_matrix(matrix):
    for line in matrix:
        print(listToStr(line))
    print()

inputs = input_parse()
for input in inputs:
    matrix = getMatrix(input[0], input[1])
    output_matrix(matrix),0

Measured memory_bytes: 7948
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

using pii = pair<int, int>;
int n, p[100], id[100];
char s[100][20];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%s %d", s[i], p + i);
	for (int i = 0; i < n; i++)
		id[i] = i;
	sort(id, id + n, [](int a, int b) {
		int x = 0;
		while (s[a][x] != 0 || s[b][x] != 0) {
			if (s[a][x] != s[b][x])
				return s[a][x] < s[b][x];
			x++;
		}
		return p[a] > p[b];
	});
	for (int i = 0; i < n; i++)
		printf("%d\n", id[i] + 1);
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<string>
#include<map>
using namespace std;

int main() {
	int n;
	char str[10], com[13];
	map<string, bool>T;

	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%s%s", com, str);
		if (com[0] == 'i')T[string(str)] = true;
		else {
			if (T[string(str)])printf("yes\n");
			else printf("no\n");
		}
	}

	return 0;
}

Measured memory_bytes: 47444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD ll(1e9+7)
#define MAX_N 200005
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


ll factorial[MAX_N];
void make_factorial_tableMOD(){
    factorial[0] = 1;
    for(int i = 1; i < MAX_N; i++){
        factorial[i] = factorial[i-1]*i%MOD;
    }
}

ll bisection_powerMOD(ll x,ll y){
    if(y==0)        { return 1; }
    ll t = bisection_powerMOD(x*x%MOD,y/2);
    if(y%2==1)      { t = t*x%MOD; }
    return t;
}

ll nCrMOD(int n, int r){
    if(n<r || n<0 || r<0){return 0;}
    if(n==0){return 1;}
    ll a = factorial[n];
    ll b = a*bisection_powerMOD(factorial[r],(MOD-2))%MOD;
    ll c = b*bisection_powerMOD(factorial[n-r],MOD-2)%MOD;
    return c % MOD;
}

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

    make_factorial_tableMOD();
    ll ans = 0;
    for(int i = 1; i*3 <= n ; i++){
        ll ex =  n - i*3;
        ans += nCrMOD(ex+i-1,i-1);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 5164
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int n,m;
    scanf("%d",&n);
    int x[3*100005];
    memset(x,0,sizeof(x));
    int max1=-1;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&m);
        x[m+1]++;
        x[m-1]++;
        x[m]++;
    }
    for(int i=0;i<3*100005;i++)
        max1=max(max1,x[i]);
    printf("%d\n",max1);
    return 0;
}

Measured memory_bytes: 4392
N = int(input())
list_a = list(map(int, input().split()))
list_b = list(map(int,input().split()))
sum1 = sum(list_a)
for i in range(N):
    k = list_a[i]-list_b[i]
    if k <0:
       list_a[i] = 0
    else:
       list_a[i] = k
    if k>0:
      continue
    if(list_a[i+1]+k < 0):
        list_a[i+1] = 0
    else:
        list_a[i+1] = list_a[i+1]+k

print(sum1 - sum(list_a))

Measured memory_bytes: 19244
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int N;cin>>N;
  int res = 0;
  for (int i = 1; i <= N; i++)
  {
    int Q = N/i;
    res +=i*(Q)*(Q+1)/2;
  }
  cout<<res<<endl;
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

#define debug(val) "[ " << #val " : " << (val)
#define space " "
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vector<ll>>
#define vii vector<vector<int>>
#define PI (double)(atan(1)*4)
#define pb push_back
#define pi pair<int , int >
#define ff first
#define ss second
#define INF 2000000000
#define delta 0.0000000001
vi dx = {-1, 0, 0, 1};
vi dy = {0, -1, 1, 0};
const int Mod = 1000 * 1000 * 1000 + 7 ;
vll mul_mat(vll a , vll b) {
    vll res(2 , vl(2,0)) ;
    int n = 2 ;
    for(int i=0;i<n;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                res[i][j] += a[i][k] * b[k][j] ;
                res[i][j] %= Mod ;
            }
        }
    }

    return res ;
}

void solve() {
    int n ;
    cin >> n ;
    string s;
    cin >> s;
    vi w(n) , r(n) ;
    for(int i=0;i<n;i++){
        if(i == 0 ) {
            if(s[i] =='W') w[i] = 1 ;
            else r[i] = 1 ;
        }else{
            w[i] = w[i-1] + (s[i] == 'W') ;
            r[i] = r[i-1] + (s[i] == 'R') ;
        }
    }
    int res = INT_MAX ;
    for(int i=0;i<n;i++){
        int pre = i+1 ;
        int post = n - (i+1 );
        int change1 = w[i] ;
        int change2 = r[n-1] - r[i] ;
        int cost = min(change1 , change2) + abs(change1 - change2) ;
        res = min(res , cost ) ;
    }
    res = min(res , r[n-1]) ;
    cout << res << endl;
}


int main() {
#ifdef _DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0); // FAST IO
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
        solve();
    }
}

Measured memory_bytes: 5132
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	string a, b, c, res; cin >> a >> b;
    int num, numroot;
    c = a + b;
    num = atoi(c.c_str());
    numroot = (int)sqrt((double)num);
    if (numroot*numroot == num)
    {
        res = "Yes";
    }
    else
    {
        res = "No";
    }
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
const int M=1e9+7,N=1000002;
int pw(int x,int y){
	int z=1;
	for (;y;y>>=1,x=1ll*x*x%M)
		if (y&1) z=1ll*z*x%M;
	return z;
}
int INV(int x){return pw(x,M-2);}
int f[N][13],i,j,k,n;
char s[N];
signed main(){
	scanf("%s",s+1),n=strlen(s+1);
	f[0][0]=1;
	for (i=0;i<n;i++)
		for (j=0;j<13;j++)
			if (s[i+1]=='?')
				for (k=0;k<10;k++) (f[i+1][(j*10+k)%13]+=f[i][j])%=M;
			else (f[i+1][(j*10+s[i+1]-48)%13]+=f[i][j])%=M;
	printf("%d",f[n][5]);
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  cout << A[N-1];
  for (int i = 1; i < N; i++) cout << ' ' << A[N-i-1];
  cout << endl;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int func1(int a){
  if (a<0) {
    a *=-1;
    return a;
  }
  else {
    return a;
  }
}
 
 
int main(){
  int N,K;
  cin >>N>>K;
  vector<int64_t> vec;
  for (int i=0;i<N;i++){
    int64_t a;
    cin >>a;
    vec.push_back(a);
  }
  vector<int64_t> dp(N);
  dp[0]=0;
  for (int i=1;i<N;i++){
    int64_t m=1000000000000000000;
    for (int j=1;j<K+1;j++){
      if (i-j>-1){
      	m =min(m,dp[i-j]+func1(vec[i-j]-vec[i]));
      }
    }
    dp[i]=m;
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1908
from collections import deque
def inpl(): return list(map(int, input().split()))

N = int(input())
A = inpl()
X = sorted([(a, i) for i, a in enumerate(A, start=1)], key=lambda x: [x[0], -x[1]])
answer = [0]*(N+1)
a, i = X.pop()

for c in range(1, N):
    b, j = X.pop()
    answer[i] += (a-b)*c
    i = min(i, j)
    a = b
answer[i] += a * N

print(*answer[1:], sep="\n")


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

int main()
{
  string S;
  int res = INF;
  cin >> S;

  int N=S.length();
  rep(i,N-2){
    int num;
    num = atoi(S.substr(i,3).c_str());
    int diff = 753-num;
    if(diff<0) diff=-diff;
    res = min(res,diff);
  }

  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <stack>

using namespace std;

int n;
long long ans, sum[100005];
long long f[100005];
long long c;
struct ss{
    long long x;
    long long v;
    bool operator < (const ss& other) {
        if (x == other.x) return v < other.v;
        return x < other.x;
    }
}s[100005];

long long g[100005];

void solve() {
    sort(s+1,s+n+1);
    g[0] = 0;
    long long now = 0, mx = 0;
    for (int i = 1; i <= n; i++) {
        now += s[i].v-(s[i].x-s[i-1].x);
        mx=max(now,mx);
        g[i]=mx;
    }
    ans=max(ans,g[n]);
    long long res = 0;
    for (int i = n; i>=1;i--) {
        res+=s[i].v;
        ans=max(ans,g[i-1]+res-2*(c-s[i].x));
    }
}

int main() {
    cin>>n>>c;
    for (int i = 1; i <= n; i++) {
        scanf("%lld%lld", &s[i].x, &s[i].v);
    }
    solve();
    for (int i = 1; i <= n; i++) s[i].x=c-s[i].x;
    solve();
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		//??\????????????
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int c = sc.nextInt();
		int[][] rc = new int[r+1][c+1];
		//?¨????
		for (int ri = 0; ri < r; ri++) {
			for (int ci = 0; ci < c; ci++) {
				rc[ri][ci] = sc.nextInt();
				rc[r][ci] += rc[ri][ci];
				rc[ri][c] += rc[ri][ci];
			}
			rc[r][c] += rc[ri][c];
		}
		//??????
		for (int ri = 0; ri <= r; ri++) {
			for (int ci = 0; ci <= c; ci++) {
				System.out.print(rc[ri][ci]);
				if (ci < c) {
					System.out.print(" ");
				} else {
					System.out.println("");
				}
			}
		}
	}

}

Measured memory_bytes: 42704
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))

table = [[-1 for i in range(max(M)+1)] for j in range(n)]

def solve(i, m):
    if m == 0:
        return True
    elif i >= n:
        return False
    elif table[i][m] != -1:
        return table[i][m]
    elif m - A[i] >= 0:
        res = solve(i + 1, m) or solve(i + 1, m - A[i])
        table[i][m] = res
        return res
    else:
        res = solve(i + 1, m)
        table[i][m] = res
        return res

for m in M:
    if solve(0, m):
        print('yes')
    else:
        print('no')

Measured memory_bytes: 8088