akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    string S;
    cin >> S;
    ll ans = 0;
    int len = S.size() - 1;
    BitRep(i, len) {
        bitset<9> bit(i);
        string t = S;
        int blen = 1;
        Rep(j, len) {
            if (bit[j]) {
                t = t.substr(0, j + blen) + '+' + t.substr(j + blen);
                blen++;
            }
        }
        ll x = 0;
        string y = "";
        Rep(j, t.size()) {
            if (t[j] == '+') {
                x += stoll(y);
                y = "";
            }
            else y += t[j];
        }
        ans += stoll(y) + x;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
   string S;
   cin >> S;
   if(S[0] == S[1] && S[1] == S[2] || S[1] == S[2] && S[2] == S[3]) cout << "Yes" << endl;
   else cout << "No" << endl;
   return (0);
}

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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n,x[1111],y[1111],s[1111];

signed main(){
    cin>>n;
    rep(i,0,n){
        cin>>x[i]>>y[i];
        s[i]=x[i]+y[i];
        if((s[i]-s[0])%2!=0){
            puts("-1");
            return 0;
        }
    }
    vint values;
    for(int i=30;i>=0;i--)values.pb(1<<i);
    if(s[0]%2==0)values.pb(1);
    int m=values.size();
    cout<<m<<endl;
    rep(i,0,m){
        if(i==m-1)cout<<values[i]<<endl;
        else cout<<values[i]<<" ";
    }
    
    rep(i,0,n){
        int u=x[i]+y[i];
        int v=x[i]-y[i];
        for(auto&& e : values){
            if(u>=0){
                if(v>=0){
                    cout<<"R";
                    u-=e;
                    v-=e;
                }else{
                    cout<<"U";
                    u-=e;
                    v+=e;
                }
            }else{
                if(v>=0){
                    cout<<"D";
                    u+=e;
                    v-=e;
                }else{
                    cout<<"L";
                    u+=e;
                    v+=e;
                }
            }
        }
        cout<<endl;
    }
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

const int MAX_N = 30;

int H, W, K;
int C[MAX_N][MAX_N]; 
int tempC[MAX_N][MAX_N]; 

int del(){
    int ret = 0;

    for(int i=0; i<H; i++){
        vector<pair<int, int>> v;
        int s = 0;
        int cnt = 1;
        for(int j=0; j<W-1; j++){
            if(tempC[i][j] == tempC[i][j+1]){
                cnt++;
            }else{
                v.push_back(make_pair(s, cnt));
                s = j+1;
                cnt = 1;
            }
        }
        v.push_back(make_pair(s, cnt));

        for(int j=0; j<v.size(); j++){
            s = v[j].first;
            int l = v[j].second;
            if(tempC[i][s] == -1) continue;
            if(l < K) continue;
            for(int k=0; k<l; k++){
                ret += tempC[i][s+k];
                tempC[i][s+k] = -1;
            }
        }
    }

    return ret;

}

bool move(){
    bool fl = false;
    for(int i=H-2; i>=0; i--){
        for(int j=0; j<W; j++){
            if(tempC[i][j] == -1) continue;
            if(tempC[i+1][j] == -1){
                tempC[i+1][j] = tempC[i][j];
                tempC[i][j] = -1;
                fl = true;
            }
        }
    }
    return fl;
}


int main(){
    cin >> H >> W >> K;

    string S[H];
    
    for(int i=0; i<H; i++){
        cin >> S[i];
    }
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            C[i][j] = S[i][j] - '0';
        }
    }
    
    int ans = 0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            for(int k=0; k<H; k++){
                for(int l=0; l<W; l++){
                    tempC[k][l] = C[k][l];
                }
            }
            tempC[i][j] = -1;

            int ta = 0;
            int cnt = 0;
            while(true){
                while(move());
                int add = del();
                if(add == 0) break;
                add *= pow(2, cnt);
                ta += add;
                cnt++;
            }
            ans = max(ta, ans);
        }
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
import sys

s = sys.stdin.readline()

cnt = 0
ans = 0
for i in range(len(s)):
    tmp = s[i]
    if 'A' in tmp or 'C' in tmp or 'G' in tmp or 'T' in tmp:
        cnt += 1
    else:
        if cnt > ans:
            ans = cnt
        cnt = 0
if cnt > ans:
    ans = cnt
print(ans)


Measured memory_bytes: 2940
H,W,h,w=map(int,input().split())
p=(10**9-1)//(max(h*w-1,1))
m=p*(h*w-1)+1
vec=[[p for i in range(W+1)] for j in range(H+1)]
sm=0
for i in range(1,H+1):
  for j in range(1,W+1):
    if i%h==0 and j%w==0:
      vec[i][j]=-m
    sm+=vec[i][j]
if sm<=0:
  print("No")
else:
  print("Yes")
  for i in range(1,H+1):
    for j in range(1,W+1):
      print(vec[i][j],end=" \n"[j==W])

