akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
    string in; cin >> in;
    bool isb = (in[0] == 'B');
    int res = 0;
    for(auto c : in){
        if((isb and c == 'W') or (not isb and c == 'B')){
            isb ^= true;
            res++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int l1 = 1, r1 = 2 + ((m - 1)/2) * 2; 
    int l2 = r1 + 1, r2 = l2 + 2 + ((m - 2)/2) * 2;
    //cout << l1 << " " << r1 << " " << l2 << " " << r2 << endl;
    while(l1 < r1 && m > 0) {
        cout << l1 << " " << r1 << endl;
        l1++; r1--;
        m--;
    }
    while(l2 < r2 && m > 0) {
        cout << l2 << " " << r2 << endl;
        l2++; r2--;
        m--;
    }

    return 0;
}
// 1 2 3 4 5
// . .
//     .   .

// 1 2 3 4 5 6 7 8
// .     . .   .
//   . .

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std ;
int Max( int a , int b ){
    return a > b ? a : b ;
}
int main(){
    string s , t ;
    cin >> s >> t ;
    int len_s = s.size() , len_t = t.size() ;
    int dp[len_s+1][len_t+1] ;
    for( int i = 0 ; i <= len_s ; i++ ){
        for( int j = 0 ; j <= len_t ; j++ ){
            dp[i][j] = 0 ;
        }
    }
    for( int i = len_s - 1 ; i >= 0 ; i-- ){
        for( int j = len_t - 1 ; j >= 0 ; j-- ){
            if( s[i] == t[j] ) dp[i][j] = 1 + dp[i+1][j+1] ;
            else dp[i][j] = Max( dp[i+1][j], dp[i][j+1] ) ;
        }
    }
    string ans ;
    int i = 0 , j = 0 ;
    while( ans.size() != dp[0][0] ){
        if( s[i] == t[j] ){
            ans += s[i] ;
            i++, j++ ;
        }
        else {
            if( dp[i+1][j] > dp[i][j+1] ){
                i++ ;
            }
            else j++ ;
        }
    }
    cout << ans ;
    return 0 ;
}

Measured memory_bytes: 35456
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://vjudge.net/contest/241120#problem/F>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
string solve(string S){
    string res;
    for(int i = 0; i < 10;i++){
        if(count(S.begin(),S.end(),'0'+i) == 4) return "NA";
    }
    ll cnt = 0;
    while(true){
        while(S.length() < 4){
            S = "0" + S;
        }
        if(S == "6174") break;
        string L = S;
        sort(L.rbegin(),L.rend());
        sort(S.begin(),S.end());
        S = to_string(atoll(L.c_str())-atoll(S.c_str()));
        cnt++;
    }
    res = to_string(cnt);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string S;
    while(cin >> S){
        if(S == "0000") break;
        cout << solve(S) << endl;
    }
    return 0;
}



Measured memory_bytes: 3220
#include <stdio.h>

#define lli long long int

int main() {
	lli a, b, x = 0, y = 0;
	scanf("%lld %lld", &a, &b);
	if (b % 4 == 0)
		y = b;
	else if (b % 4 == 1)
		y = 1;
	else if (b % 4 == 2)
		y = b + 1;
	if (a % 4 == 0)
		x = a;
	else if (a % 4 == 1)
		x = 1;
	else if (a % 4 == 2)
		x = a + 1;
	b = x ^ y ^ a;
	printf("%lld\n", b);
	return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	int n,i,cnt=0,a;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a;
		if(i%2 && a%2 ) cnt++;
	}
	cout<<cnt<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3608
const lines=readlines(open("/dev/fd/0"))
let
    state=0
    global input
    input()=lines[state+=1]
end
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
intLine()=map(intSub,split(input()))
function main()
    a,b,_=sort(intLine())
    print(Int(a*b/2))
end
main()

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

int main() {
	int n;
	string s;
	cin >> n >> s;
	ll r = 0, g = 0, b = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R')
			r++;
		if (s[i] == 'G')
			g++;
		if (s[i] == 'B')
			b++;
	}
	ll ans = r * g * b;
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			int k = 2 * j - i;
			if (k < n && s[i] != s[j] && s[i] != s[k] && s[j] != s[k])
				ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

	int n = (b - a) - 1;
	int len_a = n * (n + 1) / 2;
	int x = len_a - a;

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


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>

using namespace std;


int main()
{
	int n;
	int num=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(x%2)
		{
			cout<<"first"<<endl;
			return 0;
		}
	}
	cout<<"second"<<endl;
	return 0;
}

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

int main(void)
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	string a;
	cin>>a;
	
    if(a=="SUN")
        cout<<7;
    else if(a=="MON")
        cout<<6;
    else if(a=="TUE")
        cout<<5;
    else if(a=="WED")
        cout<<4;
    else if(a=="THU")
        cout<<3;
    else if(a=="FRI")
        cout<<2;
    else
        cout<<1;
    
    
	return 0;
}

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

