akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

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

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, k; std::cin >> n >> k;
  vi l(n); rep(i, n) std::cin >> l[i];
  sort(l.rbegin(), l.rend());
  int ans = 0;
  rep(i, k) ans += l[i];
  std::cout << ans << "\n";
}


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

using namespace std;

/** whole range */
#define whole(xs) (xs).begin(), (xs).end()

namespace {
    int N, C;
    vector<int> s, t, c;
    void input() {
        cin >> N >> C;
        s.resize(N); t.resize(N); c.resize(N);
        for (int i = 0; i < N; i++) cin >> s[i] >> t[i] >> c[i];
    }

    /** output whole vector. ex) vector<int>{1, 2, 3} -> '1 2 3'. */
    template<typename T>
    ostream& operator<<(ostream& os, const vector<T>& xs) {
       if (xs.empty()) return os;
       os << xs[0];
       for (auto i = 1; i < xs.size(); i++) os << ' ' << xs[i];
       return os;
    }

    struct P {
        int s, t;
        P(int s, int t) : s(s), t(t) {}
    };
    ostream& operator<<(ostream& os, const P& p) {
        return os << "[" << p.s << "," << p.t << ")";
    }
    void solve() {
        vector<vector<P>> M(C + 1);
        vector<P> X;
        for (int i = 0; i < N; i++) {
            M[c[i]].emplace_back(s[i], t[i]);
        }
        for (int i = 1; i <= C; i++) {
            sort(whole(M[i]), [&](const P& a, const P& b) {
                return a.s < b.s;
            });
        }
        for (int i = 1; i <= C; i++) {
            vector<P> buf;
            for (int j = 0; j < M[i].size(); ) {
                auto p = M[i][j];
                auto k = j + 1;
                while (k < M[i].size()) {
                    auto q = M[i][k];
                    if (p.t == q.s) {
                        p.t = q.t;
                        k++;
                    } else {
                        break;
                    }
                }
                buf.push_back(p);
                j = k;
            }
            M[i] = buf;
            X.insert(X.end(), whole(buf));
        }

        sort(whole(X), [&](const P& a, const P& b) {
            return a.s < b.s;
        });

        priority_queue<int, vector<int>, greater<int>> PQ;
        int ans = 0;
        for (auto x : X) {
            int s = x.s;
            int t = x.t;
            if (not PQ.empty() and PQ.top() < s) {
                PQ.pop();
            } else {
                ans++;
            }
            PQ.push(t);
        }
        cout << ans << endl;

        //for (int i = 1; i <= C; i++) {
        //    cout << i << ": " << M[i] << endl;
        //}
    }
}

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



Measured memory_bytes: 3660
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	bs := make([]int, n-1)
	for i, _ := range bs {
		fmt.Scan(&bs[i])
	}

	as := make([]int, len(bs)+1)
	var s int
	for i, b := range bs {
		as[i] = b
		as[i+1] = b
		if i != 0 && bs[i-1] < as[i] {
			as[i] = bs[i-1]
		}
	}
	for _, a := range as {
		s += a
	}

	fmt.Print(s)
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

 class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String[] args) {
        FastReader in = new FastReader();
        long n = in.nextLong();
        StringBuilder res = new StringBuilder();
        while (n>0){
            n = n-1;
            char c = (char) ('a' + n%26);
            res.append(c);
            n = n/26;
        }
        System.out.println(res.reverse());
    }
}