Measured memory_bytes: 14984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    string S;
    cin>>S;
    string A,B="";
    A=S.substr(0,1);
    ll c[2]={0};
    rep(0,i,4){
        string C=S.substr(i,1);
        if(A!=C && B==""){
            B=S.substr(i,1);
        }
        if(A==C)++c[0];
        if(B==C)++c[1];
    }
    if(c[0]==2 && c[1]==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#define D(i,a,b)for(int i=a;i>=b;--i)
int f[2005],n,k,M=1e9+7;main(){std::cin>>n>>k;f[n+1]=1;D(i,n,n-k+1)D(j,n,1)f[j]=j>i?0:(f[j]+f[j+1])%M;D(i,n-k,2)(f[1]*=2)%=M;std::cout<<f[1];}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 500010
#define NIL -2000000001

int heap[MAX];

void maxHeapify(int, int);
void buildMaxHeap(int);

int main(void){
  int i, H;
  scanf("%d", &H);

  //1 origin
  for(i = 0; i <= H; i++)
    heap[i] = NIL;

  for(i = 1; i <= H; i++)
    scanf("%d", &heap[i]);
 
  buildMaxHeap(H);

  for(i = 1; i <= H; i++)
    printf(" %d", heap[i]);
  printf("\n");

  return 0;
}

void maxHeapify(int i, int H){
  int l, r, largest, tmp;
  l = 2*i;
  r = 2*i+1;
  if(l <= H && heap[l] > heap[i])
    largest = l;
  else
    largest = i;
  if(r <= H && heap[r] > heap[largest])
    largest = r;

  if(largest != i){
    tmp = heap[i];
    heap[i] = heap[largest];
    heap[largest] = tmp;
    maxHeapify(largest, H);
  }
}

void buildMaxHeap(int H){
  int i;
  for(i = H/2; i >= 1; i--)
    maxHeapify(i, H);
}

Measured memory_bytes: 2552
a, b = map(int, input().split())

if (a==0 or b==0) or (a<0 and b>0):
    print("Zero")

if a>0 and b>0:
    print("Positive")

if a<0 and b<0:
    if (abs(abs(a)-abs(b))+1)%2 == 0:
        print("Positive")
    else:
        print("Negative")

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<char>> a(n, vector<char>(n));
  vector<vector<char>> b(m, vector<char>(m));
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      char num;
      cin >> num;
      a[i][j] = num;
    }
  }
  for(int i=0; i<m; i++){
    for(int j=0; j<m; j++){
      char num;
      cin >> num;
      b[i][j] = num;
    }
  }
  
  bool foundBinA = false;
  for(int i=0; i<n-(m-1); i++){
    for(int j=0; j<n-(m-1); j++){
      bool isBsametoA = true;
      for(int k=0; k<m; k++){
        for(int l=0; l<m; l++){
          if(a[i+k][j+l] != b[k][l]){
            isBsametoA = false;
          }
        }
      }
      if(isBsametoA) foundBinA = true;
    }
  }
  if(foundBinA) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}
  
  
  
  
  

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

using namespace std;

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

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

	return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
struct __test {} test;
using namespace std;
template <typename T>const __test &operator<<(const __test& d,
const T& v) {return cerr << "\033[31m" << v << "\033[0m",d;}
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;



int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	ll a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	cout << a[0]*a[1]*(a[2]&1) << "\n";
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef struct{
	int x;
	int y;
}dir;
const dir D[]={
	{1,0},{-1,1},{0,1},{1,1}
};
const int H=5,W=4;

map<vector<int>,int>memo;
int dfs(const vector<int> &v){
	if(v.empty())return 0;
	if(memo.find(v)!=memo.end())return memo[v];
	int r=v.size();
	for(int h=0;h<H;h++)for(int w=0;w<W&&h*W+w<v.size();w++)for(auto &d:D){
		int h1=h+d.y,w1=w+d.x;
		if(h1*W+w1<v.size() && 0<=h1&&h1<H && 0<=w1&&w1<W && v[h*W+w]==v[h1*W+w1]){
			vector<int> v1;
			for(int i=0;i<v.size();i++)if(i!=h*W+w&&i!=h1*W+w1)v1.push_back(v[i]);
			r=min(r,dfs(v1));
		}
	}
	return memo[v]=r;
}
	
int main(){
	int T;
	for(scanf("%d",&T);T--;){
		memo.clear();
		vector<int>v(H*W);
		for(int i=0;i<H*W;i++)scanf("%d",&v[i]);
		printf("%d\n",dfs(v));
	}
}

Measured memory_bytes: 1128
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 mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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

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

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

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

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