#define FAST ios_base:: sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define ff first
#define ss second
#define mp make_pair
#define FOR(i,a,b) for(ll i=a; i<b ; i++)
typedef long long ll;

ll gcd(ll a, ll b){
	return __gcd(a,b);
}

int main(){
	FAST;
	ll n;	cin >> n;
	ll a[n+1];
	memset(a,0,n+1);
	for(int i=1; i<=n ; i++)	cin >> a[i];
	ll L[n+1];
	ll R[n+2];
	L[0] = 0;
	R[n+1] = 0;
	for(int i=1; i<=n; i++)
		L[i] = gcd(L[i-1],a[i-1]);
		
	for(int i=n; i>=0 ; i--)
		R[i] = gcd(R[i+1],a[i]);
	
	ll ans = 1;
	for(int i=1; i<=n; i++)
		ans = max(ans,gcd(L[i],R[i+1]));
		
	cout << ans;
		
	
}




Measured memory_bytes: 2560
import numpy as np

line = input().split()
H = int(line[0])
W = int(line[1])

array = np.ndarray((H, W), np.uint8)

for i in range(H):
    line = input()
    for j in range(W):
        if line[j] == '.':
            array[i, j] = 0
        elif line[j] == '#':
            array[i, j] = 1

W_condition = np.sum(array, axis=0)!=0
H_condition = np.sum(array, axis=1)!=0

array = array[H_condition, :]
array = array[:, W_condition]

h, w = array.shape

for i in range(h):
    line = ''
    for j in range(w):
        if array[i, j] == 0:
            line += '.'
        elif array[i, j] == 1:
            line += '#'
    print(line)



Measured memory_bytes: 12508
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        int a = scan.nextInt();
        String op = scan.next();
        int b = scan.nextInt();
        
        int cnt = 0;
        
        if( op.charAt(0)== '+' )System.out.println(a+b);
        else if( op.charAt(0)== '-' )System.out.println(a-b);
        
	  }
}

Measured memory_bytes: 23124
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  for(int i = 0; i < h; ++i){
      cin >> s.at(i);
  } 
  int ans = 0;
  for(int is = 0; is < (1<<h); ++is){
    for(int js = 0; js < (1<<w); ++js){
        int cnt = 0;
        for(int i = 0; i < h; ++i){
            for(int j = 0; j < w; ++j){
                if (is>>i&1) continue; //消去されてたら飛ばす
                if (js>>j&1) continue; //消去されてたら飛ばす
                if (s.at(i).at(j) == '#') cnt++; //黒塗りをカウント
            }
        }
        if (cnt == k) ans++;
        } 
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<algorithm>
#include<deque>
#include<climits>
#include<cassert>
#include<cmath>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 110

using namespace std;

int V,E,ans;
vector<int> G[MAX];
int COST[MAX][MAX];
bool used[MAX];

void dfs(int node,deque<int>& deq,int sp){
  if(node >= 15)return;

  if(node >= 2){
    int tmp = [&]()mutable->int{
      int ret = 0;
      int mincost[node];
      rep(i,node) mincost[i] = IINF;
      for(int i=0;i<node;i++){
	for(int j=i+1;j<node;j++){
	  int cost = COST[deq[i]][deq[j]];
	  if(cost==0)return -1;
	  mincost[i] = min(mincost[i],cost);
	  mincost[j] = min(mincost[j],cost);
	}
      }
      rep(i,node) ret += mincost[i]; 
      return ret;
    }();
    if(tmp != -1)ans = max(ans,tmp);
  }

  REP(i,sp,V){
    if(used[i])continue;
    if(G[i].size() < node)continue;
    used[i] = true;
    deq.push_back(i);
    dfs(node+1,deq,i+1);
    deq.pop_back();
    used[i] = false;
  }
}

int main()
{
  cin >> V >> E;
  rep(i,E){
    int u,v,f;
    cin >> u >> v >> f;
    u--,v--;
    G[u].push_back(v);
    G[v].push_back(u);
    COST[u][v] = COST[v][u] = f;
  }

  deque<int> deq;
  dfs(0,deq,0);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1264
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>

using namespace std;

int x,a;
int ans;

int main() {
  cin >> x >> a;

  if (x < a) {
    ans = 0;
  }else {
    ans = 10;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N, X = map(int, input().split())

a, p = [1], [1]
for i in range(N):
  a.append(a[i] * 2 + 3)
  p.append(p[i] * 2 + 1)

def f(N, X): # X <= 0 や X > a_N を許容し解説本文から簡略化
  if N == 0:
    return 0 if X <= 0 else 1
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1)
  else:
    return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))



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

#define rep(i, N)   for(int i  = 0; i < (int)N; i++)
#define INF 10000000

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

    vector<int> L(M, 0), R(M, 0);
    rep(i, M)   cin >> L.at(i) >> R.at(i);

    int Rmin = INF, Lmax = 0;
    rep(i, M)
    {
        Lmax = max(Lmax, L.at(i));
        Rmin = min(Rmin, R.at(i));
    }

    if(Lmax <= Rmin)    cout << Rmin - Lmax + 1 << endl;
    else    cout << 0 << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
      Scanner sc = new Scanner(System.in);

        Integer N = sc.nextInt();

        Integer ans = 0;
        if (N%1000 != 0) {// N が1000で割り切れないとき
            ans = (N/1000 + 1)*1000 - N;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 35684
#include <bits/stdc++.h>
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;

int n, a[18], b[18], dp[19][1<<18][51];
vector<int> mask[19];

int main(){
    memset(dp, 0x3f, sizeof dp);
    scan(n);
    for(int i = 0; i < n; i++)
        scan(a[i]);
    for(int i = 0; i < n; i++)
        scan(b[i]);
    for(int i = 0; i < (1<<n); i++)
        mask[__builtin_popcount(i)].emplace_back(i);
    dp[0][0][0] = 0;
    for(int i = 1; i <= n; i++){
        for(int pre : mask[i-1]){
            //previously taken
            for(int l = 0; l < 51; l++){
                //last number
                for(int j = 0; j < n; j++){
                    if(dp[i-1][pre][l] == 0x3f3f3f3f)
                        continue;
                    //take # j
                    if(!(pre&(1<<j))){
                        int cur = pre|(1<<j);
                        int val;
                        if((j^i)&1) //if same parity
                            val = a[j];
                        else
                            val = b[j];
                        if(val < l)
                            continue;
                        
                        int mv = 0, ij = j;
                        //get index of j
                        for(int k = 0; k < j; k++){
                            if((pre&(1<<k)))
                                ij--;
                        }
                        for(int k = j+1; k < n; k++){
                            if(pre&(1<<k))
                                ij++;
                        }
                        mv = abs(ij);
                        //print(i-1, pre, l, i, cur, val, mv);
                        dp[i][cur][val] = min(dp[i][cur][val], dp[i-1][pre][l] + mv);
                    }
                }
            }
        }
    }
    
    int i = (1<<n)-1;
    int ans = *min_element(dp[n][i], dp[n][i]+51);
    if(ans == 0x3f3f3f3f)
        puts("-1");
    else
        print(ans/2);
    
    return 0;
}

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

bool prime[100001];
int cnt[100001] = {0};

bool is_2017like(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) {
          prime[N] = false;
          return false;
        }
    }
    prime[N] = true;
    return prime[(N+1)/2];
}

