akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	lint n,m; scanf("%lld%lld",&n,&m);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]);

	sort(a.begin(),a.end());

	vector<lint> sum(n+1);
	rep(i,n) sum[i+1]=sum[i]+a[i];

	lint lo=0,hi=2e5+1;
	while(hi-lo>1){
		lint mi=(lo+hi)/2;
		lint tmp=0;
		rep(i,n){
			tmp+=a.end()-lower_bound(a.begin(),a.end(),mi-a[i]);
		}
		if(tmp>=m) lo=mi;
		else       hi=mi;
	}

	lint ans=0;
	rep(i,n){
		int idx=lower_bound(a.begin(),a.end(),hi-a[i])-a.begin();
		m-=n-idx;
		ans+=(n-idx)*a[i]+(sum[n]-sum[idx]);
	}
	ans+=m*lo;

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007

int main() {
	int N;
	cin >> N;
	string S, T;
	cin >> S >> T;
	for (int i = 0;i < N;i++) {
		cout << S[i] << T[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>
#include <queue>

typedef long long ll;

using namespace std;

int main(){
    cout.precision(15);
    int n, k;
    cin >> n >> k;
    double a[n];
    for(int i = 0; i < n; i++){
        double x;
        cin >> x;
        a[i] = (1.0 + x) / 2.0; 
    }
    double b[n];
    b[0] = a[0];
    for(int i = 1; i < n; i++){
        b[i] = b[i - 1] + a[i];
    }

    vector<double> c;
    c.push_back(b[k - 1]);
    for(int i = 0; i + k < n; i++){
        c.push_back(b[i + k] - b[i]);
    }

    sort(c.begin(), c.end());

    cout << c[c.size() - 1] << endl;
}


Measured memory_bytes: 5492
#include <iostream>
using namespace std;
int N, A[100009]; long long sum;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	bool ok = true;
	if (sum % (1LL * N * (N + 1) / 2) != 0) {
		ok = false;
	}
	else {
		sum /= 1LL * N * (N + 1) / 2;
		long long delta = A[0] - sum;
		A[0] = 0;
		for (int i = 1; i < N; i++) {
			A[i] = -(A[i] - 1LL * (i + 1) * sum - delta);
		}
		for (int i = 1; i < N; i++) {
			if (A[i - 1] > A[i] || A[i] % N != 0 || A[i] > sum * N) {
				ok = false;
			}
		}
	}
	cout << (ok ? "YES\n" : "NO\n");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include <utility>
#include <vector>
#include <tuple>
#include <numeric>
using namespace std;

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

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

int main(int argc, char* argv[]){
	int n;
	scanf("%d", &n);

	int LCM = lcm(360, n);

	printf("%d\n", LCM/n);


	return 0;
}


Measured memory_bytes: 3804
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>

#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e10

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
typedef std::pair<ll, ll> P;

using namespace std;

bool pairCompare(const P& f, const P& s){
    return f.first < s.first;
}

int main()
{
    string s;
    ll k;
    cin >> s >> k;
    ll n = 5000*pow(10, 12);
    int ans;
    rep(i, s.size()){
        int p = s[i] - '0';
        if(k <= pow(p, n)){
            ans = p;
            break;
        }else{
            k -= pow(p, n);
        }
    }
    cout << ans;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using ld=long double;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

ll f[1010101], invf[1010101];//iの階乗、iの階乗の逆元
ll inv(ll x) {//逆元計算 =>（inf-2)乗
    ll res = 1;
    ll k = inf - 2;
    ll y = x;
    while (k) {     //繰り返しニ乗法
        if (k & 1) res = (res * y) % inf; //最右が1ならyをかける
        y = (y * y) % inf;  //yを二乗
        k >>= 1;  //右に1シフト
    }
    return res;
}
void init() { //階乗計算O(101010)
    f[0] = 1;
    rep(i, 1, 1010101) f[i] = (f[i - 1] * i) % inf;
    rep(i, 0, 1010101) invf[i] = inv(f[i]);
}
ll comb(int n, int k) {
    if( k < 0 || k > n )return 0;
    ll a = f[n]; // = n!
    ll b = invf[n-k]; // = /(n-k)!
    ll c = invf[k]; // = /k!

    ll bc = (b * c) % inf;

    return (a * bc) % inf;
}


int main(){cout<<fixed<<setprecision(20);
		   ll s;
           cin>>s;
           init();
           ll ans=0;
           ll p=s/3;
           rep(i,1,p+1){
             ll c=s-i*3;
             /// i H c
             ans+=comb(c+i-1,c);
               ans%=inf;
           }
           cout<<ans<<endl;
}

Measured memory_bytes: 19420
N=int(input())
a=input().split(" ")
b=[]
for p in range(0,N):
    b.append(int(a[p]))
if N==1:
    print(0)
else:
    c=[]
    if b[0]-b[1]>=0:
        c.append(1)
    else:
        c.append(0)
    for q in range(1,N-1):
        if b[q]-b[q+1]>=0:
            c.append(c[q-1]+1)
        else:
            c.append(0)
    print(max(c))

Measured memory_bytes: 18192
using System;

namespace ABC164B
{
    class Program
    {
        static void Main(string[] args)
        {
            var target = Console.ReadLine().Split(' ');
            int A = int.Parse(target[0]);
            int B = int.Parse(target[1]);
            int C = int.Parse(target[2]);
            int D = int.Parse(target[3]);
            while(A > 0){
                C -= B;
                if(C <= 0){
                    Console.WriteLine("Yes"); return;
                }
                A -= D;
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 27476
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int a[111];

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N) scanf("%d", &a[i + 1]);
    
    // 2. 条件を満たすマスは？
    int ans = 0;
    repx(i, 1, N + 1) if((i & 1) && (a[i] & 1)) ans++;
    
    // 3. 出力.
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 3800
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int64)
mod = 10 ** 9 + 7

ans = 0
dmax = 61
for d in range(dmax):
    B = np.right_shift(A, d)
    one = np.count_nonzero(np.bitwise_and(B, 1))
    zero = N - one
    add = pow(2, d, mod) * one * zero
    ans = (ans + add) % mod

print(ans)


Measured memory_bytes: 62756
n = int(input())
prev_dp=[0]*3
for _ in range(n):
    arr=[]
    a,b,c = list(map(int,input().split()))
    arr.append((a,b,c))
    curr_dp = [0]*3
    for i in range(3):
        for j in range(3):
            if i!=j:
                #print(i,j)
                curr_dp[j] = max(curr_dp[j],prev_dp[i] + arr[0][j])
    prev_dp = curr_dp
print(max(prev_dp[0],prev_dp[1],prev_dp[2]))

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

int main(){
	int H, W, D, Q;
	cin >> H >> W >> D;
	int A[H][W];
	map<int, P> M;
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			cin >> A[i][j];
			M[A[i][j]].first = i, M[A[i][j]].second = j;
		}
	}
	cin >> Q;
	int L[Q], R[Q];
	ll r[H*W+1];
	for(int i=1; i<=H*W; i++){
		if(i <= D){
			r[i] = 0;
		}else{
			r[i] = r[i-D] + abs(M[i].first - M[i-D].first) + abs(M[i].second - M[i-D].second);
		}
	}
	int ans[Q];
	for(int i=0; i<Q; i++){
		int L, R;
		cin >> L >> R;
		ans[i] = r[R] - r[L];
	}
	for(int i=0; i<Q; i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 8192
void main()
{
    string s = readln.chomp;

    long cnt;
    long times;
    foreach (i, c; s)
    {
        if (c == 'W')
        {
            times += i - cnt;
            ++cnt;
        }
    }

    times.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 764
import sys
sys.setrecursionlimit(10**7)
input=sys.stdin.readline
mod=10**9+7
n=int(input())
A=[tuple(map(int,input().split())) for _ in range(n)]
DP=[-1]*(1<<n)
DP[0]=1

def dfs(s,m):
    if DP[s]!=-1:
        return DP[s]
    tmp=0
    for i in range(n):
        if (s>>i)&1 and A[m][i]:
            tmp+=dfs(s-(1<<i),m-1)
    DP[s]=tmp%mod
    return DP[s]

print(dfs((1<<n)-1,n-1))

Measured memory_bytes: 63836
import heapq
N, M = map(int, input().split())
A = [-int(i) for i in input().split()]
heapq.heapify(A)
for i in range(M):
    a = -heapq.heappop(A) // 2
    heapq.heappush(A, -a)
print(-sum(A))

Measured memory_bytes: 72088
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pairs;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}


int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b>c){
        puts("No");
        return 0;
    }
    ll move = (c-a-b);
    if(4*a*b<(move*move))puts("Yes");
    else puts("No");
    return 0;
}
 



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

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	vector<long> a, b;

	cin >> N;

	for (int i = 0; i < N; i++) {
		int ai;
		cin >> ai;
		a.push_back(ai);
	}

	for (int i = 0; i < N; i++) {
		int bi;
		cin >> bi;
		b.push_back(bi);
	}

	int ans = 0;
	for (int k = 30; k >= 0; k--) {
		long T = 1 << k;
		long cnt = 0;

		sort(b.begin(), b.end());

		for (int i = 0; i < N; i++) {
			long p = a[i];
			int x = lower_bound(b.begin(), b.end(), 2 * T - p) - lower_bound(b.begin(), b.end(), T - p);
			int y = lower_bound(b.begin(), b.end(), 4 * T - p) - lower_bound(b.begin(), b.end(), 3 * T - p);
			cnt += x + y;
		}

		if (cnt & 1) ans |= T;

		for (int i = 0; i < N; i++) {
			a[i] &= ~T;
			b[i] &= ~T;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
const int Max_N=1e5,Max_M=2*1e5,Max_C=1e6;
int N,M,cnt=0,Num=0,lin[Max_N*5+10]={},dis[Max_N*5+10]={},Vis[Max_N*5+10]={};
map<int,map<int,int> > vis;
struct kk{
	int Id,Next,v;
} e[Max_M*6+10]={};
priority_queue< pair<int,int> > Q;
inline void insert(int x,int y,int z){
	e[++Num].Next=lin[x]; lin[x]=Num; e[Num].Id=y; e[Num].v=z;
}
inline void Dij(){
	memset(dis,10,sizeof(dis));
	Q.push(make_pair(0,1)); dis[1]=0;
	for(;Q.size();){
		int x=Q.top().second; Q.pop();
		if(Vis[x]) continue; ++Vis[x];
		for(int i=lin[x];i;i=e[i].Next)
		 if(dis[x]+e[i].v<dis[e[i].Id]){
		 	dis[e[i].Id]=dis[x]+e[i].v;
		 	Q.push(make_pair(-dis[e[i].Id],e[i].Id));
		 }
	}
	if(dis[N]==dis[0]) puts("-1");
	else printf("%d\n",dis[N]/2);
}
int main(){
	scanf("%d%d",&N,&M);
	for(int i=1;i<=M;i++){
		int p,q,c,x=0,y=0; scanf("%d%d%d",&p,&q,&c);
		if(!vis[p][c]) vis[p][c]=++cnt; x=vis[p][c];
		if(!vis[q][c]) vis[q][c]=++cnt; y=vis[q][c];
		insert(p,N+x,1); insert(N+x,N+y,0); insert(N+y,q,1);
		insert(N+x,p,1); insert(N+y,N+x,0); insert(q,N+y,1);
	}
	Dij();
	return 0;
}

Measured memory_bytes: 49404
def validate(plan):
    pre_time = 0
    pre_x, pre_y = 0, 0
    available = True
    for t, x, y in plan:
        elapsed = t - pre_time
        dist = abs(x-pre_x) + abs(y-pre_y) 
        if elapsed < dist or elapsed%2 != dist%2:
            available = False
            break
    return available

def solve():
    N = int(input())
    plan = []
    for i in range(N):
        plan.append(map(int, input().split()))
    available = validate(plan)
    if available:
        print('Yes')
    else:
        print('No')

solve()

Measured memory_bytes: 48780
import sys
sys.setrecursionlimit(10**6)


def main(input, print):
    n = int(input())
    cnt = 0
    ans = 'No'
    for i in range(n):
        a, b = map(int, input().split())
        if a == b:
            cnt += 1
        else:
            cnt = 0
        if cnt >= 3:
            ans = 'Yes'
    print(ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 61852
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001 
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl> 
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define set(x,k) memset(x,k,sizeof(x))
#define cy cout << "YES" << endl
#define  cn cout << "NO" << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (auto i=2; i<MAXN; i++) 
  		spf[i] = i; 
  	for (auto i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (auto i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (auto j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
	return;
} 

vl getFactorization(ll x) 
{ 
    vl ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 


void check()
{
	ll x;
	cin >> x;
	if(x>=30) 
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;
    return ;
}

int32_t main()
{
    fastio;
    ll t = 1;
    // cin >> t;
    while(t--)
        check();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

    auto la = t1 * a1 + t2 * a2;
    auto lb = t1 * b1 + t2 * b2;

    if (la == lb) {
        cout << "infinity" << endl;
        return 0;
    }

    if (la < lb) {
        swap(a1, b1);
        swap(a2, b2);
        swap(la, lb);
    }

    if (a1 > b1) {
        cout << 0 << endl;
        return 0;
    }

    int64_t n = t1 * (b1 - a1) / (la - lb);
    while (n * (la - lb) < t1 * (b1 - a1)) {
        ++n;
    }

    if (n * (la - lb) == t1 * (b1 - a1)) {
        cout << 2 * n << endl;
    } else {
        cout << 2 * n - 1 << endl;
    }


}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
l=[0]*(max(a)+1)
l2=[0]*(max(a)+1)
for i in range(n):
     l[a[i]]+=1
for i in range(len(l)):
    l2[i]=max(0,(l[i]*(l[i]-1))//2)
sum=sum(l2)
for k in range(n):
    ans1=sum-l2[a[k]]
    ans2=max(0,((l[a[k]]-1)*(l[a[k]]-2))//2)
    print(ans1+ans2)


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

using namespace std;

const ll sz=1e5+5;

ll n,ar[sz][4],cache[sz][4];

ll dp(ll day,ll pichle_din_kaam)
{
    if(day==0)
        return 0;

    ll &ans=cache[day][pichle_din_kaam];
    if(ans!=-1)
    	return ans;

    for(int i=1;i<=3;i++)
    {
        if(i==pichle_din_kaam)
            continue;
        ans=max(ans,ar[day][i]+dp(day-1,i));
    }
	
    return ans;
}

int main()
{
    cin>>n;
    memset(cache,-1,sizeof cache);
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=3;j++)
        {
            cin>>ar[i][j];
        }
    }

    cout<<dp(n,0);
    
    // for(ll i=1;i<=n;i++)
    // {
    //     for(ll j=1;j<=3;j++)
    //     {
    //         cout<<cache[i][j]<<"  ";
    //     }
    //     cout<<endl;
    // }
}

Measured memory_bytes: 14336
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, sum = 0;
    cin >> n;
    
    vector<int> v(n+1, 0);
    for (int i = 1; i <= n; ++i) {
        cin >> v[i], sum += abs(v[i] - v[i-1]);
    }
    sum += abs(v[n]);
    
    for (int i = 1; i <= n-1; ++i) {
        cout << sum - abs(v[i+1] - v[i]) - abs(v[i] - v[i-1]) + abs(v[i+1] - v[i-1]) << "\n";
    }
    cout << sum - abs(v[n]) - abs(v[n] - v[n-1]) + abs(v[n-1]) << "\n";
    
    return 0;
}

Measured memory_bytes: 2048
#include <cstdio>
#include <algorithm>

using namespace std;

char s[1000001];

int main()
{
	scanf("%s", s);
	
	int ans = 0;
	
	for (int i = 0; s[i];){
		int Jcount, Ocount, Icount;
		for (Jcount = 0; s[i] == 'J'; Jcount++) i++;
		for (Ocount = 0; s[i] == 'O'; Ocount++) i++;
		for (Icount = 0; s[i] == 'I'; Icount++) i++;
		
		if (Jcount >= Ocount && Ocount <= Icount) ans = max(ans, Ocount);
	}
	
	printf("%d\n", ans);
	
	return (0);
}

Measured memory_bytes: 1944
n = input()
s = ""
if n[0] == "1":
	s += "9"
else:
	s += "1"

if n[1] == "1":
	s += "9"
else:
	s += "1"

if n[2] == "1":
	s += "9"
else:
	s += "1"

print (s)

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

using namespace std;

#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	all(c)			(c).begin(),(c).end()
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())
#define	endl			'\n'

typedef long long		ll;
typedef unsigned long long	ull;
typedef unsigned char	 	byte;
typedef vector<int>		vi;
typedef pair<int, int>		pii;
typedef pair<ll, ll>		pll;
typedef vector<pii>		vpii;

const int MX = 405;

ll dp[MX][MX];

int main(int argc, char *argv[])
{
#ifdef	HTRINH_UNIT_TEST
	freopen(argv[1],"r",stdin);
	ifstream cin(argv[1]);
#endif
#if 0
	ofstream cout(argv[2]);
#endif
	ios :: sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	ll a[n];
	FOR(i,0,n) cin >> a[i];
	ll sum[n];
	sum[0] = a[0];
	FOR(i,1,n) sum[i] = sum[i-1]+a[i];
	FOR(d,2,n+1) FOR(l,0,n) {
		int r = l+d-1;
		if (r >= n) break;
		ll tot = 0;
		if (l-1 >= 0) tot = sum[r]-sum[l-1];
		else tot = sum[r];
		ll best = 1LL<<60;
		FOR(k,l,r) best = min(best,dp[l][k]+dp[k+1][r]);
		dp[l][r] = best+tot;
	}
	cout << dp[0][n-1] << endl;
	return 0;
}


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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

struct pt {
  double x, y;
  pt operator + (pt p) { return {x+p.x, y+p.y}; }
  pt operator - (pt p) { return {x-p.x, y-p.y}; }
  pt operator * (pt p) { return {x*p.x-y*p.y, x*p.y+y*p.x}; }
  pt operator * (double d) { return {x*d, y*d}; }
  pt operator / (double d) { return {x/d, y/d}; } /// only for floating point
  bool operator == (pt b) { return x == b.x && y == b.y; }
  bool operator != (pt b) { return !(*this == b); }
  bool operator < (const pt &o) const { return y < o.y || (y == o.y && x < o.x); }
  bool operator > (const pt &o) const { return y > o.y || (y == o.y && x > o.x); }
};

double dot(pt a, pt b) { return a.x*b.x + a.y*b.y; }
double cross(pt a, pt b) { return a.x*b.y - a.y*b.x; }

int main(){
	IO;
	ll n,x,y,fact=1;
	long double sum = 0;
	cin>>n;
	pt a[n];
	forn(i,n){
		cin>>x>>y;
		a[i].x = x;
		a[i].y = y;
	}
	forni(i,n){
		fact*=i+1;
	}
	forn(i,n){
		for(ll j = i+1; j<n ;j++){
			sum+=sqrt(dot(a[j]-a[i],a[j]-a[i]))*2/n;
		}
	}
	printf("%.7Lf\n",sum);
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""


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

int matrix[310][310];
using lint = long long;
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			scanf("%d", &matrix[i][j]);
		}
	}
	lint sum = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			bool flag = false;
			for (int k = 0; k < n; k++) {
				if (k != i && k != j) {
					if (matrix[i][j] == matrix[i][k] + matrix[k][j]) {
						flag = true;
					}
					if (matrix[i][j] > matrix[i][k] + matrix[k][j]) {
						printf("-1");
						return 0;
					}
				}
			}
			if (!flag) {
				sum += matrix[i][j];
			}
		}
	}
	printf("%lld", sum);
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int K,A,B;
    cin>>K;
    cin>>A>>B;
    int count=0;
    int num=0;
    
    for(num=A;num<=B;num++)
    {
      //int check=num%K;
      //cout<<"%:"<<num%K<<endl;
      if((num%K)<=0){
        count++;
        //cout<<count<<endl;
      }
    }
    if(count>0)
    	cout<<"OK"<<endl;
  	else
        cout<<"NG"<<endl;
    
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

const int N = 1e6 + 10;
int dp[N][2];
int n;
int solve(string &s, int pos, int flag){
	if(pos == n){
		return 0;
	}
	if(dp[pos][flag] != -1){
		return dp[pos][flag];
	}
	int ans = 0;
	int dig = s[pos] - '0';
	if(flag)
		dig = (pos == n-1 ? 10 : 9) - (s[pos] - '0');
	ans = dig + solve(s,pos+1,flag);
	ans = min(ans,(dig + 1) + solve(s,pos+1,flag^1));
	
	return dp[pos][flag] = ans;
}

int32_t main(){
	string s;
	cin >> s;
	n = s.size();
	memset(dp,-1,sizeof dp);
	
	cout << min(solve(s,0,0),1 + solve(s,0,1)) << endl;

	return 0;
}



Measured memory_bytes: 79492
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
  int h,n;
  cin >> h >> n;
  LOOP(i,n){
    int a;
    cin >> a;
    h -= a;
  }
  if(h<=0)cout << "Yes" << endl;
  else  cout << "No" << endl;
}


Measured memory_bytes: 256
S = list(input())

N=len(S)
flag=0
for i in range(N):

    if i%2==0:  #奇数
        if S[i]=='L':
            flag=1
            break

    else:
        if S[i]=='R':
            flag=1
            break

if flag==0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <cctype>
#include <bits/stdc++.h>
using namespace std;
int n,m;
long long ans[100004];
int x[100004],y[100004];
int f[100004],num[100004];
int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++) f[i]=i,num[i]=1;
	for (int i=1;i<=m;i++)
		cin>>x[i]>>y[i];
	ans[m]=0;
	for (int i=m-1;i>=1;i--){
		int x1=x[i+1],y1=y[i+1];
		x1=find(x1);
		y1=find(y1);
		if (x1==y1){
			ans[i]=ans[i+1];
			continue;
		}
		ans[i]=ans[i+1]+1ll*num[x1]*num[y1];
		f[x1]=y1;
		num[y1]+=num[x1];
	}
	for (int i=1;i<=m;i++) cout<<1ll*n*(n-1)/2-ans[i]<<endl;
}

Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int age = in.nextInt();
		int cost = in.nextInt();
		in.close();
		int ans = age > 12 ? cost
				: age < 6 ? 0
				: cost / 2;
		System.out.println(ans);
	}

}