fn main() {
    
    input! {
        n: isize,
        e: isize
    }
    

    //test
    //
    /*
    let n: isize = 1000;
    let e: isize = 1234000;
    */

    const K10: isize = 10000;
    const K5: isize = 5000;
    const K1: isize = 1000;

    let mut x: isize = 0;
    let mut y: isize = 0;
    let mut z: isize = 0;

    x = e / K10;
    let e = e % K10;
    y = e / K5;
    let e = e % K5;
    z = e / K1;
    let e = e % K1;

    let mut xi: isize = x;
    let mut yi: isize = y;
    let mut yj: isize = y;
    let mut zj: isize = z;

    for i in 0..x + 1 {

        if (xi + yj + zj) == n {
            break;
        }

        xi = x - i;
        yi = y + 2 * i;

        for j in 0..yi + 1 {

            yj = yi - j;
            zj = z + 5 * j;

            if (xi + yj + zj) == n {
                break;
            } else if (xi + yj + zj) > n {
                break;
            }
        }
    }

    if (xi + yj + zj) == n {
        println!("{} {} {}", xi, yj, zj);
    } else {
        println!("-1 -1 -1");
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
using namespace std;
int x[1000000], s[1000000], t[1000000], n, m, sum, u, v;
int main() {
	cin >> n >> m;
	for (int i = 1; i < n; i++) {
		cin >> s[i];
		x[i] = x[i - 1] + s[i];
	}
	u = 1;
	for (int i = 1; i <= m; i++) {
		v = u;
		cin >> t[i];
		u += t[i];
		sum += abs(x[u - 1] - x[v - 1]);
		sum %= 100000;
	}
	cout << sum % 100000 << endl;
	return 0;
}

Measured memory_bytes: 9744
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderBeginnerContest117First
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            //int a = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            double T = double.Parse(input[0]);
            double X = double.Parse(input[1]);
            // 文字列の入力
            //string s = Console.ReadLine();
            double ans = T / X;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11220
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,k;
int a[22];
int fact[1005],inv[1005];
int dp[22][1005];
int C(int nn,int mm){
	return fact[nn]*inv[mm]%mod*inv[nn-mm]%mod;
}
int calc(int hv,int nxt,int all){
//	cerr<<hv<<" "<<nxt<<" "<<all<<" "<<C(n-hv,nxt)*C(n-nxt,all-nxt)%mod<<endl;
	return C(n-hv,nxt)*C(n-nxt,all-nxt)%mod;
}
signed main(){
	fact[0]=1;
	for(int i=1;i<=1000;i++)fact[i]=fact[i-1]*i%mod;
	for(int i=0;i<=1000;i++)inv[i]=modpow(fact[i],mod-2,mod);
	cin>>n>>k;
	for(int i=1;i<=k;i++)cin>>a[i];
	dp[0][0]=1;
	for(int i=0;i<k;i++){
		for(int j=0;j<=n;j++){
			if(!dp[i][j])continue;
//			cerr<<i<<" "<<j<<" "<<dp[i][j]<<endl;
			for(int now=0;now<=a[i+1];now++){
//				cerr<<"add:"<<i+1<<" "<<j+now<<" "<<calc(j,now,a[i+1])*dp[i][j]<<endl;
				dp[i+1][j+now]+=calc(j,now,a[i+1])*dp[i][j]%mod;
				dp[i+1][j+now]%=mod;
			}
		}
	}
	cout<<dp[k][n]<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long LL;
typedef unsigned long long ULL;
const LL LINF = 0x3f3f3f3f3f3f3f3f; 
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1e9+7;
const ULL P = 131;
const int N = 2e5+7;


int a[N];
int dis[N*2],cnt;
bool st[N];
int main()
{
	LL n,k;
	cin>>n>>k;
	int tt;
	for(int i=1;i<=n;i++) cin>>tt,a[i]=tt;
	int x=1,t=0,next;
	while(!st[x]&&t<k){
		st[x] = 1;
		dis[++cnt] = x;
		x = a[x];
		t++;
	}
//	for(int i=1;i<=cnt;i++) cout<<dis[i]<<" ";
//	cout<<endl;
	if(t==k) cout<<x<<endl;
	else {
		int pos=1;
		for(int i=1;i<=cnt;i++){
			if(dis[i]==x) pos = i;
		}
		//cout<<pos<<endl; 
		int xun = cnt-pos+1;
		k=k-pos+1;
		k%=xun;
		cout<<dis[pos+k]<<endl;
	}
	return 0;
}

Measured memory_bytes: 5192
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
k,t=mii()
arr=sorted(limii(),reverse=True)

if t==1:
    print(k-1)
    exit()
if arr[0]-1 <=sum(arr[1:]):
    print(0)
else:
    print(arr[0]-sum(arr[1:])-1)


Measured memory_bytes: 65516
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long int ll;
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define deb(x) cout<<"Debug\t"<<#x<<"="<<x<<endl;
#define deb2(x,y) cout<<"Debug\t"<<#x<<"="<<x<<"\t"<<#y<<"="<<y<<endl;
#define deb3(x,y,z) cout<<"Debug\t"<<#x<<"="<<x<<"\t"<<#y<<"="<<y<<"\t"<<#z<<"="<<z<<endl;
#define deb4(x,y,z,w) cout<<"Debug\t"<<#x<<"="<<x<<"\t"<<#y<<"="<<y<<"\t"<<#z<<"="<<z<<"\t"<<#w<<"="<<w<<endl;
#define mod 1000000007
#define vi vector<ll>
#define pll pair<ll,ll>
#define vivi vector<vector<ll>> 
#define vipa vector<pair<ll,ll>>
#define pb push_back 
#define pf push_front
#define pll pair<ll,ll>


int main()
{
    ios;    
    ll t,i,n,m,j,x,y,pos,ans,sum,mini,k,diff;string s;
    cin>>n>>k;
    vi v(n);
    for(auto &z:v)
    cin>>z;
    sort(v.begin(),v.end());
    cout<<accumulate(v.begin(),v.begin()+k,0ll)<<endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int N;

vector<i64> A,B;

int main(){
  cin >> N;
  A.resize(N);
  B.resize(N);

  bool same = true;
  rep(i,0,N - 1){
    cin >> A[i] >> B[i];
    same &= A[i] == B[i];
  }
  if(same){
    cout << 0 << endl;
    return 0;
  }

  i64 res = 0;

  vector<P> vec;

  rep(i,0,N - 1){
    if(A[i] == B[i]){
      res += A[i];
    }
    else if(A[i] < B[i]){
      res += B[i];
    }
    else{
      vec.push_back({B[i],i});
    }
  }
  if(vec.size() > 1){
    sort(vec.rbegin(),vec.rend());
    for(int i = 0;i < vec.size() - 1;i++){
      res += vec[i].first;
    }
  }

  cout << res << endl;
 }

Measured memory_bytes: 896
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
     string S,T;
     cin>>S;
     cin>>T;
     ll NS=S.size();
     ll NT=T.size();
     vector<ll> AS(NS+1,0),BS(NS+1,0),AT(NT+1,0),BT(NT+1,0);
     REP(i,NS){
         AS[i+1]=AS[i];
         BS[i+1]=BS[i];
         if(S[i]=='A') AS[i+1]++;
         else BS[i+1]++;
     }

     REP(i,NT){
         AT[i+1]=AT[i];
         BT[i+1]=BT[i];
         if(T[i]=='A') AT[i+1]++;
         else BT[i+1]++;
     }

    ll q;
    cin>>q;
    vector<string> ans(q);
    REP(i,q){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll A_T=AT[d]-AT[c-1];
        ll B_T=BT[d]-BT[c-1];
        ll A_S=AS[b]-AS[a-1];
        ll B_S=BS[b]-BS[a-1];
        ll A=A_T-A_S;
        ll B=B_T-B_S;
        ll D=(d-c+1)-(b-a+1);
        if((2*D-A)%3==0&&(B+D)%3==0) ans[i]="YES";
        else ans[i]="NO";
    }

    REP(i,q) cout<<ans[i]<<endl;


}

Measured memory_bytes: 9784
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  string c;
  cin >> c;
  vector<int> R_pos;
  vector<int> W_pos;
  for(int i=0;i<N;++i){
    if(c.at(i)=='R') R_pos.push_back(i);
    else W_pos.push_back(i);
  }

  if(R_pos.size()==0 || W_pos.size()==0){
    cout << 0 << endl;
    return 0;
  }

  int R_ind=R_pos.size()-1;
  int W_ind=0;
  int ans=0;
  while(W_pos.at(W_ind)<R_pos.at(R_ind)){
    --R_ind;
    ++W_ind;
    ++ans;
    if(R_ind<0 || W_ind>=W_pos.size()) break;
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4688
#include<stdio.h>

int main(){
  int i,j,k,min,n,x,a,b;
  int D[100],F[100],G[100],M[100][100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&k);
      if(k==-1){
        M[i][j]=1000000;
      }
      else{
        M[i][j]=k;
      }
    }
  }
  for(i=0;i<n;i++){
    D[i]=1000000;
    F[i]=1000000;
    G[i]=1;
  }
  D[0]=0;
  while(1){
    min=1000000;
    for(i=0;i<n;i++){
      if(G[i]!=0 && D[i]<min){
        min=D[i];
        x=i;
      }
    }
    if(min==1000000){
      break;
    }
    G[x]=0;
    for(i=0;i<n;i++){
      b=M[x][i];
      if(b!=-1){
        if(G[i]!=0 && M[x][i]<D[i]){
          F[i]=x;
          D[i]=M[x][i];
        }
      }
    }
  }
  for(i=0;i<n;i++){
    a+=D[i];
  }
  printf("%d\n",a);
}



Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const int vx[]={1,0,-1,0}, vy[]={0,1,0,-1};
const ll LINF=1e18;
const ld PI=abs(acos(-1));

int li[100010];

int main(){
	int n; cin >> n; int a;
	REP(i,0,n) cin >> a, li[a]++;
	
	REP(i, 1, n + 1) if(li[i] == n and i * 2 <= n){cout << "Yes" << endl; return 0;}
	REP(i, 1, n) if(li[i] and li[i + 1] and li[i] < i + 1 and 2 * (i + 1 - li[i]) <= li[i + 1]){cout << "Yes" << endl; return 0;}
	if(li[n - 1] == n){cout << "Yes" << endl; return 0;}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 640
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  int N=s.length();
  string sfw=s.substr(0,(N-1)/2);
  string sbk=s.substr((N+1)/2,(N-1)/2);

  
  string a=s;
  string b=sfw;
  string c=sbk;
  reverse(s.begin(),s.end());
  reverse(sfw.begin(),sfw.end());
  reverse(sbk.begin(),sbk.end());

  if(s==a&&sfw==b&&sbk==c)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

}


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

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    int temp = 0;
    temp = x;
    x = y;
    y = temp;
    temp = x;
    x = z;
    z = temp;
    cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 100;
char s[maxn][maxn + 1];
int dp[maxn][maxn + 1];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < N; i += 1) cin >> s[i];
    for(int i = 0; i < N; i += 1)
        for(int j = 0; j < M; j += 1)
            if(not i and not j) dp[0][0] = s[0][0] == '#';
            else{
                dp[i][j] = N + M;
                if(i) dp[i][j] = dp[i - 1][j] + (s[i - 1][j] == '.' and s[i][j] == '#');
                if(j) dp[i][j] = min(dp[i][j], dp[i][j - 1] + (s[i][j - 1] == '.' and s[i][j] == '#'));
            }
    cout << dp[N - 1][M - 1];
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long int
#define fast  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            int t; cin>>t; while(t--)
const int mod = 1000000007;
bool comp(pair<ll,ll>& a, pair<ll,ll>& b)
{
    if(a.second == b.second)
    return a.first > b.first;
    else
    return b.second < a.second;
}
int main()
{
    fast
    int n;
    cin>>n;
    int ac=0,wa=0,tle=0,re=0;
    while(n--)
    {
        string s;
        cin>>s;
        if(s=="AC") ac++;
        else if(s=="WA") wa++;
        else if(s=="TLE" ) tle++;
        else if(s=="RE") re++;

    }

    cout<<"AC "<<"x "<<ac<<endl;
    cout<<"WA "<<"x "<<wa<<endl;
    cout<<"TLE "<<"x "<<tle<<endl;
    cout<<"RE "<<"x "<<re<<endl;

    return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

//クラス名は必ずMainにする必要があります。



public class Main {
    public static void main(String args[] ) throws Exception {
		Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());

        int num = 0;
        for(int i = 0; i < n; i++){
            int res = Integer.parseInt(sc.next());
            if(i % 2 == 0){
                if(res % 2 == 1){
                    num++;
                }
                
            }

        }
        System.out.println(num);
        
    }
    
}

Measured memory_bytes: 35532
#include <bits/stdc++.h>
#define FOR(i,s,e) for(int i=(s);i<(e);i++)
#define REP(i,n) FOR(i,0,n)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int D, N;
    cin >> D >> N;
    if(N == 100) N=101;
    REP(i, D) N *= 100;
    cout << N << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(void){
  string S, front="", back="";
  int Q, D, F;
  char C;
  cin >> S;
  cin >> Q;
  bool rev = false;
  
  for(int i=0; i<Q; i++){
    cin >> D;
    if(D==1){
      rev = !rev;
    }else if(D==2){
      cin >> F >> C;
      if(rev){
        if(F==1){
          back = back+C;
        }else if(F==2){
          front = front+C;
        }
      }else if(!rev){
        if(F==1){
          front = front+C;
        }else if(F==2){
          back = back+C;
        }
      }
    }
      
  }
  reverse(front.begin(),front.end());
  S = front + S + back;
  if(rev)reverse(S.begin(), S.end());
 
  cout << S;
  return 0;
}

Measured memory_bytes: 1584
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
//#define N (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

const int inf = 1e9;

ll dp[1000010][4];

char s[305][305];

int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>s[i][j];
        }
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        int a = 0;
        int b = i;
        bool flag = true;
        for(int j=0;j<n;j++){
            for(int k=j;k<n;k++){
                int i1 = (j+a)%n;
                int j1 = (k+b)%n;
                int i2 = (k+a)%n;
                int j2 = (j+b)%n;
                flag = flag&(s[i1][j1]==s[i2][j2]);
            }
        }
        if(flag)ans+=n;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3724