void Main()
{
  ll q; cin >> q;
  prime[2] = true;
  prime[1] = false;
  for(int i = 4; i <= 100000; i++) {
    prime[i] = false;
    i++;
  }
  for(int i = 3; i <= 100000; i++) {
    if (is_2017like(i)) cnt[i] = cnt[i-1] + 1;
    else cnt[i] = cnt[i-1];
    i++;
    cnt[i] = cnt[i-1];
  }
  rep(i,q) {
    int l,r; cin >> l >> r;
    //cout << cnt[l-1] << ' ' << cnt[r] << endl;
    cout << cnt[r] - cnt[l-1] << endl;
  }
}

int main()
{
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 4128
//ナイーブで間に合わなかったので、qを使って、変化があった選手についてだけ翌日見ることにした。
//コードは特に汚い
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[][] = new int[N][N-1];
		for(int i=0;i<N;i++) {
			for(int j=0;j<N-1;j++) {
				A[i][j]=sc.nextInt()-1;
			}
		}
		sc.close();
		int INF = Integer.MAX_VALUE/2;
		int cnt[] = new int[N]; //各選手の次の対戦相手を表すポインタがどこにあるか
		int p[] = new int[N]; //各選手の次の対戦相手
		for(int i=0;i<N;i++) {
			p[i] = A[i][0];
		}
		
		Queue<Integer> q = new ArrayDeque<>();
		Queue<Integer> q_check = new ArrayDeque<>();
		
		//日にち
		int day = 0;
		boolean isStop = false;
		for(;day<1000000;day++) {
			if(day==0) {
				for(int j=0;j<N;j++) {
					if(p[j]==-1||p[j]==INF)continue;
					if(p[p[j]]!=j) continue;
					//マッチング成功
					p[p[j]]=INF;
					p[j]=INF;
				}
			
				isStop = true;
				for(int j=0;j<N;j++) {
					if(p[j]==INF) {
						cnt[j]++;
						if(cnt[j]!=N-1) p[j]=A[j][cnt[j]];
						else p[j]=-1;
						isStop = false;
						q.add(j);
					}
				}
			}
			else {
				while(!q.isEmpty()) {
					int now = q.poll();
					if(p[now]==-1||p[now]==INF)continue;
					if(p[p[now]]!=now) continue;
					//マッチング成功
					p[p[now]]=INF;
					q_check.offer(p[now]);
					p[now]=INF;
					q_check.offer(now);


				}
				isStop = true;
				while(!q_check.isEmpty()) {
					int now = q_check.poll();
					if(p[now]==INF) {
						cnt[now]++;
						if(cnt[now]!=N-1) p[now]=A[now][cnt[now]];
						else p[now]=-1;
						isStop = false;
						q.add(now);
					}
				}

			}
			if(isStop)break;
		}
		
		for(int i=0;i<N;i++) {
			if(cnt[i]!=N-1) {
				System.out.println(-1);
				return;
			}
		}
		System.out.println(day);
	}
}


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

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

    int len = s.length();
    bool flag_e = true, flag_o = true;
    for(int i = 0; i < len; i += 2) {
        if(!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) flag_e = false;
    }
    for(int i = 1; i < len; i += 2) {
        if(!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) flag_o = false;
    }

    if(flag_e && flag_o) cout << "Yes" << endl;
    else                 cout << "No" << endl;

    return 0;
}

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