Measured memory_bytes: 23124
#include<stdio.h>

int main(){
	int w,n,i,c;
	scanf("%d",&w);
	int num[w];
	for(i=0;i<w;i++)num[i]=i+1;
	scanf("%d",&n);
	int a[n],b[n];
	for(i=0;i<n;i++)scanf("%d,%d",&a[i],&b[i]);
	for(i=0;i<n;i++){
		c=num[a[i]-1];
		num[a[i]-1]=num[b[i]-1];
		num[b[i]-1]=c;}
	for(i=0;i<w;i++)printf("%d\n",num[i]);
	return 0;
}

Measured memory_bytes: 0
N = int(input())
robots = [tuple(map(int, input().split())) for _ in range(N)]
robots = [(x+l, x-l) for x, l in robots]
robots.sort()

cnt = 0
last = -float('inf')
for right, left in robots:
    # 手前のロボットの右手が次のロボットの左手よりも小さいか判定
    if last <= left:
        cnt += 1
        last = right

print(cnt)


Measured memory_bytes: 30040
package main

import (
	"fmt"
)

func main() {
	var a,b int
	fmt.Scan(&a,&b)

	plags := 1
	count := 0
	for {
		if plags >= b {
			break
		}
		plags += a - 1
		count++
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int fact[100001];
int main() {
	int i,n,m,ans;
	fact[0]=1;
	for(i=1;i<=100000;i++){
		fact[i]=  (1LL*fact[i-1]%MOD * i%MOD)%MOD;
	}
	cin>>n>>m;
	if(abs(n-m)>1){
		cout<<0;
	}
	else{
		if(n!=m){
		ans = (1LL*fact[n]*fact[m])%MOD;
		cout<<ans;
		}
		else 
		{
			ans= (1LL*fact[n]*fact[m])%MOD;
			ans=ans%MOD * 2%MOD;
			cout<<ans%MOD;
		}
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

int table[MAX_N] = {};

signed main()
{
    int N, M, X;
    cin >> N >> M >> X;
    REP(i, M) {
        int A;
        cin >> A;
        table[A] = 1;
    }
    for(int i = X + 1; i <= N; i++) {
        table[i] += table[i-1];
    }
    for(int i = X - 1; i >= 0; --i) {
        table[i] += table[i+1];
    }
    printf("%lld\n", min(table[0], table[N]));
    return 0;
}


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

int main()
{
  std::vector<int> ABC(3);
  std::cin >> ABC.at(0) >> ABC.at(1) >> ABC.at(2);
  sort(ABC.begin(), ABC.end());
  std::cout << ABC.at(2) * 10 + ABC.at(0) + ABC.at(1) << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
using namespace std;
typedef pair<int,int> P;

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

void debug(int a[100][100]){
	cout << "[debug]" << endl;
	for(int y=0 ; y <= h*2 ; y++ ){
		for(int x=0 ; x <= w*2 ; x++ ){
			if( x%2 == 0 ){
				if( y%2 == 0 ){
					cout << "+";
				}else{
					cout << (a[y][x]? "|" : " " ) ;
				}
			}else{
				cout << (a[y][x]? "-" : " " ) ;
			}
		}
		cout << endl;
	}
	cout << endl;
}

void debug_2(int a[100][100]){
	cout << "[debug]" << endl;
	for(int y=0 ; y <= h*2 ; y++ ){
		for(int x=0 ; x <= w*2 ; x++ ){
			cout << a[y][x];
		}
		cout << endl;
	}
	cout << endl;
}

int solve(int a[100][100]){
	int d[100][100] = {0};
	d[1][1] = 1;
	
	P sp(1,1);
	queue<P> q;
	q.push( sp );
	
	while( !q.empty() ){
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
		int cnt = d[y][x];
		
		if( x == w*2-1 && y == h*2-1 ) break;
		for(int i=0 ; i < 4 ; i++ ){
			int mx = x + dx[i];
			int my = y + dy[i];
			int nx = mx + dx[i];
			int ny = my + dy[i];
			if( nx < 0 || ny < 0 || nx > w*2 || ny > h*2 ) continue;
			
			if( a[my][mx] == 0 && d[ny][nx] == 0 ){
				P np( nx , ny );
				q.push( np );
				d[ny][nx] = cnt+1;
			}
		}
	}
	return d[h*2-1][w*2-1];
}

int main(){
	while( cin >> w >> h , w || h ){
		int a[100][100] = {0};
		for(int x=0 ; x <= w*2 ; x++ ){
			a[0][x] = a[h*2][x] = 1;
		}
		for(int y=0 ; y <= h*2 ; y++ ){
			a[y][0] = a[y][w*2] = 1;
		}
		
		for(int y=0 ; y < (h*2-1) ; y++ ){
			if( y%2 == 0 ){
				for(int x=0 ; x < w-1 ; x++ ){
					//(x,y) => (2x+2,y+1);
					cin >> a[y+1][2*x+2];
				}
			}else{
				for(int x=0 ; x < w ; x++ ){
					//(x,y) => (2x+1,y+1);
					cin >> a[y+1][2*x+1];
				}
			}
		}
		//debug( a );
		cout << solve( a ) << endl;
	}
}

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

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

#[fastout]
fn main() {
  input! {
    N: usize,
  }
  let (mut A, mut B): (Vec<i32>, Vec<i32>) = {
    input! {
	  AB: [(i32, i32); N],
    }
    AB.into_iter().unzip()
  };
  A.sort();
  B.sort();
  let result = if N % 2 == 1 {
    let a = A[N / 2];
    let b = B[N / 2];
    b - a + 1
  } else {
    let a = A[N / 2 - 1] + A[N / 2];
    let b = B[N / 2 - 1] + B[N / 2];
    b - a + 1
  };
  println!("{}", result);
}


Measured memory_bytes: 9316
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

using namespace std;

int main(){
  int x[101];
  int n,xx;
  cin>>n>>xx;
  int sum=0;;
  int ma=10000;
  for(int i=0;i<n;i++){
    int tmp;cin>>tmp;
    sum += tmp;
    ma = min(ma,tmp);
  }


  cout<<(n+(xx-sum)/ma)<<endl;

  return 0;
}


Measured memory_bytes: 256
s = input()
c = s.count("R")
if c==3:
    print(3)
elif c==2:
    if s[0]==s[1]=="R" or s[1]==s[2]=="R":
        print(2)
    else:
        print(1)
elif c==1:
    print(1)
else:
    print(0)

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

int gcd(int x, int y)
{
    while(true){
        x=x%y;
        if(x==0) return y;
        y=y%x;
        if(y==0) return x;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y;
    while(cin>>x>>y){
        int g=gcd(x, y);
        int l=x/g*y;
        cout<<g<<' '<<l<<'\n';
    }
    return 0;
}

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

 class Main{




   public static long func(int weight[], long value[], int total, int weightnow, int index, int n, long dp[][] )
   { 
       
       if(index>=n)
       {
           return 0;
       }
       
       if(dp[index][weightnow]!=-1)
       {
           return dp[index][weightnow];
       }
       long sum=0l;
     //  int sum1=0;
    long ans =0l;
       
           if(weightnow+weight[index]>total)
           {  //System.out.println("weight"+weightnow+" "+weight[i]);
              // sum1+=func(weight,value,total,weightnow,i+1,n);
             sum=  func(weight,value,total,weightnow,index+1,n,dp);
           }
           else{
               ans=value[index]+func(weight,value,total,weightnow+weight[index],index+1,n,dp);
               long val1=func(weight,value,total,weightnow,index+1,n,dp);
               ans=Math.max(val1,ans);
           }
          
         ans=Math.max(ans,sum);
       
       dp[index][weightnow]=ans;
       return ans ;
   }
   
     public static void main(String []args) throws Exception{
        //System.out.println("Hello World");
        BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
        String s =br.readLine();
       String ss[]=s.split(" ");
       int total=Integer.parseInt(ss[1]);
       int n =Integer.parseInt(ss[0]);
       int weight[]=new int[n];
       long value[]=new long[n];
       String temp;
       String tempo[];
        for(int i=0;i<n;i++)
        {
         temp=br.readLine();
         tempo=temp.split(" ");
         weight[i]=Integer.parseInt(tempo[0]);
         value[i]=Long.parseLong(tempo[1]);
        }
        
        
        
    long  sum=0l;
        
     int weightnow=0;
        
      long dp[][]=new long[n][total+1];
        long ans =0l;
        for(int y=0;y<n;y++)
        {
            Arrays.fill(dp[y],-1);
        }
        int i=0;
        long val=0l;
            if(weight[i]>total)
           {
            val=func(weight,value,total,weightnow,i+1,n,dp);
            ans =Math.max(ans , val);  
           }
           else{
             val=value[i]+func(weight,value,total,weightnow+weight[i],i+1,n,dp);
             long val1=func(weight,value,total,weightnow,i+1,n,dp);
               val=Math.max(val1,val);
               ans =Math.max(ans , val);  
           }
           // System.out.println(val);
           //ans =Math.max(ans , val);    
            
        
        
        System.out.println(ans);
        
        
        
        
     }
}

Measured memory_bytes: 125140
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> v(n+3,0);
  for(int i=0;i<m;++i){
    int l,r;
    cin>>l>>r;
    v[l]++;
    v[r+1]--;
  }
  for(int i=1;i<n+3;++i)v[i]+=v[i-1];
  cout<<count(v.begin(),v.end(),m);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 998244353
#define MAX 100
#define INF 800000000

int main(){
  int N;
  cin>>N;
  vector<pair<ll,ll>> xy(N);
  for(int i=0;i<N;i++){
    cin>>xy.at(i).first>>xy.at(i).second;
  }
  int ans=50;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      ll p=xy.at(j).first-xy.at(i).first;
      ll q=xy.at(j).second-xy.at(i).second;
      vector<bool> seen(N,false);
      int count=0;
      for(int k=0;k<N;k++){
        for(int l=0;l<N;l++){
          if((xy.at(k).first-xy.at(l).first==p)&&(xy.at(k).second-xy.at(l).second==q)){
            count++;
          }
        }
      }
      ans=min(ans,N-count);
    }
  }
  if(N==1){
    cout<<1<<endl;
  }else{
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  int X;
  rd(X);
  if(X<1200){
    wt_L("ABC");
    wt_L('\n');
  }
  else{
    wt_L("ARC");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// {
//   int X;
//   rd(X);
//   wt(if[X<1200, "ABC", "ARC"]);
// }


Measured memory_bytes: 256
#include<stdio.h>

long long N,A,B,X[100001];

int main(void){
    int i,j,k;
    long long ans;

    scanf("%lld %lld %lld",&N,&A,&B);

    for(i = 1;i <= N;i++)
        scanf("%lld",&X[i]);
    ans = 0;k = N - 1;

    for(i = 1;i < N;i++){
        if((X[i + 1] - X[i]) * A < B){
            ans += (X[i + 1] - X[i]) * A;
            k--;
        }
    }

    ans += k * B;

    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 896
from collections import defaultdict
from bisect import bisect_right

N, K = map(int, input().split())
*A, = map(int, input().split())

dd = defaultdict(list)
cc = defaultdict(list)

for i, j in enumerate(A):
    dd[j].append(i)

pos, loop = 0, 1
ans = []

while pos < N:
    num = A[pos]
    pp = bisect_right(dd[num], pos)
    if pp < len(dd[num]):
        pos = dd[num][pp]+1
    else:
        pos = dd[num][0]+1            
        loop += 1
    cc[loop].append(pos)

pos = cc[K%loop][0] if cc[K%loop] else 0
while pos < N:
    num = A[pos]
    pp = bisect_right(dd[num], pos)
    if pp < len(dd[num]):
        pos = dd[num][pp]+1
    else:
        ans.append(num)
        pos += 1
print(*ans)


Measured memory_bytes: 174700
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> T(N+1, 0), X(N+1, 0), Y(N+1, 0);
  for (int i=0; i<N; i++) cin >> T.at(i+1) >> X.at(i+1) >> Y.at(i+1);
  
  bool fla = true;
  for (int i=0; i<N; i++) {
    int dt = T.at(i+1) - T.at(i);
    int dist = abs( X.at(i+1) - X.at(i) ) + abs( Y.at(i+1) - Y.at(i) );
    if (dt < dist) fla = false;
    if (dist % 2 != dt % 2) fla = false;
  }
  
  if (fla) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 1408
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))


A2 = sorted(A)
B2 = sorted(B)
C2 = sorted(C)


def numadd(up, down):
    array = []
    count = 0
    last = 0
    for i in range(0,N):
        while down[i] > up[count]:
            count = count + 1
            if count == N:
                count = count - 1
                last = 1
                break
        array.append(count + last)
    return array

B3 = numadd(A2,B2)
C3 = numadd(B2,C2)

B4 = [B3[0]]
for i in range(0,N-1):
    B4.append(B4[i] + B3[i+1])

ans = 0
for i in range (0,N):
    if C3[i] > 0:
        ans = ans + B4[C3[i]-1]

print(ans)

Measured memory_bytes: 30272
#include <bits/stdc++.h>
 
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)
 
using namespace std;
typedef long long ll;
 
int main(){
    string s;
    cin >> s;
 
    bool ans = false;
 
    rep(i, 3){
        if(s[i] == '7'){
            ans = true;
            break;
        }
    }
 
    cout << (ans ?  "Yes" : "No") << endl;
    return 0;
}

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

const int mod = 998244353;

string s;
map <string, int> all;

int dfs(string s){
//	cout << "dfs:" << s << endl;
	if (s.length() == 0) return 1;
	if (s.length() == 1) return s[0] - '0' + 1;
	if (all.count(s)) return all[s];
	int n = s.length();
	int res = 1ll * dfs(s.substr(1, n - 1)) * (s[0] - '0' + 1) % mod;
	for (int i = 1; i <= n / 2; i++){
		string tmp = s.substr(0, i);
		for (int j = 2; i * j <= n; j++){
			for (int k = i * (j - 1); k < i * j; k++){
				if (tmp[k - i * (j - 1)] == '0' || s[k] == '0') tmp[k - i * (j - 1)] = '0';
				else tmp[k - i * (j - 1)] = '1';
			}
			res = (res + 1ll * dfs(tmp) * dfs(s.substr(i * j, n - i * j))) % mod;
		}
	}
	return all[s] = res;
}

int main(){
	cin >> s;
	cout << dfs(s) << endl;
	return 0;
}


Measured memory_bytes: 5632
fun main(args: Array<String>) {
    val n = readLine()!!.split(" ").map { it.toInt() }[0]
    val p = readLine()!!.split(" ").map { it.toInt() }
    val q = readLine()!!.split(" ").map { it.toInt() }
    var a = 0
    var b = 0
    var count = 0

    fun dfs(myList: MutableList<Int>) {

        val m = myList.size
        if (n == m) {
            count++
            if (myList == p) {
                a = count
            }
            if (myList == q) {
                b = count
            }
            return
        }
        for (i in 1 until n+1){
            var flag = 0
            if (m > 0) {
                for (j in 0 until m) {
                    if (myList[j] == i) {
                        flag = 1
                        break
                    }
                }
            }
            if (flag == 1) continue
            myList.add(i)
            dfs(myList)
            myList.removeAt(m)
        }
    }

    dfs(mutableListOf())
    if (a > b) println("${a - b}")
    else println("${b - a}")
}



Measured memory_bytes: 43080
#include<stdio.h>

int main(void)
{
        int a, b, t;
        int res = 0;
        int i = 1;

        scanf("%d%d%d", &a,&b,&t);

        while(a*i < t+0.5) {
                res += b;
                i++;
        }

        printf("%d", res);
        return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
char s[101];
int main(void) {
scanf("%s", s);
int res = 0;
int n = strlen(s);
for (int i = 0; i < n; i++) {
if (s[i] != s[n - 1 - i]) res++;
}
printf("%d\n", res / 2);
}

Measured memory_bytes: 1704
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ANot solver = new ANot();
        solver.solve(1, in, out);
        out.close();
    }

    static class ANot {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt();
            if (x == 1) out.println("0");
            else out.println("1");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 32904
numberotestcase = int(input())
verdicat=[]
for step in range(numberotestcase):
  exp = input().upper()
  verdicat.append(exp)
 
first = verdicat.count('AC')
sec =  verdicat.count('WA')
thir =  verdicat.count('TLE')
fou = verdicat.count('RE')
print('AC x '+str(first))
print('WA x '+str(sec))
print('TLE x '+str(thir))
print('RE x '+str(fou))

Measured memory_bytes: 16276
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv,
    std.typecons, std.math, std.container, std.format, std.numeric;

void main(string[] args)
{
    long n;
    readf("%d\n", &n);
    n++;

    // ふるいをやるんだけど、各値についてその素因数を記録しておく
    long[] factorcount = new long[](n);
    factorcount[0] = 0;
    factorcount[1] = 1;

    long ans = 1;
    for (long i = 2; i < n; i++)
    {
        ans += i * (factorcount[i] + 2);
        for (long j = i + i; j < n; j += i)
        {
            factorcount[j] += 1;
        }
    }
    writeln(ans);

}


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

int main(){
  int a,A=0,B=0,O=0,z=0;
  char ti[3];
  while(scanf("%d,%s",&a,ti)>0){
    if(ti[0] == 'B'){
      B++;
    }
    else if(ti[0] == 'O'){
      O++;
    }
    else if(ti[1] == 'B'){
      z++;
    }
    else if(ti[0] == 'A'){
      A++;
    }
  }
  cout << A << endl << B << endl << z << endl << O << endl;
  return 0;
}

Measured memory_bytes: 1212
using System;
class Practice
{
    public static void Main()
    {
        string[] str = Console.ReadLine().Split(' ');
        int a = int.Parse(str[0]), b = int.Parse(str[1]);
        Console.WriteLine("{0} {1} {2:.000000}", a / b, a % b, (double)a / b);
    }
}


Measured memory_bytes: 18024
import math
from collections import defaultdict,deque
from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

t=1
#t=ii()
for _ in range(t):
    a,b,c=ml()
    a=abs(a)
    rem=a//c
    rem=abs(rem)
    
    if(b>=rem and b%2==rem%2):
        ans=abs(abs(a)-c*rem)
        print(ans)
    elif(b>=rem+1 and b%2!=rem%2):    
        ans=abs(abs(a)-c*(rem+1))
        print(ans)
    else:
        print(abs(abs(a)-c*b))

Measured memory_bytes: 65296
cl = [int(input()) for i in range(int(input()))]
ans = 1

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

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

for i in cl:
    ans = lcm(ans,i)

print(ans)


Measured memory_bytes: 3060
character s*4
read*, s
if(s(1:1)==s(2:2) .and. s(2:2)/=s(3:3) .and. s(3:3)==s(4:4)) then
	print*, "Yes"
else if(s(1:1)==s(3:3) .and. s(2:2)/=s(3:3) .and. s(2:2)==s(4:4)) then
	print*, "Yes"
else if(s(1:1)/=s(2:2) .and. s(2:2)==s(3:3) .and. s(1:1)==s(4:4)) then
	print*, "Yes"
else
	print*, "No"
end if
end

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int MAX_N = 100000;

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

    vector<int> c(MAX_N);
    
    rep(i, n) {
        int a;
        cin >> a;
        c[a]++;
    }

    int ans = 0;
    for(int i = 1; i <= MAX_N-2; i++) {
        int t = c[i-1] + c[i] + c[i+1];
        ans = max(ans, t);
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
N=int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
S=0
for x in range(0,N):
    S=S+B[A[x]-1]
    if x!=N-1:
        if A[x]==A[x+1]-1:
            S=S+C[A[x]-1]
print(S)


Measured memory_bytes: 3064