/*	Don’t Quit
	
	When things go wrong as they sometimes will;
		When the road you’re trudging seems all uphill;
			When the funds are low, and the debts are high;
				And you want to smile, but you have to sigh;
					When care is pressing you down a bit
						Rest if you must, but don’t you quit.
*/
#pragma gcc optimize ("unroll-loop")
#pragma gcc optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int a[N];
int pre[N];
int32_t main()
{
	IOS;
	int n,k;
	cin>>n>>k;
	vector<int>pos,neg;

	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==0)
			k--;
		else if(a[i]<0)
		{
			neg.pb(abs(a[i]));
		}
		else
		{
			pos.pb(a[i]);
		}
		
	}
	if(k==0)
	{
		cout<<"0"<<endl;
		return 0;
	}
	if(neg.size()>0)
	{
		reverse(all(neg));
	}
	if(neg.size()==0)
	{
		cout<<pos[k-1]<<endl;
		return 0;
	}
	else if(pos.size()==0)
	{
		cout<<neg[k-1]<<endl;
		return 0;
	}
	int mn=1e10;
	for(int i=1;i<=pos.size();i++)
	{
		int z=k-i;
		if(z>0&&neg.size()>=z)
		{
			mn=min(mn,2*pos[i-1]+neg[z-1]);
		}

	}
	for(int i=1;i<=neg.size();i++)
	{
		int z=k-i;
		if(z>0&&pos.size()>=z)
		{
			mn=min(mn,2*neg[i-1]+pos[z-1]);
		}
		
	}
	cout<<mn<<endl;



}