void solve(long long H, long long A){
    cout << ceil((double)H/(double)A) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long A;
    scanf("%lld",&A);
    solve(H, A);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI acos(-1.0)
#define test() int t; cin>>t; while(t--)
#define ll long long int
int mod = 1e9 + 7;
int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> a(n), b(m);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	vector<ll> prefA(n + 1), prefB(m + 1);
	prefA[0] = 0;
	prefB[0] = 0;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		prefA[i] = prefA[i - 1] + a[i - 1];
	}
	for (int i = 1; i <= m; i++) {
		prefB[i] = prefB[i - 1] + b[i - 1];
	}
	int j = m;
	for (int i = 0; i <= n; i++) {
		if (prefA[i] > k) break;
		while (prefB[j] > k - prefA[i])	j--;
		ans = max(ans, i + j);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7932
#include<iostream>
#include<vector>
#define ll long long
using namespace std;

vector<int>decompose(ll x){
	vector<int>tmp;
	while(x)tmp.push_back(x%10),x/=10;
	return tmp;
}

ll to_number(vector<int>x){
	ll tmp=0;
	for(int i=x.size()-1;~i;--i)
	(tmp*=10)+=x[i];
	return tmp;
}

ll sum(ll x){
	ll s=0;
	while(x)s+=x%10,x/=10;
	return s;
}

inline ll f(ll x){
	vector<int>dx=decompose(x);
	double mn=1e18;ll ne=-1;
	for(int i=0;i<dx.size();++i){
		for(int d=dx[i];d<=9;++d){
			vector<int>dy=dx;
			dy[i]=d;
			for(int j=0;j<i;++j)dy[j]=9;
			ll y=to_number(dy),sy=sum(y);
			if((double)y/sy<mn)
				mn=(double)y/sy,ne=y;
		}
	}
	return ne;
}

int k;

void solve(){
	ll s=1;
	for(int i=1;i<=k;++i,s=f(s+1))
		cout<<s<<"\n";
}

int main(){
	ios::sync_with_stdio(0);
	cin>>k;
	solve();
	return 0;
}
            

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

int main()
{
    int A[100000],q,n,B[50000];
    int sum=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>A[i];
    }

    cin>>q;
    for(int i=0;i<q;i++)
    {
        cin>>B[i];
        if(search1(A,n,B[i])) sum++;

    }
    cout<<sum<<endl;

}

Measured memory_bytes: 3580
a = input()
if a == a[::-1]:
    b = a[:int((len(a) - 1) / 2)]
    c = a[int((len(a) + 3) / 2) - 1:]
    if b == b[::-1] and c == c[::-1]:
        print('Yes')
        exit(0)
print('No')


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

using namespace std;

typedef long long ll;

int main(){
  ll N,M;
  ll A[111111],B[111111],H[111111];
  cin >> N >> M;
  ll i;
  
  for(i=1;i<=N;i++)
    cin >> H[i];
  for(i=1;i<=M;i++)
    cin >> A[i] >> B[i];
  
  int x[111111]; //1なら良い展望台、最初は全部1
  for(i=1;i<=N;i++)
    x[i] = 1;

  for(i=1;i<=M;i++){
    if(H[A[i]] < H[B[i]]) x[A[i]] = 0;
    else if(H[A[i]] > H[B[i]]) x[B[i]] = 0;
    else if(H[A[i]] == H[B[i]]) {
      x[A[i]] = 0;
      x[B[i]] = 0;
    }
    }
  ll sum = 0;
  for(i=1;i<=N;i++)
    sum += x[i];
  cout << sum << endl;
}



Measured memory_bytes: 6372
S = input()
T = list(input())

ans = 0
cnt = 0