Measured memory_bytes: 32684
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long K;
    cin >> K;
    long long A,B;
    cin >> A >> B;
    bool flag = false;
    for(int i=A;i<=B;i++){
        if(i%K==0){
            flag = true;
            break;
        }
    }
    if(flag == true){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,r = LI()

    return r + max(0,100*(10-n))


print(main())





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

int main(){
    int a,b;
    cin>>a>>b;
    int ans=max(a+b,max(a-b,a*b));
    cout<<ans<<endl;
}

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

#define endl '\n'

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define BUFF ios::sync_with_stdio(0);

typedef long long int ll;
typedef long double ld;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef pair < int, int > ii;
typedef vector < ii > vii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const int MOD = 1e9+7;
const ld pi = acos(-1);

int main() { BUFF
  string a, b, c;
  cin >> a >> b >> c;
  int pa = 0, pb = 0, pc = 0;
  char turn = 'a';
  while(pa <= a.size() && pb <= b.size() && pc <= c.size()) {
    if(turn == 'a') turn = a[pa++];
    else if(turn == 'b') turn = b[pb++];
    else if(turn == 'c') turn = c[pc++];
  }
  if(pa > a.size()) cout << "A" << endl;
  else if(pb > b.size()) cout << "B" << endl;
  else if(pc > c.size()) cout << "C" << endl;
  return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
import math
def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()
def IIR(n): return [II() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
mod = 1000000007

#A
n,k = LI()
if 2*(k-1) < n:
    print("YES")
else:
    print("NO")
#B

#C

#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38384
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}



signed main(){
	ll n;
	cin >> n;
	
	string s;
	cin >> s;
	
	rep(i,0,s.size()){
		cout << (char)('A' + ((s[i] + n) - 'A') % 26);
	}
	
	cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int  n, a, b, c;
  string ans;
  cin >> n ;
  ans = "No";
  a = n/100;
  b = (n - a*100)/10;
  c = (n - a*100 - b*10);
  
  if(a == 7 || b == 7 || c == 7){
    ans = "Yes";
  }
  
  cout << ans <<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <math.h>

using namespace std;

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

  int a = 0;

  for (int i = 0; i < S.size();i++){
    if(i%2==0){
      if (S.at(i) == 'L')
      {
        cout << "No" << endl;
        a = 1;
        break;
      }
    }
    else{
      if (S.at(i) == 'R')
      {
        cout << "No" << endl;
        a = 1;
        break;
      }
    }
  }

  if(a==0){
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
   int n;
   cin>>n;
   string s, t;
   cin>>s>>t;

   rep(i, n) cout<<s[i]<<t[i];
   cout<<endl;
   return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long ;
using P = pair<ll, ll>;
const ll INF = 1e16;

void solver(string const &S, string const &ref, bool &flg){

    int cnt = 0, pos = 0;
    for(int i = 0; i != S.size(); ++i){
        if(pos == ref.size()) break;
        if(S.at(i) != ref.at(pos)) break;
        ++cnt;
        ++pos;
    }
    pos = ref.size() - 1;
    for(int i = S.size()-1; i != -1; --i){
        if(pos == 0) break;
        if(S.at(i) != ref.at(pos)) break;
        ++cnt;
        --pos;
    }

    if(cnt >= ref.size()) flg = true;

    return;
}

int main(){

    string S;
    cin >> S;

    string ref = "keyence";

    bool flg = false;
    solver(S, ref, flg);

    if(flg) cout << "YES"s << endl;
    else cout << "NO"s << endl;

    return 0;
}

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

using namespace std;
#define int long long


#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
#define PI 3.1415926535897932384626433832795
int MOD=1e9+7;
int powmod(int a,int l, int md){int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; typedef vector<ii> vii;
#define pb push_back
int __set(int b, int i) {return b|(1<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return ((a%md)*(b%md))%md;}
int addmod(int a, int b, int md) {return (a+b)%md;}
int submod(int a, int b, int md) {return (((a-b)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
// priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}

int solve(string& s1, string& s2) {
	int ret=-1;
	int ln = min(s1.length(),s2.length());
	for(int i = 0; i < ln; i++) {
		if(s1[i]!=s2[i]) {
			ret=i;
			break;
		}
	}
	if(ret==-1)
		ret=ln;
	return ret/2;
}
signed main(void)
{
	IOS;
	// int n,k,m; cin>>n>>k>>m;
	// int vv=n*m;
	// for(int i = 0; i < n-1; i++) {
	// 	int x; cin>>x;
	// 	vv-=x;
	// }
	// if(vv<=0) {
	// 	cout<<0<<endl;
	// } else if(vv > k) {
	// 	cout<<-1<<endl;
	// } else {
	// 	cout<<vv<<endl;
	// }

	char c;
	cin>>c;
	cout<<(char)(c+1)<<endl;
	return 0;
}

Measured memory_bytes: 256
N,M,C=[int(s) for s in input().split(" ")]
B=[int(s) for s in input().split(" ")]
A=[input().split(" ") for _ in range(N)]

count=0
for i in range(N):
  sum=0
  for j in range(M):
    sum+=int(A[i][j])*B[j]
  sum+=C
  if sum>0:
    count=count+1
 

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

ll a[2002];
ll dp[2002][2];
//dp[ 山札からとった枚数 ][ 後手かどうか ] 
//:= その状態からスタートしたときの、最終的なカードの数値の差の最適値 (先手なら最大値、後手なら最小値)

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,Z,W;
    cin >> n >> Z >> W;
    rep(i,n)cin >> a[i];

    for(int i=n-1;i>=0;i--){
        // 先手番
        dp[i][0] = -INF;

        ll Y = (i?a[i-1]:W);// 残りi枚 = i-1番目のカードを相手が持っている

        chmax(dp[i][0],abs(Y-a[n-1]));//全ての山札を取る場合
        for(int j=i+1;j<n;j++)chmax(dp[i][0],dp[j][1]);

        dp[i][1] = INF;

        ll X = (i?a[i-1]:Z);// 先手の持つカードの番号

        chmin(dp[i][1],abs(X-a[n-1])); // 最後のカードを取る場合

        for(int j=i+1;j<n;j++)chmin(dp[i][1],dp[j][0]);
    }
    cout << dp[0][0] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char a[101],b[101];
    int i,j,c=0;
    char *p,*p1,p2,tm;

    scanf("%s",a);
    scanf("%s",b);

    for(i=0;i<strlen(a);i++)
    {

        if((strcmp(a,b))==0)
            {
                c++;
                break;
            }



        p2=a[0];

        for(j=0;a[j+1]!='\0';j++)
        {
            a[j]=a[j+1];
        }
        a[j]=p2;


    }
    if(c==0) printf("No");
    else printf("Yes");

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] arr = new int[45];
		arr[0]=1;
		arr[1]=1;
		
		for(int i=2;i<arr.length;i++)
		{
			arr[i]=arr[i-1]+arr[i-2];
		}
		
		int n = sc.nextInt();
		System.out.println(arr[n]);
	}
}



Measured memory_bytes: 26252
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
#define par pair<int,pair<int,long long> > 
#define dat pair<long long,pair<int,int> > 
using namespace std;
int n,m,s,mx,ns,a;
long long u,v,t,nt,b,c[100],d[100];
vector<par> ga[60];
long long dp[60][2510],res;
bool vis[60][2510];
priority_queue<dat,vector<dat>,greater<dat> >q; 
dat tmp;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>m>>s;
  	mx=(n-1)*50;
	for(int i=1;i<=m;i++){
		cin>>u>>v>>a>>b;
		ga[u].push_back(make_pair(v,make_pair(a,b)));
		ga[v].push_back(make_pair(u,make_pair(a,b)));
	}
	for(int i=1;i<=n;i++)
		cin>>c[i]>>d[i];
	memset(dp,63,sizeof(dp));
	s=min(s,mx);
	dp[1][s]=0;
	q.push(make_pair(0,make_pair(1,s)));
	while(q.size()){
		tmp=q.top();
		q.pop();
		u=tmp.second.first;
		t=tmp.first;
		s=tmp.second.second;
		for(int i=0;i<ga[u].size();i++){
			if(s<ga[u][i].second.first) continue;
			v=ga[u][i].first;
			ns=s-ga[u][i].second.first;
			nt=ga[u][i].second.second;
			if(dp[v][ns]>dp[u][s]+nt){
				dp[v][ns]=dp[u][s]+nt;
				q.push(make_pair(dp[v][ns],make_pair(v,ns)));
			}
		}
		ns=s+c[u];
		ns=min(ns,mx);
		if(dp[u][ns]>dp[u][s]+d[u]){
			dp[u][ns]=dp[u][s]+d[u];
			q.push(make_pair(dp[u][ns],make_pair(u,ns)));
		}
	}
	for(int i=2;i<=n;i++){
		res=1e18;
		for(int j=0;j<=mx;j++){
			res=min(res,dp[i][j]);
		}
		cout<<res<<endl;
	}
	return 0;
}


Measured memory_bytes: 6384
#include <stdio.h>

int main(void){
	int i,j;
	char S[5];
	scanf("%s",S);
	int f;

	f=0;
	for(i=0; i<4; i++){
		for(j=i+1; j<4; j++){
			if(S[i]==S[j]) f++;
		}
	}
	if(f==2)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>

#define PI (3.14159265358979323846)
#define INF (1e+9)
#define DIV_NUM (1000000007)

using namespace std;

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

	// 1bitずつ立てながら、それぞれ処理を行ってゆくコード
	long long count = 0;
	int search_bit_num = S.length() - 1;

	for (int i = 0; i < (1 << search_bit_num); i++) { // 000-111の様にループを回す

		int last_one = 0;
		for (int j = 0; j < search_bit_num; j++) { // 下から一桁づつ処理
			if (i & (1 << j)) { // j番目のビットが1なら
				// j番目のビットが1の時の処理
				string tmp_s = S.substr(S.length() - 1 - j, j - last_one + 1);
				long long tmp = atoll(tmp_s.c_str());
				count += tmp;
				last_one = j + 1;
			}
			else {
				// j番目のビットが0の時の処理
			}
		}
		// ビット状態にかかわらず、共通して実施する処理
		long long tmp = atoll(S.substr(0, S.length() - last_one).c_str());
		count += tmp;
	}

	cout << count << endl;

    return 0;
}




Measured memory_bytes: 256
#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);

    ll N,W; cin >> N >> W;

    ll w[105],v[105];

    vector<ll> lis[4];

    cin >> w[0] >> v[0];
    lis[0].push_back(v[0]);

    for (int i =1;i < N;i++){
        cin >> w[i] >> v[i];
        lis[w[i]-w[0]].push_back(v[i]);
    }

    vector<ll> sum[4];

    for (int i = 0;i < 4;i++){
        sort(lis[i].begin(),lis[i].end());
        reverse(lis[i].begin(),lis[i].end());
        sum[i].push_back(0);
        for (int j = 0;j < lis[i].size();j++){
            sum[i].push_back(sum[i][j]+lis[i][j]);
        }
    }

    ll ans = -1;

    for (int i = 0;i <= lis[0].size();i++){
        for (int j = 0;j <= lis[1].size();j++){
            for (int k = 0;k <= lis[2].size();k++){
                for (int l = 0;l <= lis[3].size();l++){
                    if(w[0]*i+(w[0]+1)*j+(w[0]+2)*k+(w[0]+3)*l > W) continue;  
                    ans = max(sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l], ans);
                }
            }
        }
    }

    cout << ans << endl;

    return 0;

}

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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;
const long double PI = (acos(-1));
const ull MOD = 1000000007;


struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;
template <class X> map<X,int> prime_factorize(X a){
    int b = 2;
    map<X,int>cnt;
    while(a >= b * b){
        if(a % b == 0){
            cnt[b]++;
            a /= b;
        }else b++;
    }
    cnt[a]++;
    return cnt;
}
int main(){
    int N;
    cin >> N;
    map<int,int> cnti;
    for(int i = 2; i <= N; i++){
        map<int,int> cnt = prime_factorize(i);
        for(auto p: cnt){
            cnti[p.fi] += p.se;
        }
    }
    ull ans = 1;
    for(auto p : cnti){
        ans *= (p.se + 1);
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
str_s = input()

if str_s[0] != 'A':
    print("WA")
    exit(0)

if str_s[2:-1].count("C") != 1:
    print("WA")
    exit(0)

idx_c = str_s.find("C")

w_str = str_s[1:idx_c] + str_s[idx_c +1:]
if w_str.islower():
    print("AC")
else:
    print("WA")







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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int N;
	cin >> N;
	vector<int> v;
	forn(i, N)
	{
		int tmp; 
		cin >> tmp;
		--tmp;
		if (tmp > v.size())
		{
			cout << -1 << endl;
			return 0;
		}
		v.insert(v.begin()+tmp, tmp + 1);
	}
	forn(i, N)
		cout << v[i] << endl;
	return 0;
}


Measured memory_bytes: 256
// 3_abc111_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k = 100000;
    int n;
    cin >> n;
    vector<pair<int, int>> u(k + 1);
    vector<pair<int, int>> v(k + 1);

    rep(i, k + 1){
        v[i] = make_pair(0, i);
        u[i] = make_pair(0, i);
    }
    rep(i, n){
        int a;
        cin >> a;
        if(i % 2 == 0){
            u[a].first++;
        }else{
            v[a].first++;
        }
    }

    sort(u.begin(), u.end(), greater<pair<int, int>>());
    sort(v.begin(), v.end(), greater<pair<int, int>>());

    if(u[0].second != v[0].second){
        cout << n - u[0].first - v[0].first << endl;
    }else{
        int ans = max(u[0].first + v[1].first, u[1].first + v[0].first);
        cout << n - ans << endl;
    }

    return 0;
}


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

using namespace std;

int main()
{
    int n, q;
    
    while (scanf("%d %d", &n, &q) && n){
        int a[128] = {0};
        
        for (int i = 0; i < n; i++){
            int m;
            scanf("%d", &m);
            for (int j = 0; j < m; j++){
                int x;
                scanf("%d", &x);
                a[x]++;
            }
        }
        
        int mpos = 1;
        
        for (int i = 1; i < 128; i++){
            if (a[i] > a[mpos]) mpos = i;
        }
        
        printf("%d\n", mpos * (a[mpos] >= q));
    }
    
    return (0);
}

Measured memory_bytes: 1188
#include<deque>
#include<queue>
#include<map>
#include<string>
#include<iostream>
#include<set>
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
//#define scanf scanf_s
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<30);
const llint mod=1000000007;


int main(void){
	llint N,ans;
	int M,q,i,j,a,ansa,ansb,ok=0;
	queue<int> que;
	vector<int> nuru;
	vector<int> siro;//0=siro 1=kuro
	int hkazu;
	scanf("%lld %d %d",&N,&M,&q);
	for(i=0;i<q;i++){
		scanf("%d",&a);
		nuru.pub(a);
	}
	
	if(M%7!=0){ 
		for(i=0;i<q;i++){
			for(j=1;j<7;j++){
				nuru.pub(nuru[i]+M*j);
			}
		}
		M*=7;ok=1;
	}
	siro.resize(M);
	for(i=0;i<nuru.size();i++){
		siro[nuru[i]]=1;
	}
	hkazu=M-nuru.size();
	ansa=0;
	for(i=0;i<M;i++){
		if(siro[i]==1){ continue; }
		que.push(i);
		while(!que.empty()){
			hkazu--;
			a=que.front();
			que.pop();
			if(siro[a]==1){continue;}
			siro[a]=1;
			if(a-7>=0&&siro[a-7]==0){ que.push(a-7); }
			if(a+7<M&&siro[a+7]==0){ que.push(a+7); }
			if(a%7!=0&&siro[a-1]==0){ que.push(a-1); }
			if(a%7!=6&&siro[a+1]==0){ que.push(a+1); }

		}
		ansa++;
	}
	siro.clear();
	siro.resize(M*2);
	for(i=0;i<nuru.size();i++){
		siro[nuru[i]]=1;siro[nuru[i]+M]=1;
	}
	hkazu=M*2-nuru.size();
	ansb=0;
	for(i=0;i<M*2;i++){
		if(siro[i]==1){continue;}
		que.push(i);
		while(!que.empty()){
			hkazu--;
			a=que.front();
			que.pop();
			if(siro[a]==1){ continue; }
			siro[a]=1;
			if(a-7>=0&&siro[a-7]==0){ que.push(a-7); }
			if(a+7<M*2&&siro[a+7]==0){ que.push(a+7); }
			if(a%7!=0&&siro[a-1]==0){ que.push(a-1); }
			if(a%7!=6&&siro[a+1]==0){ que.push(a+1); }
		}
		ansb++;
	}
	ans=(ansb-ansa)*N*7/M+(2*ansa-ansb);
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 8952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    int mx = 0;
    for(int i = 0; i < n; i++) {cin >> a[i] >> b[i]; mx = max(mx, a[i]);}
    //for(int i = 0; i < n; i++) cout << a[i] << " " << b[i] << "\n";
    int len = h + mx + 1;
    vector<vector<ll>> dp(n + 1, vector<ll>(len, INF));
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++){
        int val = a[i - 1];
        //cout << val << " ";
        for(int j = 0; j < len; j++){
            if(j < val) dp[i][j] = dp[i - 1][j];
            else{
                dp[i][j] = min(dp[i - 1][j], dp[i][j - val] + b[i - 1]);
            }
        }
    }
    ll mn = LLONG_MAX;
    //for(int i = 0; i <= n; i++) {cout << "\n"; for(int j = 0; j < len; j++) cout << dp[i][j] << " ";}
    for(int i = 0; i <= n; i++){
        for(int j = h; j < len; j++){
            mn = min(mn, dp[i][j]);
        }
    }
    cout << mn;
}

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

int main() {
	long long int n, a, b, x[100001], np = 1, count = 0;
	cin >> n >> a >> b;
	cin >> x[0];
	np = x[0];
	for(int i=1; i<n; i++){
		cin >> x[i];
		if(((x[i] - np) * a) < b){
			count += (x[i] - np) * a;
			
		}else{
			count += b;
		}
		np = x[i];
	}
	
	cout << count <<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
int a[500001];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	vi vec;
	for(int i=n-1;i>=0;i-=2)
	{
		vec.pb(a[i]);
	}
	for(int i=(n&1);i<n;i+=2)
	{
		vec.pb(a[i]);
	}
	for(int i=0;i<vec.size();i++)
	{
		cout<<vec[i];
		if(i+1<vec.size()) cout<<' ';
	}
	cout<<'\n';
}


Measured memory_bytes: 6064
package main

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

var scanner *bufio.Scanner

func printIt() {
	a := nextInt()
	b := nextInt()
	fmt.Printf("%d %d %f\n", a/b, a%b, float64(a)/float64(b))
}

func nextInt() int {
	scanner.Scan()
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(1)
	}
	return num
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



Measured memory_bytes: 1104
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define INF 2140000000
#define MOD 1000000007

int main() {
	long long n, m, a, b;
	vector<pair<long long,long long> > v;
	
	cin >> n >> m;

	for (int i = 0; i < n; ++i) {
		cin >> a >> b;
		v.push_back(make_pair(a,b));
	}

	sort(v.begin(),v.end());
	
	long long ans = 0, mm = 0;

	for (int i = 0; i < n; ++i) {
		if (mm + v[i].second < m) {
			mm += v[i].second;
			ans += v[i].second * v[i].first;
		}
		else if(mm + v[i].second == m) {
			mm += v[i].second;
			ans += v[i].second * v[i].first;
			break;
		}
		else if(mm + v[i].second > m) {
			long long temp = m - mm;
			mm += m - mm;
			ans += temp * v[i].first;
			break;
		}
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long q, h, s, d, n;
    scanf("%lld%lld%lld%lld%lld", &q, &h, &s, &d, &n);
    s = min(4 * q, min(2 * h, s));
    if (d > 2 * s) {
        printf("%lld\n", s * n);
    }
    else {
        printf("%lld\n", (n / 2) * d + (n % 2) * s);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <queue>
using namespace std;

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

vector<int> sorted;
int topological_sort(vector<vector<int> > &dag){
    int n = dag.size();
    vector<int> in_degree(n);
    for(int i=0;i<n;i++){
        for(auto x: dag[i]){
            in_degree[x]++;
        }
    }
    queue<int> node_set;
    for(int i=0;i<n;i++){
        if(in_degree[i] == 0){
            node_set.push(i);
        }
    }
    while(!node_set.empty()){
        int node = node_set.front();
        node_set.pop();
        sorted.push_back(node);
        for(auto x: dag[node]){
            in_degree[x]--;
            if(in_degree[x] == 0) node_set.push(x);
    }
    }
    return 0;
}

int dp[100005];
int main(){
    rep(i,100005) dp[i] = 0;
    int n, m; cin >> n >> m;
    vector<vector <int> > g(n);
    vector<int> in_degree(n);
    rep(i,m){
        int fr,to; cin >> fr >> to;
        g[fr-1].push_back(to-1);
        in_degree[to-1]++;
    }
    topological_sort(g);
    rep(i,n){
        int idx = sorted[i];
        for(auto x: g[idx]){
            dp[x] = max(dp[x], dp[idx]+1);
        }
    }
    int ans = 0;
    rep(i,n) ans = max(ans, dp[i]);
    cout << ans << endl;
}


Measured memory_bytes: 7548
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  string s;cin>>s;
  int zero=0,one=0;
  int i;
  int n=s.size();
  for(i=0;i<n;i++){
    if(s.at(i)=='0') zero++;
    if(s.at(i)=='1') one++;
  }
  int ans;
  ans = min(zero,one)*2;
  cout << ans << endl;


}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>
#include <cctype>

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

typedef long long ll;

using namespace std;

const int INF = 1e9;
const double PI=3.14159265358979323846;

int main(){
  string s,p,ds;
  cin >> s >> p;
  ds = s+s;

  int pos = ds.rfind(p);

  if(pos == string::npos) cout << "No" << endl;
  else cout << "Yes" << endl;
}



Measured memory_bytes: 3200
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

int Q;
ll A,B;
bool flag;

int main()
{
	cin>>Q;
while(Q--){
	flag=0;
	cin>>A>>B;
	if(A>B) swap(A,B);
	if(A==B||A+1==B){
		cout<<2*(A-1)<<endl;
		continue;
	}
	ll ub=1e+9+10;
	ll lb=0;
	ll mid=0;
	while(ub-lb>1){
		mid=(ub+lb)/2;
		if(mid*mid>A*B){
			ub=mid;
		}
		else lb=mid;
	}
	if(lb*lb==A*B) flag=1;
	if(flag){
		cout<<2*(lb-1)-1<<endl;
	}
	else{
		ll ans=2*lb-1;
		if(lb*(lb+1)>=A*B) ans--;
		cout<<ans<<endl;
	}
}
}

Measured memory_bytes: 256
function body(S){
    var ss = parseInt(S);
    var s = ss % 60;
    var x = Math.floor(ss / 60);
    var m = x % 60;
    var h = Math.floor(x / 60);

    return(h.toString() + ":" + m.toString() + ":" + s.toString());
}
    
str = require("fs").readFileSync("/dev/stdin", "utf8");
console.log(body(str));


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

int main(){
  
  int N;
  cin >> N;
    
  for(int i = 0; i < N; i++){
    
    string x;
    cin >> x;
    
    if (x == "Y"){
      cout << "Four" << endl;
    break;
    }
     
    if (i == N-1){
      cout << "Three" << endl;
    }
  
  }
  
}

Measured memory_bytes: 256
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <utility>
#include <set>
#include <unordered_set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>
#include <functional>

using namespace std;

typedef long long ll;
typedef pair<int,int> i2;
typedef pair<ll,ll> ll2;

int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    int a, b, c, x, y;
    
    cin >> a >> b >> c >> x >> y;
    c *= 2;
    
    int ret = 0;
    
    if (c <= a+b)
    while (x > 0 && y > 0)
    {
        x--;
        y--;
        ret += c;
    }
    
    while (x > 0)
    {
        x--;
        ret += min(a,c);
    }
    while (y > 0)
    {
        y--;
        ret += min(b,c);
    }
    
    cout << ret << '\n';
    
    return 0;
    
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string> a(n);
  vector<int> b;
  string st;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i==j)continue;
      st=a[i]+a[j];
      //cout << st << endl;
      int num;
      num=atoi(st.c_str());
      b.push_back(num);
      sort(b.begin(),b.end());
      if(b.size()>3)b.pop_back();
    }
  }
  for(int i=0;i<3;i++){
    if(i==2)cout << b[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3488
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0;
string s;
bool flag;
#pragma endregion
#define MAX 111111

#define NOT 0
#define VIS 1
#define COMP 2

struct edge {
  ll cost;
  pll node;
  edge(ll c, pll n) : cost(c), node(n) {}
  bool operator>(const edge &e) const {
	return cost > e.cost;
  }
};

priority_queue<edge, vector<edge>, greater<edge>> pq1;

ll stt[MAX];
ll mini[MAX];
vector<pll> edge2[MAX];
priority_queue<pll, vector<pll>, greater<pll>> pq2;

void dijkstra(ll start) {
  ll k;
  pll min;
  FOR(i, 0, n) {
	stt[i] = NOT;
	mini[i] = INF;
  }
  mini[start] = 0;
  pq2.push(make_pair(0, start));

  while (!pq2.empty()) {
	min = pq2.top();
	pq2.pop();
	m = min.second;
	stt[m] = COMP;

	if (mini[m] < min.first) continue;

	FOR(i, 0, edge2[m].size()) {
	  k = edge2[m][i].first;
	  if (stt[k] != COMP) {
		if (edge2[m][i].second + mini[m] < mini[k]) {
		  mini[k] = edge2[m][i].second + mini[m];
		  stt[k] = VIS;
		  pq2.push(make_pair(mini[k], k));
		}
	  }
	}
  }

}

int main(void) {
  ll x[333][333];
  cin >> n;
  FOR(i, 0, n) {
	FOR(j, 0, n) {
	  scanf("%lld", &x[i][j]);
	}
  }
  FOR(i, 0, n) {
	FOR(j, i + 1, n) {
	  pq1.push(edge(x[i][j], pll(i, j)));
	}
  }

  while (!pq1.empty()) {
	edge e = pq1.top();
	pq1.pop();
	dijkstra(e.node.F);
	//cout << mini[e.node.S] << " " << e.node.first << " " << e.node.second << endl;
	if (mini[e.node.S] > e.cost) {
	  edge2[e.node.F].pb(pll(e.node.S, e.cost));
	  edge2[e.node.S].pb(pll(e.node.F, e.cost));
	  ans += e.cost;
	}
	else if (mini[e.node.S] < e.cost) {
	  cout << "-1" << endl;
	  return 0;
	}
  }
  cout << ans << endl;

  return 0;
}

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

int main(){
  ll N,A,B;
  cin >> N >> A >> B;
  if((B-A)%2==0){
    cout << (B-A)/2 << endl;
    return 0;
  }
  cout << min(N-B,A-1) +1+(B-A-1)/2<< endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	cout << max(C - (A - B), 0) << endl;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;

void main()
{
    while(true)
    {
        auto input=readln.split.map!(to!int);
        if(input[0]==0&&input[1]==0) break;
        int m=input[1]-input[0];
        int th, fiv, han;
        for(; m>=1000; ++th) m-=1000;
        for(; m>=500; ++fiv) m-=500;
        for(; m>=100; ++han) m-=100;
        writeln(han, " ", fiv, " ", th);
    }
}

Measured memory_bytes: 1052
#include <cstdio>
#define MAXN 2000
char mat[MAXN + 1][MAXN + 1];
int vertex[MAXN + 1][MAXN + 1];
int edge[MAXN + 1][MAXN + 1];
int slin[MAXN + 1][MAXN + 1];
int scol[MAXN + 1][MAXN + 1];

int main() {
    FILE * fi, * fout;
    int i,n,m,q,j,x1,x2,y1,y2;
    //fi = fopen("A.in" ,"r");
    //fout = fopen("A.out" ,"w");
    fi=stdin;
    fout=stdout;
    fscanf(fi,"%d %d %d " ,&n, &m, &q);
    for(i = 1; i <= n; i++)
     for(j = 1; j <= m; j++) {
        fscanf(fi,"%c " ,&mat[i][j]);
        mat[i][j] -= '0';
        vertex[i][j] = mat[i][j] + vertex[i - 1][j] + vertex[i][j - 1] - vertex[i - 1][j - 1];
        slin[i][j] = slin[i][j - 1];
        scol[i][j] = scol[i - 1][j];
        edge[i][j] += edge[i - 1][j] + edge[i][j - 1] - edge[i - 1][j - 1];
        if(mat[i][j] == 1) {
           if(mat[i - 1][j] == 1)
             edge[i][j]++;
           if(mat[i][j - 1] == 1)
             edge[i][j]++;
           if(mat[i][j - 1] == 1)
             slin[i][j]++;
           if(mat[i - 1][j] == 1)
             scol[i][j]++;
        }
     }
    while(q>0) {
        q--;
        fscanf(fi,"%d %d %d %d " ,&x1,&y1,&x2,&y2);
        int ans = vertex[x2][y2] - vertex[x1 - 1][y2] - vertex[x2][y1 - 1] + vertex[x1 - 1][y1 - 1];
        ans -= edge[x2][y2] - edge[x1][y2] - edge[x2][y1] + edge[x1][y1] + slin[x1][y2] - slin[x1][y1] + scol[x2][y1] - scol[x1][y1];
        fprintf(fout,"%d\n" ,ans);
    }
    //fclose(fi);
    //fclose(fout);
}


Measured memory_bytes: 68224
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll n;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>n;
	ll sum=0;
	for(ll i=1; i<=n;i++)
	{
	    if(i%3==0||i%5==0)
	    continue;
	    else
	    sum+=i;
	}
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int M=stdIn.nextInt();
		int C=stdIn.nextInt();
		int A[]=new int[M];
		int B[]=new int[M];
		int z=0,y=0,ans=0,cou=0;
		while(z<M){
			B[z]=stdIn.nextInt();
			z++;
		}z=0;
		while(y<N){
			while(z<M){
				A[z]=stdIn.nextInt();
				cou+=A[z]*B[z];
				z++;
			}z=0;
			cou+=C;
			if(cou>0)
				ans++;
			cou=0;
			y++;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 21844
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    int N, X;
    cin >> N >> X;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    ll sum = 0;
    FOR(i, 0, N){
        sum += A[i];
    }

    ll rest = X - sum;

    sort(ALL(A));
    ll additional_num = rest / A[0];

    p(N+additional_num);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    // 逆順
    int N, M;
    cin >> N >> M;
    string S;
    cin >> S;
    int cur = N;
    vector<int> ans;
    while (cur) {
        bool flag = false;
        for (int i = M; i >= 1; i--) {
            if (cur-i>=0 && S[cur-i] == '0') {
                cur -= i;
                flag = true;
                ans.push_back(i);
                break;
            }
        }
        if (!flag) {
            cout << -1 << '\n';
            return 0;
        }
    }
    reverse(ans.begin(), ans.end());
    show(ans);
    return 0;
    // ll, 0, -, 1i, for s&g, debug
}

Measured memory_bytes: 3880
import io.StdIn.{readInt, readLine}

object Main extends App {
  val n = readInt
  val ds = for (i <- 1 to n) yield readLine.split(' ')

  val result = ds.sliding(3).exists(_.forall(d => d.head == d.last))
  if (result) println("Yes")
  else println("No")
}

Measured memory_bytes: 58396
import java.io.*;

class Dice{
    int[] sides = new int[6];
    int j = 0;

    Dice(int[] sides){
        this.sides = sides;
    }

    void N(){
        int tmp = sides[0];
        sides[0] = sides[1];
        sides[1] = sides[5];
        sides[5] = sides[4];
        sides[4] = tmp;
    }

    void S(){
        int tmp = sides[0];
        sides[0] = sides[4];
        sides[4] = sides[5];
        sides[5] = sides[1];
        sides[1] = tmp;
    }

    void W(){
        int tmp = sides[0];
        sides[0] = sides[2];
        sides[2] = sides[5];
        sides[5] = sides[3];
        sides[3] = tmp;
    }

    void E(){
        int tmp = sides[0];
        sides[0] = sides[3];
        sides[3] = sides[5];
        sides[5] = sides[2];
        sides[2] = tmp;
    }

    int getSide(int i){
        return sides[i];
    }
}

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        String[] str = br.readLine().split(" ");
        int[] sides = new int[6];
        int n = Integer.parseInt(br.readLine());

        for(int i = 0; i < 6; i++){
            sides[i] = Integer.parseInt(str[i]);
        }
        Dice dice = new Dice(sides);

        for(int i = 0; i < n; i++){
            String[] line = br.readLine().split(" ");
            int upper = Integer.parseInt(line[0]);
            int front = Integer.parseInt(line[1]);
            int cnt = 0;
            while(dice.getSide(0) != upper){
                if(cnt % 4 == 3){
                    dice.E();
                }else{
                    dice.N();
                }
                cnt++;
            }
            dice.W();
            while(dice.getSide(0) != front){
                dice.N();
            }
            sb.append(dice.getSide(4)).append("\n");
        }
        System.out.print(sb.toString());
    }
}

Measured memory_bytes: 24488
import sys
import numpy as np

n=int(sys.stdin.readline())
#n,k=map(int,sys.stdin.readline().split())
#a=np.array(sys.stdin.readline().split(),dtype='inty64')
a=np.array([sys.stdin.readline().split() for i in range(2)],dtype='int64')

p,q=a[0],a[1]


def order(x):
    dp=[0]*(n+1)
    l=list(range(1,n+1))
    for i in range(n):
        dp[i+1]=dp[i]*len(l)+l.index(x[i])
        l.remove(x[i])
    return dp[n]

print(abs(order(p)-order(q)))


Measured memory_bytes: 12512
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ff first
#define ss second
using namespace std;
const int N=2005;
const long long M=1e9+7;
typedef long long ll;
typedef long double lb;
inline void read(int &x){x=0; char ch=getchar();while(ch<'0') ch=getchar();while(ch>='0'){x=x*10+ch-48; ch=getchar();}}
//------------------------------------------head---------------------------------------------------//
int cnt[N],pr[N];
int main()
{
	int n;read(n);
	ll ans=1;
	rep(i,2,n)
	{
		int T=i; for(int j=2;j*j<=i;j++) while(T%j==0){T/=j;++cnt[j];}
		if(T>1) ++cnt[T];
	}
	rep(i,2,n) ans=ans*(ll)(cnt[i]+1)%M;printf("%d\n",(int)ans);
	return 0;
}

Measured memory_bytes: 128