Measured memory_bytes: 3704
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  long long int n;
  cin >> n;
  long long int ans = 1000000000000, k;
  for (long long int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      k = n / i + i - 2;
      if (k < ans) {
        ans = k;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static int D;
    static int N;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        D = sc.nextInt();
        N = sc.nextInt();
        System.out.println( solve() );
    }

    private static int solve() {
        if( D == 0 ) {
            if( N == 100 ) return 101;
            else return N;
        }
        if( D == 1 ) {
            if( N == 100 ) return 100 * 101;
            else return 100 * N;
        }
        if( D == 2 ) {
            if( N == 100 ) return 10000 * 101;
            else return 10000 * N;
        }
        return -1;
    }

    static class FastScanner {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

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

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}



Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair <int, int>
#define iiii pair <int, pii >
#define mp make_pair
#define INF 1000000000
#define rep(i, x) for(int (i) = 0; (i) < (x); (i)++)
inline int getint() {
  int x = 0, p = 1; char c = getchar();
  while (c <= 32) c = getchar();
  if (c == 45) p = -p, c = getchar();
  while (c > 32) x = x * 10 + c - 48, c = getchar();
  return x * p;
}
using namespace std;
const int mod = 1e9 + 7;
inline void reduce(int &x) { x += x >> 31 & mod; }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
//ruogu_alter
//
int main() {
  string s, t;
  cin >> s >> t;
  rep(i, s.size()) if (s[i] != t[i]) return !printf("No\n");
  printf("Yes\n");
  return 0;
}


Measured memory_bytes: 3720
#include<iostream>
#include<vector>
void stupid(){
    unsigned int N;
    std::vector<unsigned int>numDivisor;
    unsigned long long sum;
    std::cin>>N;
    numDivisor=std::vector<unsigned int>(N,1);
    for(int i=1;i<N;++i){
        for(int j=i;j<N;++j){
            if((j+1)%(i+1)==0){
                numDivisor[j]++;
            }
        }
    }
    sum=0;
    for(int i=0;i<N;++i){
        sum+=(i+1)*numDivisor[i];
    }
    std::cout<<sum;
}

void stupid2(){
    unsigned int N;
    std::vector<unsigned int>numDivisor;
    std::vector<unsigned int>squares;
    unsigned long long sum;
    std::cin>>N;
    int indexSquares;
    int numSquares;
    numDivisor=std::vector<unsigned int>(N,0);
    numDivisor[0]=1;
    for(int i=1;(i-1)*(i-1)<=N;++i){
        squares.push_back(i*i);
    }
    numSquares=squares.size();
    indexSquares=0;
    
    for(int i=1;i<N;++i){
        if(indexSquares<squares.size() && squares[indexSquares+1]==(i+1)){
            indexSquares++;
        }
        for(int j=0;j<=indexSquares;++j){
            if((i+1)%(j+1)==0){
                // std::cout<<i+1<<":"<<j+1<<std::endl;
                ++numDivisor[i];
            }
        }
        numDivisor[i]*=2;
        if(indexSquares<squares.size() && squares[indexSquares]==(i+1)){
            numDivisor[i]--;
        }
    }

    // for(int i=0;i<N;++i){
    //     std::cout<<i+1<<":"<<numDivisor[i]<<std::endl;
    // }

    sum=0;
    for(int i=0;i<N;++i){
        sum+=(i+1)*numDivisor[i];
    }
    std::cout<<sum;
}

void correct(){
    unsigned int N;
    unsigned long long sum;
    std::cin>>N;
    sum=0;
    for(int i=1;i<=N;++i){
        unsigned long long div=(int)(N/i);
        sum+=i*(div)*(div+1)/2;
    }
    std::cout<<sum;
}

int main(){
    // stupid();
    // stupid2();
    correct();
    return 0;
}

Measured memory_bytes: 3624
// Jump, and you will find out how to unfold your wings as you fall.

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=2e5+10,mod=1e9+7;
const ll inf=1e18;

vector<int>v[maxn],vert[maxn],vec;
int ans[maxn],par[maxn],mx[maxn],delta[maxn],mark[maxn],C;

void dfs(int u,int pr=0){
    par[u]=pr; mx[u]=max(mx[pr],pr);
    for(int y:v[u]){
	if(y!=pr)
	    dfs(y,u);
    }
}
int calc(int u,int val){
    if(u>val || mark[u]) return 0;
    int ans=1;
    for(int y:v[u]){
	if(y!=par[u])
	    ans+=calc(y,val);
    }
    return ans;
}
void tovec(int u,vector<int>&vv){
    if(mark[u]) return;
    mark[u]=C; vv.PB(u);
    for(int y:v[u]){
	if(y!=par[u])
	    tovec(y,vv);
    }
}
void write(int u,int mrk,int val){
    if(mark[u]!=mrk) return;
    ans[u]=val;
    for(int y:v[u]){
	if(y!=par[u])
	    write(y,mrk,val);
    }
}
void prep(int u){
    vec.PB(u);
    mark[u]=C;
    delta[u]=1;
    for(int y:v[u]){
	if(y!=par[u] && mark[y]==0){
	    delta[y]=calc(y,mx[u]);
	    delta[u]+=delta[y];
	    tovec(y,vert[y]);
	}
    }
    for(int y:v[u]){
	if(y!=par[u] && mark[y]==C){
	    delta[y]=delta[u]-delta[y]+sz(vert[y]);
	}
    }
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    for(int i=1;i<n;i++){
	int a,b;cin>>a>>b;
	v[a].PB(b);
	v[b].PB(a);
    }
    dfs(1);
    int pt=n;
    while(pt>1){
	if(mark[pt]==0)
	    ++C,prep(pt);
	--pt;
    }
    while(sz(vec)){
	int u=vec.back();
	vec.pop_back();
	ans[u]=delta[u]+ans[par[u]];
	for(int y:v[u]){
	    if(y!=par[u])
		write(y,mark[u],delta[y]+ans[par[u]]);
	}
    }
    for(int i=2;i<=n;i++){
	cout<<ans[i]<<" ";
    }
    return cout<<endl,0;
}
// Deathly mistakes:
//  * Read the problem curfully.
//  * Check maxn.
//  * Overflows.


Measured memory_bytes: 30712
n, l = map(int, input().split())

#最後の味を求める(最初の味はL)
R = l + n - 1

#食べるリンゴを決める
if R <= 0:
  eat = R
elif l >= 0:
  eat = l
else:
  eat = 0

#総和を求めて食べたリンゴを引く
answer = round((R+l) * (R-l+1) / 2 - eat)
print(answer)


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

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

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

	int N; cin >> N;
	double t[200], v[200];
	for (int i = 0;i < N;i++){
		cin >> t[i];
	}
	for (int i = 0;i < N;i++){
		cin >> v[i];
	}

	double sum[200];

	sum[0] = 0;
	for (int i = 1;i <= N;i++){
		sum[i] = sum[i-1]+t[i-1];
	}
	v[N] = 0;

	double dist = 0;
	double speed = 0;
	int idx = 0;

	double d = 0.25;

	for (double time = 0;time < sum[N];time += d){
		if(time >= sum[idx+1]) idx++;
		bool can_keep = true;
		for (int j = idx+1;j <= N;j++){
			if(speed-v[j] > sum[j]-(time+d)){ can_keep = false; break;}
		}
		if(!can_keep){ dist += speed*d - (d*d)/2; speed -= d; continue;}
		bool can_acc = true;
		if(speed+d > v[idx]){ dist += speed*d; continue;}
		for (int j = idx+1;j <= N;j++){
			if(speed+d-v[j] > sum[j]-(time+d)){ can_acc = false; break;}
		}
		if(!can_acc){dist += speed; continue;}
		dist += speed*d+(d*d)/2; speed += d;
	}

	printf("%.10f\n", dist);

	return 0;

}


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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