for i in range(len(S) - len(T) + 1):
    cnt = 0
    for j in range(len(T)):
        # print(S[i + j], T[j])
        if S[i + j] == T[j]:
            cnt += 1
            if ans < cnt:
                ans = cnt


print(len(T) - ans)


Measured memory_bytes: 9080
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll cnt[1001001],calc[1001001];
int main(void){
	int n,i,j,a,m=(int)(1e6)+1,ans=0;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> a;
		++cnt[a];
	}
	for(i=1; i<m; ++i){
		for(j=i; j<m; j+=i){
			calc[j] += cnt[i];
		}
	}
	for(i=1; i<m; ++i){
		if(cnt[i]==1 && calc[i]==1){
			++ans;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 19240
#include<stdio.h>
int main()
{
	int n, a, b, c, d, m;
	while (scanf("%d", &n)>0) {
		m = 0;
		for (a = 0; a <= 9; a ++) {
			for (b = 0; b <= 9; b ++) {
				for (c = 0; c <= 9; c ++) {
					for (d = 0; d <= 9; d ++) {
						if (a+b+c+d == n)
							m++;
					}
				}
			}
		}
		printf("%d\n", m);
	}
	return 0;
}

Measured memory_bytes: 0
# coding:utf-8
n = int(input())
nums = [int(x) for x in input().split(" ")]
flag = True
count = 0
while flag:
    flag = False
    for i in range(n - 1, 0, -1):
        if nums[i] < nums[i - 1]:
            nums[i], nums[i - 1] = nums[i - 1], nums[i]
            flag = True
            count += 1
print(" ".join([str(i) for i in nums]))
print(count)

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

int main(){
  string s,mB,mH;
  cin >> s;
  mB = s; mH = s;
  for(int i = 0;i < s.size();i++){
    if(i%2 == 0){
    mB.at(i) = '0';
    mH.at(i) = '1';
    }else{
    mB.at(i) = '1';
    mH.at(i) = '0';
    }
  }
  int ans = 0;
  int b,h;
  b = 0; h = 0;
  for(int i = 0;i < s.size();i++){
    if(s.at(i) != mB.at(i))
      b++;
  }
  for(int i = 0;i < s.size();i++){
    if(s.at(i) != mH.at(i))
      h++;
  }
  ans = min(b,h);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
 
 
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);cout.tie(NULL);
   
 
      int l,r,d;
      int i,cnt=0;
      cin>>l>>r>>d;
      for(i=l;i<=r;++i)
       {
           if(i%d==0)
             cnt++;
       }
       
       cout<<cnt;
   
    
   
     return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define p 998244353
using namespace std;
int n,m,k;
char c[200010];
void b(int x){
	for(int i=1;i*x+x<=n;i+=2){
		for(int j=1;j<=x;j++)c[i*x+j]='1'+'0'-c[i*x+j];
	}
}
int v[200010],s[200010];
int calc(int q){
	int ret=0;
	for(int i=1;i<=q;i++)
	ret=(1ll*ret*2+(c[i]=='1'))%p;
	return ret;
}
int main(){
	cin>>n;
	scanf("%s",c+1);int ret=0;
	for(int i=1;i<=n;i++){
		ret=(1ll*ret*2+(c[i]=='1'))%p;
	}
	int ans=0,sum=0;
	for(int i=1;i<=n;i++)if(n%i==0)if((n/i)&1){//连续i个相同 
		b(i);
		for(int j=i;j+i<=n;j+=i){
			for(int t=1;t<=i;t++)if(c[t]!=c[j+t]){
				if((c[t]>c[j+t]&&((j/i)&1))||((c[t]<c[j+t]&&((j/i)&1^1)))){
					v[i]=calc(i)+1;
					goto ed;
				}
				else {
					v[i]=calc(i);
					goto ed;
				}
			}
		}
		v[i]=calc(i)+1;
		
		ed:;
		(v[i]-=s[i])%=p;
		for(int j=i;j<=n;j+=i)(s[j]+=v[i])%=p;(sum+=v[i])%=p;
		(ans+=1ll*v[i]*i%p*2%p)%=p;
		b(i);
	}
	cout<<(ans%p+p)%p;;
    return 0;
}








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

int main(){
 int K;
 int S;
 cin >> K >> S;
 int ans=0;
 for ( int i = 0; i <= K; i++){
  for ( int j = 0; j <= K; j++){
    int k=S-i-j;
    if(k>=0 && k<=K){
     ans++;
    }
  }
 }
 cout << ans << endl;
}

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

#define     bip(a)         __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     u              unsigned
#define     pb             push_back
#define     pf             push_front ///for list
#define     mp             make_pair
#define     is             insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));


int main()
{
    int n,a,b,c;
    cin>>n;
    int h[n+5];
    for(int i=0;i<n;i++)cin>>h[i];
    ll dp[n+5];
    for(int i=1;i<=n;i++)dp[i]=inf;
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+2;j++){
            if(j<n)
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n-1]<<endl;
}



Measured memory_bytes: 1408
// https://atcoder.jp/contests/abc070/tasks/abc070_d

#include <iostream>
#include <vector>

using namespace std;

#define MAX 100001
const long long INF = 1e18;

vector<pair<int, int> > graph[MAX];
bool visited[MAX];
long long dist[MAX];

void DFS(int s, long long w)
{
	visited[s] = true;

	for(int i = 0; i < graph[s].size(); i++)
	{
		pair<int, int> v = graph[s][i];

		if(!visited[v.first])
		{
			dist[v.first] = w + v.second;
			DFS(v.first, w + v.second);
		}
	}
}

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

	for(int i = 0; i < N-1; i++)
	{
		int u, v, w;
		cin >> u >> v >> w;

		graph[v].push_back(pair<int, int>(u, w));
		graph[u].push_back(pair<int, int>(v, w));
	}

	int Q, K;
	cin >> Q >> K;

	for(int i = 1; i <= N; i++)
	{
		dist[i] = INF;
		visited[i] = false;
	}

	DFS(K, 0);

	for(int i = 0; i < Q; i++)
	{
		int x, y;
		cin >> x >> y;

		long long first = dist[x];

		long long second = dist[y];

		// cout << "first is " << first << " and second is " << second << endl;
		long long ans = first + second;
		cout << ans << endl;
	}

	return 0;
}

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

const int N = 100010;

int n;
vector <int> G[N];
int f[N];

void dfs(int u, int p) {
	for (int v: G[u]) if (v != p) {
		dfs(v, u);
		f[u] ^= (f[v] + 1);
	}
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i < n; ++i) {
		int u, v; cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1,0);

	printf(f[1] > 0 ? "Alice\n" : "Bob\n");
}

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

const ll mod = 1e9 + 7;

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

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

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

    int n, k;
    cin >> n >> k;
    int num = (n - 2) * (n - 1) / 2 - k;
    if(num < 0) {
        cout << -1 << endl;
        return 0;
    }
    cout << n - 1 + num << endl;
    FOR(i, 2, n + 1) {
        cout << 1 << " " << i << endl;
        FOR(j, i + 1, n + 1) if(num) {
            cout << i << " " << j << endl;
            num--;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int a, b, k;
  cin >> a >> b >> k;
  for (int i = a; i <= b; i++) {
    if (i - a + 1 <= k || b - i + 1 <= k) cout << i << endl;
  }
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3608
package main

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

var sc *bufio.Scanner

func init() {
	// 100MB
	bufsize := 100 * 1024 * 1024
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, bufio.MaxScanTokenSize), bufsize)
	sc.Split(bufio.ScanWords)
}
func readInt() int              { return readIntArray(1)[0] }
func readInt2() (int, int)      { a := readIntArray(2); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(3); return a[0], a[1], a[2] }
func readIntArray(n int) []int {
	s := readStringArray(n)
	a := make([]int, n)
	for i := range a {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}
func readString() string            { return readStringArray(1)[0] }
func readString2() (string, string) { a := readStringArray(2); return a[0], a[1] }
func readStringArray(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		a[i] = sc.Text()
	}
	return a
}
func max(ns ...int) int {
	max := ns[0]
	for _, n := range ns {
		if n > max {
			max = n
		}
	}
	return max
}
func min(ns ...int) int {
	min := ns[0]
	for _, n := range ns {
		if n < min {
			min = n
		}
	}
	return min
}
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	N, R := readInt2()

	if N > 10 {
		fmt.Println(R)
		return
	}

	fmt.Println(R + 100*(10-N))
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <cmath>