vector<int> graf[100];
map<pair<int, int>, int> grana;
vector<int> svaki[100][100];
bool veza[100];
pair<int, int> niz[30];
bool mark[60];
int n;
ll res = 0;

ll stepen(ll a, int k)
{
    if(k == 0) return 1;
    ll rez = stepen(a, k/2);
    rez *= rez;
    if(k % 2 == 1) rez *= a;
    return rez;
}

bool dfs(int x, int goal, int pret, int ind1, int ind2)
{
    //if(!prvi) cout << x << " * ";
    mark[x] = true;
    if(x == goal)
    {
        mark[x] = false;
        if(pret != 0 && pret != x) svaki[ind1][ind2].pb(grana[mp(min(x, pret), max(x, pret))]);
        return true;
    }
    for(int i = 0; i < graf[x].size(); i++)
    {
        int cvor = graf[x][i];
        if(!mark[cvor])
            if(dfs(cvor, goal, x, ind1, ind2))
            {
                mark[x] = false;
                if(pret != 0 && pret != x) svaki[ind1][ind2].pb(grana[mp(min(x, pret), max(x, pret))]);
                return true;
            }
    }
    mark[x] = false;
    return false;
}


void perm(int ind, int l, int cnt, string s, bool add)
{
    if(ind == l)
    {
        if(cnt != 0) {cout << "kurac"; return;}
        for(int i = 0; i < l; i++)
            if(s[i] == '1')
            {
                int a = min(niz[i].fi,niz[i].se);
                int b = max(niz[i].fi,niz[i].se);
                for(int i = 0; i < svaki[a][b].size(); i++) veza[svaki[a][b][i]] = true;
            }
        int broj = 0;
        for(int i = 1; i <= n; i++) if(veza[i]) broj++;
        //int broj = veza.size();
        //cout << s << " " << broj << "\n";
        broj = n - 1 - broj;
        ll komb = stepen(2, broj);

        if(add) res += komb;
        else res -= komb;
        memset(mark, false, sizeof(mark));
        memset(veza, false, sizeof(veza));
        return;
    }

    if(l - cnt > ind) perm(ind + 1, l, cnt, s + "0", add);
    if(cnt > 0) perm(ind + 1, l, cnt-1, s + "1", add);
}

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


    cin >> n;
    for(int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        graf[a].pb(b);
        graf[b].pb(a);
        grana[mp(min(a,b), max(a,b))] = i+1;
    }
    int m;
    cin >> m;
    for(int i = 0; i < m; i++)
        cin >> niz[i].fi >> niz[i].se;

    for(int i = 0; i < m; i++)
    {
        int a = min(niz[i].fi,niz[i].se);
        int b = max(niz[i].fi,niz[i].se);
        dfs(niz[i].fi, niz[i].se, 0, a, b);
    }

    for(int i = 1; i <= m; i++)
        perm(0, m, i, "", i % 2);

    //cout << res;
    cout << stepen(2, n-1) - res;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int ans=10000;
	string s;
	cin >> s;
	for(int i=0; i<s.size()-2; i++){
		ans=min(ans, abs(753-100*(s[i]-'0')-10*(s[i+1]-'0')-(s[i+2]-'0')));
	}
	cout << ans << endl;

	return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) { cin >> l[i]; }

  auto longest = max_element(l.begin(), l.end());
  if (accumulate(l.begin(), l.end(), 0) - *longest > *longest) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    ll n, m, d;
    cin >> n >> m >> d;
    if (d != 0LL)
        printf("%.10lf\n", (double)(2LL * (n - d) * (m - 1LL)) / (double)(n * n));
    else 
        printf("%.10lf\n", (double)((m - 1)) / (double)(n));
}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