using namespace std;

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

    if((c - a - b) > 0) {
        if(  ((long long)4*(a*b)) < (c-a-b)*(c-a-b)  ){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    else {
            cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    answer = 0
    for i in range(M): ## iの辺を消す
        matrix = [[0]*(N) for _ in range(N)]
        for j in range(M):
            if j == i:
                continue
            aa = a[j]-1
            bb = b[j]-1
            matrix[aa][bb] = 1
           
        dist_matrix = floyd_warshall(csgraph=csr_matrix(matrix), directed=False)
        
        if dist_matrix[a[i]-1][b[i]-1] == float('inf'):
            answer += 1
            
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]"
    b = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)

if __name__ == '__main__':
    main()


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

int main(){
    string s1,s2;
    int count=0;
    cin>>s1;
    cin>>s2;

    for(int i = 0 ; i < s1.size() ; i++){
        if(s1[i]!=s2[i]){
            count++;
        }
    }
    cout<<count;
}

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

int main() {
  int N,i;

  cin >> N;

  for(i=0;i<=N/7;i++) {
    if((N-i*7)%4==0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    string S;
    cin >> N >> S;
    ll a[N + 1][3]{};
    map<char, int> m;
    m['R'] = 0;
    m['G'] = 1;
    m['B'] = 2;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) a[i + 1][j] = a[i][j];
        a[i + 1][m[S[i]]]++;
    }
    ll ans = 0;
    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            if (S[i] != S[j]) {
                int id = 0;
                for (int k = 0; k < 3; k++) {
                    if (k != m[S[i]] && k != m[S[j]]) {
                        id = k;
                        break;
                    }
                }
                ans += a[N][id] - a[j + 1][id];
            }
        }
    }
    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            int k = 2 * j - i;
            if (k < N && j < k && k >= 0) {
                if (S[i] != S[j] && S[j] != S[k] && S[i] != S[k]) ans--;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3688
#include <iostream>

using namespace std;

int main(){
    int H, W;
    int a[500][500] = {};
    int temp[500] = {};
    int nCount = 0;

    /* input */
    cin >> H >> W;

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

    /* initialize Array temp */
    for(int j = 0; j < W; j++){
        temp[j] = a[0][j];
    }

    /* Action 1 : to bottom */
    for(int i = 0; i < H - 1; i++){
        for(int j = 0; j < W; j++){
            if(temp[j] % 2 == 1){
                temp[j] = a[i + 1][j] + 1;
                nCount++;
            }
            else{
                temp[j] = a[i + 1][j];
            }
        }
    }
    /* Action 2 : to right */
    for(int j = 0; j < W - 1; j++){
        if(temp[j] % 2 == 1){
            temp[j + 1]++;
            nCount++;
        }
    }

    /* output */
    /* count */
    cout << nCount << endl;
 
    /* initialize Array temp */
    for(int j = 0; j < W; j++){
        temp[j] = a[0][j];
    }

   /* Action 1 : to bottom */
    for(int i = 0; i < H - 1; i++){
        for(int j = 0; j < W; j++){
            if(temp[j] % 2 == 1){
                cout << i+1 << " " << j+1 << " " << i+2 << " " << j+1 << endl;
                temp[j] = a[i + 1][j] + 1;
            }else{
                temp[j] = a[i + 1][j];
            }
        }
    }
    /* Action 2 ; to right */
    for(int j = 0; j < W - 1; j++){
        if(temp[j] % 2 ==1){
            cout << H << " " << j+1 << " " << H << " " << j+2 << endl;
            temp[j+1]++;
        }
    }

    return 0;
}



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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  int c[51];
  for(int l=0;l<n;l++){
    c[l]=0;
  }
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    c[a-1]++;
    c[b-1]++;
  }
 for(int i=0;i<n;i++){
  cout<<c[i]<<endl;
 }


}

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

int n,ans=0;

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		int l=i,r=(n/i)*i;
		//cout<<l<<' '<<r<<endl;
		ans+=((r+l)*(((r-l)/i)+1))/2;
	}
	cout<<ans<<endl;
	
	return 0;
}

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

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


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    ll n;
    cin>>n;
    ll a[5];
    rep(i,5) cin>>a[i];
    ll mi=a[0];
    rep(i,4) mi=min(mi,a[i+1]);
    ll ans=(n-1)/mi+5;
    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll N;
    cin >> N;
    ll pre_t = 0, pre_x = 0, pre_y = 0;
    REP(i, N) {
        ll t, x, y, dt, dx, dy;
        cin >> t >> x >> y;
        dt = t - pre_t;
        dx = abs(x - pre_x);
        dy = abs(y - pre_y);
        bool can = false;
        if (dx+dy<=dt && (dx+dy)%2==dt%2) can = true;
        if (!can) {
            cout << "No\n";
            return 0;
        }
        pre_t = t;
        pre_x = x;
        pre_y = y;
    }
    cout << "Yes\n";
}


Measured memory_bytes: 256
// D - Water Bottle
#include <bits/stdc++.h>
using namespace std;
using dbl = double;
#define PI (M_PI)
#define DEG(rad) ((rad)*180/PI)
#define EPS (0.000000001) // 誤差範囲

dbl f(dbl a, dbl b, dbl rad){//rad 傾けたとき a*a*b の容器にあふれずに入れられる水の量は？
	if(PI/2 - rad < EPS) return 0.0;//誤差範囲で90°といえるなら0を返す
	dbl c = tan(rad);//rad 傾けてみる
	//入れられる水の量: b/a(45°)以下？ yes:容器の体積-空き容量(横から見て、奥行き*△) no:奥行き*△
	return c<=b/a? a*a*b - a*(a*(a*c)/2): a*(b*(b/c)/2);
}

dbl solve(dbl a, dbl b, dbl x){
	dbl ok = PI/2;
	dbl ng = 0;
	dbl volume = 0;
	while(abs(x - volume) >= EPS){
		dbl mid = (ok+ng)/2;// mid: この角度でどれだけ水を入れられるか？
		volume = f(a,b,mid);
		if(volume <= x) ok = mid;// 角度を小さくして、もっと多く入るようにする
		else ng = mid;// 角度を大きくして、もっと少なく入るようにする
	}
	return ok;
}