int main(){
  int n;
  cin >> n;
  vector<int> a(n, 0);
  rep(i, n) {
    cin >> a[i];
  }
  int swapCount = 0;
  rep(i,n) {
    int minj = i;
    rep2(j,i,n) {
      if (a[j] < a[minj]) {
        minj = j;
      }
    }
    if (i != minj) {
      swap(a[i], a[minj]);
      ++swapCount;
    }
  }
  rep(i,n) {
    if (i > 0) cout << " ";
    cout << a[i];
  }
  cout << endl << swapCount << endl;
  return 0;
}



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

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

typedef long long ll;
using namespace std;

ll lcm(ll x, ll y) { return x / __gcd(x, y) * y; }

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

  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll high, low, ng;
  ng = 0ll;

  high = B >= C ? B / C : 0;
  low = A >= C ? (A + C - 1) / C : 0;
  // cout << high << ":" << low << "/" << ng << endl;
  if (high > 0) {
    if (low > 0) {
      ng += high - low + 1;
    } else {
      ng += high;
    }
  }

  high = B >= D ? B / D : 0;
  low = A >= D ? (A + D - 1) / D : 0;
  // cout << high << ":" << low << "/" << ng << endl;
  if (high > 0) {
    if (low > 0) {
      ng += high - low + 1;
    } else {
      ng += high;
    }
  }

  ll l = lcm(C, D);
  high = B >= l ? B / l : 0;
  low = A >= l ? (A + l - 1) / l : 0;
  // cout << high << ":" << low << "/" << ng << endl;
  if (high > 0) {
    if (low > 0) {
      ng -= (high - low + 1);
    } else {
      ng -= high;
    }
  }

  cout << B - A + 1 - ng << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main(){
	string s,t;
  cin >> s >> t;
  int ccc=0;
  for(int i=0; i<s.size(); i++){
    if(s[i]!=t[i])++ccc;
  }
  cout << ccc;

return 0;
}

Measured memory_bytes: 3512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#define inf 0x3f3f3f3f
#define LL long long

using namespace std;

int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)==2)
    {
        string s;
        cin>>s;
        int flag=1;
        for(int i=0;i<n;i++)
        {
            if(s[i]<'0'||s[i]>'9')
            {
                flag=0;
            }
        }
        if(s[n]!='-') flag=0;
        for(int i=n+1;i<n+m+1;i++)
        {
            if(s[i]<'0'||s[i]>'9')
            {
                flag=0;
            }
        }
        if(flag) {printf("Yes\n");}
        else {printf("No\n");}
    }
    return 0;
}


Measured memory_bytes: 256