int main(){
	dbl a,b,x; cin>>a>>b>>x;
	printf("%.10f\n", DEG(solve(a, b, x)));
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LSOne(i) ((i) & -(i))

const int MAXN = 1e5+100;
const ll MOD = 1e9+7;
string s;
ll n, dp[MAXN][13];

void add (ll& a, ll b) {
    a = (a+b)%MOD;
}

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

    cin >> s;
    n = s.length();

    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        int c = s[i];
        if (c == '?') c = -1;
        else c -= '0';

        for (int j = 0; j < 10; j++) {
            if (c != -1 && c != j) continue;
            for (int d = 0; d < 13; d++) {
                add(dp[i+1][(d*10+j)%13], dp[i][d]);
            }
        }
    }

    ll ans = dp[n][5];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10704
# greedy
# 翌日に上がるなら： 全力で買い
# 翌日に下がるなら： 全力で売り
# 値が動かないなら： ステイ
# 最終日なら： 全部売る

N = int(input())
prices = list(map(int, input().split()))

# 初期化
jpy = 1000
stocks = 0

for i in range(N):
    # 最終日なら全部売る
    if i == N - 1:
        jpy += prices[i] * stocks
        stocks = 0
        break
    
    # 翌日に上がるなら全力で買い
    if prices[i+1] > prices[i]:
        stocks += jpy // prices[i]
        jpy = jpy % prices[i]
    # 翌日に下がるなら全力で売り
    elif prices[i+1] < prices[i]:
        jpy += prices[i] * stocks
        stocks = 0
    # 値が動かないならステイ
    else:
        pass
print(jpy)


Measured memory_bytes: 8844
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
int main(void)
{
  string s,t;
  cin >> s >> t;
  vector<vector<int> > sa(26,vector<int>(s.size()+1,0));
  vector<vector<int> > ta(26,vector<int>(t.size()+1,0));
  REP(i,s.size()) sa[s[i]-'a'][i+1]++;
  REP(i,t.size()) ta[t[i]-'a'][i+1]++;
  REP(i,26) REP(j,s.size()) sa[i][j+1]+=sa[i][j];
  REP(i,26) REP(j,t.size()) ta[i][j+1]+=ta[i][j];
  int answer=min(s.size(),t.size());
  for(;;--answer){
    set<vector<int> > ccs;
    REP(i,s.size()-answer+1){
      vector<int> cc;
      REP(j,26) cc.push_back(sa[j][i+answer]-sa[j][i]);
      ccs.insert(cc);
    }
    REP(i,t.size()-answer+1){
      vector<int> cc;
      REP(j,26) cc.push_back(ta[j][i+answer]-ta[j][i]);
      if(ccs.find(cc)!=ccs.end()){
        cout << answer << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4496
#include<iostream>

using namespace std;

int main(){
  int L,A,B,C,D;
  cin >> L >> A >> B >> C >> D;

  int tmp1 = A/C;
  int tmp2 = B/D;

  if(A%C) tmp1++;
  if(B%D) tmp2++;
  
  cout << L-max(tmp1,tmp2) << endl;

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()




using namespace std;

int main(){
  ll ans = 1;
  
  ll N; cin>>N;
  bool f = false;
  REP(i,N){
    ll a; cin>>a;
    //cout<<ans<<endl;
    if(a == 0){
      cout<<0<<endl;
      return 0;
    }
    if(a * ans < ans or a * ans > 1000000000000000000){
      f = true;
      //cout<<-1<<endl;
      //return 0;
    }
    ans *= a;
  }

  if(f) ans = -1;

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    
    if (n % 3 == 0)
    {
        int t = n / 3;
        double ans = t * t * t;
        printf("%.12lf\n", ans);
    }
    else {
        double t = n * 1.0;
        double t1 = t/3.0, t2 = t/3.0, t3 = t/3.0;
        //int p = (n - t * 3);
       
        double V = t1 * t2 * t3;
        printf("%.12lf\n", V);
    }
}

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

int main(){

  int n,m; 
  set<int> s;
  cin >> n;
  for(int i=0; i<n; i++){
    int tmp; cin >> tmp;
    s.insert(tmp);
  }
  cin >> m;
  int ans=0;
  for(int i=0; i<m; i++){
    int tmp; cin >> tmp;
    if(s.find(tmp) != s.end()) ans++;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define VS vector<string>
#define ll long long int
#define debug(x) cout << x << " :" <<#x << endl  
int main(void) {
    string a, b, c;
    cin >> a >> b >> c;
    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES" << endl;                        
    else cout << "NO" << endl;
}


Measured memory_bytes: 256