akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n';

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int count = 0;
	rep(i, n - 2) {
		if (s[i] == 'A'&&s[i + 1] == 'B'&&s[i + 2] == 'C') ++count;
	}
	cout << count;
}



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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
typedef long long ll;
const int  INF = 1000000000;
const ll INFL = 1LL << 50;
const ll MOD = 1000000007;


int main() {
	string s;
	cin >> s;
	int n = s.size();
	VVLL dp(n+3, vector<ll>(4, 0));
	dp[0][0] = 1;
	REP(i, n) {
		REP(j, 4) {
			if (s[i] == '?')dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * 3) % MOD;
			else  dp[i + 1][j] += dp[i][j];
		}
		if (s[i] == '?') {
			dp[i + 1][1] += dp[i][0] % MOD;
			dp[i + 1][2] += dp[i][1] % MOD;
			dp[i + 1][3] += dp[i][2] % MOD;
		}
		else if (s[i] == 'A') {
			dp[i + 1][1] += dp[i][0] % MOD;

		}
		else if (s[i] == 'B') {
			dp[i + 1][2] += dp[i][1] % MOD;
		}
		else {
			dp[i + 1][3] += dp[i][2] % MOD;
		}
	}
	cout << dp[n][3] % MOD << endl;
	return 0;
}

Measured memory_bytes: 7424
K=int(input())
t='7'
while int(t)<int(K):
  t+='7'
  
c=len(t)
t=int(t)
nums=[1]*K
while int(t)>0:
  t%=K
  if t==0:
    print(c)
    exit()
    
  if nums[t]==1:
    nums[t]=0
    t=10*t+7
    c+=1
  else:
    print(-1)
    exit()

Measured memory_bytes: 75460
// ###### Sat Mar 28 14:19:29 IST 2020
#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long    
#define MOD                998244353
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"  
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             (x).begin(),(x).end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int N = 2e5+7;
int tests(){ 
  int n,i;
  int k ; cin >>  k ;
  cin >> n ;
  vector <int> v(n),a(n);
  for(auto &x :v)
    cin >> x ;
  forn(i,1,n)
    a.pb(v[i]-v[i-1]);
  a.pb(v[0] + k-v[n-1]);
  for(auto &x :a)
    x = k-x ;
  sort(all(a));
  cout << a[0] << '\n';    

  return 0 ;
} 
int main(){
    I__O ;            
    int cases = 1 ; 
    // cin >> cases ;  
    while(cases--){   
    // cout << "Case #" << cases << ": ";
      tests(); 
    }
    return 0 ; 
}

// -Wall -Wextra -O2
// -pedantic -std=c++11
// -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN=1e5+5;
const ll MOD=1e9+7;
const ll MOD1=13;
ll n,k,ans=1;
vector<ll>G[MAXN];
ll mul(ll x,ll y)
{
    return x*y%MOD;
}
ll d(ll dep)
{
    if(dep==0)
    {
        return 1;
    }
    else
    {
        return 2;
    }

}
void dfs(ll u,ll pre,ll dep)
{
    ll det=0;
    for(ll i=0;i<G[u].size();i++)
    {
        ll v=G[u][i];
        if(v==pre)
        {
            det=1;
            continue;
        }
        ans=mul(ans,k-i+det-d(dep));
        dfs(v,u,dep+1);
    }
}
void solve()
{
    ans=k;
    dfs(1,0,0);
    printf("%lld\n",ans);
}
int main()
{
    scanf("%lld %lld",&n,&k);
    for(ll i=1;i<n;i++)
    {
        ll u,v;
        scanf("%lld %lld",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    solve();
}


Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main() {
    
    
    int n;
    string s;
    cin>>n>>s;
    auto p = unique(s.begin(), s.begin() + n); 
    s.resize(distance(s.begin(), p)); 
   cout<<s.length()<<endl;  
    
    
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MON 1000000007
#define INF (1LL<<60)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

class Edge{
public:
  Int from, to, rev;
  Int cost, lim;
  Edge(Int from, Int to, Int cost, Int lim = -1, Int rev = -1):
    from(from),to(to),cost(cost),lim(lim),rev(rev){}
};


class Graph{
public:
  Int n;
  Int m;
  vector<vector<Edge>> edge;
  Graph(Int n = 0):n(n),m(0){
    edge = vector<vector<Edge>>(n);
  }
  void add_edge(Int from, Int to, Int cost = 1, Int lim = -1)
  {
    if(lim == -1){
      edge[from].push_back(Edge(from, to, cost));
      return;
    }
    edge[from].push_back(Edge(from, to, cost, lim, edge[to].size()));
    edge[to].push_back(Edge(to, from, -cost, 0, edge[from].size() - 1));
  }
};

Graph g;
int n, m, r, s, t, d;
int main(){
  cin >> n >> m >> r;
  g = Graph(n);
  vector<Int> dist(n, INF);
  for(Int i = 0;i < m;i++){
    cin >> s >> t >> d;
    g.add_edge(s, t, d);
  }

  dist[r] = 0;

  for(Int i = 0;i < n+1;i++){
    for(Int node = 0;node < n;node++){
      for(auto e:g.edge[node]){
	if(dist[e.from] == INF)continue;
	if(dist[e.to] > dist[e.from] + e.cost){
	  if(i == n){
	    cout << "NEGATIVE CYCLE" << endl;
	    return 0;
	  }
	  dist[e.to] = dist[e.from] + e.cost;
	}
      }
    }
  }

  for(Int i = 0;i < n;i++){
    if(dist[i] == INF)cout << "INF" << endl;
    else cout << dist[i] << endl;
  }  
  return 0;
}


Measured memory_bytes: 3148
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(n,m);VC2(m,a,b);
  REP(i,m){
    a[i]--;
    b[i]--;
  }
  vector<S> edges(n+1);

  REP(i,m){
    edges[a[i]].insert(b[i]);
    edges[b[i]].insert(a[i]);
  }

  V v(n);
  iota(ALL(v),0);



  ll ans = 0;

  do{
    bool flag = true;
    if(v[0]!=0)continue;
    REP(i,n-1)
      if(!edges[v[i]].count(v[i+1]))
        flag=false;

    ans += flag;

  }while(next_permutation(ALL(v)));

  COUT(ans);

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;

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

int main(){
    int N, M, X, Y;
    scanf("%d %d %d %d", &N, &M, &X, &Y);
    int x[N];
    int y[M];
    int ma=-100, mi=100;
    string ans;
    rep(i, N) {
        scanf("%d", &x[i]);
        ma = (x[i]>=ma)?x[i]:ma;
    }
    rep(j, M) {
        scanf("%d", &y[j]);
        mi = (y[j]<=mi)?y[j]:mi;

    }

    ma = max(ma, X);
    mi = min(mi, Y);
    ans = (ma >= mi)? "War":"No War";
    cout << ans << endl;

    return 0;
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

template<typename V,typename T>
T find_num(V v, T num) {
    if ( find(ALL(v), num) == v.end() ) {
        return false;
    } else {
        return true;
    }
}

// π M_PI
// deg = rad*180/M_PI

int main() {
    ll n, k;
    cin >> n >> k;
    cout << min( abs(n%k), abs((n%k)-k) ) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const *argv[])
{
    size_t num = 1;
    while (true) {
        int x;
        std::cin >> x;
        if (x == 0) {
            break;
        }

        std::cout << "Case " << num << ": " << x << std::endl;
        num++;
    }
}

Measured memory_bytes: 2972
import java.util.ArrayList;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int px;
        int result;
        ArrayList inputList = new ArrayList<Integer>();

        for(int i=0; i<N; i++){
            px = Math.abs(sc.nextInt() - X);
            inputList.add(px);
        }

        result = (int) inputList.get(0);

        for(int i=1; i<inputList.size(); i++){
            result = gcd(result, (int) inputList.get(i));
        }

        System.out.println(result);
    }
    static int gcd(int x, int y){
        if(x < y) return gcd(y, x);
        if(x%y == 0) {
            return y;
        }
        return gcd(y,x%y);
    }


}

Measured memory_bytes: 50468
//#include <algorithm>
#include <array>
//#include <cassert>
//#include <cfloat>
//#include <cmath>
//#include <cstdio>
//#include <cstdlib>
//#include <deque>
#include <iostream>
//#include <limits>
//#include <map>
//#include <queue>
//#include <set>
//#include <stack>
//#include <string>
//#include <tuple>
//#include <unordered_map>
//#include <unordered_set>
//#include <vector>
using namespace std;

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

string S;

long dfs(int cur, array<char, 10> plus) {
  long result;
  if (cur >= S.size()) {
    long sum{}, num{};
    for (int i{}; i < S.size(); ++i) {
      if (plus[i] == '+') {
//        cerr << num << endl;
        sum += num;
        num = 0;
      }
      num *= 10;
      num += S[i] & 0xF;
    }
    sum += num;
//    cerr << num << endl;
    return sum;
  }
  result = dfs(cur + 1, plus);
  plus[cur] = '+';
  result += dfs(cur + 1, plus);

  return result;
}

int main() {
  cin >> S;
  array<char, 10> plus;
  cout << dfs(1, plus) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  
  string t;
  cin >> t;
  sort(t.begin(),t.end(),greater<char>());
  
  if(s < t) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> x(N), y(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
	}
	ll res = 4000000000000000000ll;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			for (int k = 0; k < N; k++) {
				for (int l = k + 1; l < N; l++) {
					ll x0 = min(x[i], x[j]), x1 = max(x[i], x[j]);
					ll y0 = min(y[k], y[l]), y1 = max(y[k], y[l]);
					int cnt = 0;
					for (int m = 0; m < N; m++) {
						if (x0 <= x[m] && x[m] <= x1 && y0 <= y[m] && y[m] <= y1) {
							cnt++;
						}
					}
					if (cnt >= K) {
						res = min(res, (x1 - x0) * (y1 - y0));
					}
				}
			}
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;

long long int a[101][2];
long long int dp[101][100001];


int main() {
    string s,t;
    cin>>s>>t;
    int sl=s.length(),tl=t.length();
    int dp[3005][3005];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=sl;i+=1){
        for(int j=1;j<=tl;j+=1){
            if(s[i-1]==t[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    char ans[3005];
    ans[dp[sl][tl]]='\0';
    int i=sl,j=tl;
    while(true){
        if(i==0||j==0){
            break;
        }
        if(s[i-1]==t[j-1]){
            ans[dp[i][j]-1]=s[i-1];
            i-=1,j-=1;
        }
        else{
           if(dp[i-1][j]>dp[i][j-1]){
               i-=1;
           } 
           else{
               j-=1;
           }
        }
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 35584
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        if (a == 0) {
            System.out.println(1);
        } else if (b == 0) {
            System.out.println(2);
        } else if (c == 0) {
            System.out.println(3);
        } else if (d == 0) {
            System.out.println(4);
        } else {
            System.out.println(5);
        }
    }
}

Measured memory_bytes: 26940
/*


*/
#include <cstdio>
#include <cctype>
#include <algorithm>
#define gc() getchar()
#define mod 1000000007
#define Mod(x) x>=mod&&(x-=mod)
typedef long long LL;
const int N=2e5+5,M=4005,D=2001;

int A[N],B[N],f[M][M],fac[N],ifac[N];

inline int read()
{
	int now=0;register char c=gc();
	for(;!isdigit(c);c=gc());
	for(;isdigit(c);now=now*10+c-'0',c=gc());
	return now;
}
inline int FP(int x,int k)
{
	int t=1;
	for(; k; k>>=1,x=1ll*x*x%mod)
		if(k&1) t=1ll*t*x%mod;
	return t;
}
#define C(n,m) 1ll*fac[n]*ifac[m]%mod*ifac[(n)-(m)]%mod

int main()
{
	int n=read(),mx=0;
	for(int i=1,x,y; i<=n; ++i)
	{
		A[i]=x=read(), B[i]=y=read(), ++f[D-x][D-y];//(-x+D,-y+D)
		mx=std::max(mx,std::max(x,y));
	}
	int lim=D+mx;
	for(int i=D-mx; i<=lim; ++i)
		for(int j=D-mx; j<=lim; ++j)
			f[i][j]+=f[i-1][j]+f[i][j-1], Mod(f[i][j]);//a little bigger

	LL ans=0;
	for(int i=1; i<=n; ++i) ans+=f[D+A[i]][D+B[i]];
	ans%=mod;

	lim=mx<<2, fac[0]=fac[1]=1;
	for(int i=2; i<=lim; ++i) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[lim]=FP(fac[lim],mod-2);
	for(int i=lim-1; ~i; --i) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
	for(int i=1; i<=n; ++i) ans-=C(A[i]*2+B[i]*2,A[i]*2);

	ans%=mod, ans*=FP(2,mod-2);
	printf("%lld\n",(ans%mod+mod)%mod);

	return 0;
}

Measured memory_bytes: 64384
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

int main () {
    deque<char> dq;
    string s;
    cin >> s;
    rep(i,s.size()) {
        dq.push_back(s[i]);
    }
    ll q, c;
    int t, f;
    char chr;
    cin >> q;
    int normal_dir = 1;
    while (q--) {
        cin >> t;
        if (t == 1) {
            normal_dir = (normal_dir + 1)%2;
        }
        else if (t==2) {
            cin >> f >> chr;
            if ((f + normal_dir)%2 == 0) {
                dq.push_front(chr);
            }
            else {
                dq.push_back(chr);
            }
        }
    }
    string res = "";
    for (const auto& v : dq) {
        res += v;
    }
    if (!normal_dir) {
        reverse(res.begin(), res.end());
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1412
using System;
using System.Linq;

class AtCoderCS {
    static void Main(string[] args) {
        int[] XY = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        int X = XY[0], Y = XY[1];

        for(int i = 0; i <= X; i++) {
            if (2 * i + 4 * (X - i) == Y) {
                Console.WriteLine("Yes");
                return;
            }
        }
        Console.WriteLine("No");
    }
}

Measured memory_bytes: 28048
program main
      implicit none
      integer :: n, k, cnt, i
      integer, allocatable :: a(:)

      read *, n
      allocate( a(n) )
      read *, a

      k = 1
      cnt = 0
      do i = 1, n
        if ( a(i) == k ) then
          k = k + 1
        else
          cnt = cnt + 1
        end if
      end do

      if ( k == 1 ) then
        print *, '-1'
      else 
        print *, cnt
      end if

end program main



Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include<string>
#include<vector>
using namespace std;

int N, K;
string S;

int main() {
	cin >> N >> K;
	cin >> S;
	vector<int> num;
	int now = 1;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == (char)('0' + now)) { cnt++; }
		else {
			num.push_back(cnt);
			now = 1 - now;
			cnt = 1;
		}
	}
	if (cnt != 0) { num.push_back(cnt); }
	if (num.size() % 2 == 0) { num.push_back(0); }

	int ans = 0;
	int left = 0, right = 0;
	int tmp = 0;
	//左端がi
	for (int i = 0; i < (int)num.size(); i+=2) {
		int Nextleft = i;
		int Nextright = min(i + (K * 2 + 1), (int)num.size());
		while (Nextleft > left) {
			tmp -= num[left];
			left++;
		}
		while (Nextright > right) {
			tmp += num[right];
			right++;
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1020
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;


public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
		
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            line=br.readLine();
            Set<Integer> set1=new HashSet<Integer>();
            Set<Integer> set2=new HashSet<Integer>();
            line=br.readLine();
            String[] str=line.split(" ");
            for(int i=0;i<str.length;i++){
            	set1.add(Integer.parseInt(str[i]));
            }
            line=br.readLine();
            line=br.readLine();
            str=line.split(" ");
            for(int i=0;i<str.length;i++){
            	set2.add(Integer.parseInt(str[i]));
            }
            int result=0;
            if(set1.size()>set2.size()){
            	Iterator it=set2.iterator();
            	while(it.hasNext()){
            		if(set1.contains(it.next())){
            			result++;
            		}
            	}
            }else{
            	Iterator it=set1.iterator();
            	while(it.hasNext()){
            		if(set2.contains(it.next())){
            			result++;
            		}
            	}
            }
            System.out.println(result);
        }
	}

}

Measured memory_bytes: 28164
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+18 + 10;

struct Panel{
	int dat[3][3];
	int nx, ny;

	bool operator < (const Panel &p) const{
		rep(i, 3)rep(j, 3)if (dat[i][j] != p.dat[i][j])return dat[i][j] < p.dat[i][j];
		return false;
	}
};

Panel up(Panel p){
	if (p.ny != 0)std::swap(p.dat[p.ny][p.nx], p.dat[p.ny - 1][p.nx]), --p.ny;
	return p;
}

Panel down(Panel p){
	if (p.ny != 2)std::swap(p.dat[p.ny][p.nx], p.dat[p.ny + 1][p.nx]), ++p.ny;
	return p;
}

Panel left(Panel p){
	if (p.nx != 0)std::swap(p.dat[p.ny][p.nx], p.dat[p.ny][p.nx - 1]), --p.nx;
	return p;
}

Panel right(Panel p){
	if (p.nx != 2)std::swap(p.dat[p.ny][p.nx], p.dat[p.ny][p.nx + 1]), ++p.nx;
	return p;
}

bool check(Panel p){
	rep(i, 3){
		rep(j, 3){
			if (p.dat[i][j] != ((j + 1) + i * 3) % 9)return false;
		}
	}
	return true;
}

typedef std::pair<Panel, int> MP;

int main(){
	Panel p;
	rep(i, 3){
		rep(j, 3){
			std::cin >> p.dat[i][j];
			if (p.dat[i][j] == 0)p.nx = j, p.ny = i;
		}
	}

	std::queue<MP> que;
	std::set<Panel> s;
	que.push(MP(p, 0));

	while (!que.empty()){
		MP p = que.front();
		que.pop();

		if (s.find(p.first) != s.end())continue;
		else s.insert(p.first);

		if (check(p.first)){
			std::cout << p.second << std::endl;
			break;
		}

		que.push(MP(up(p.first), p.second + 1));
		que.push(MP(down(p.first), p.second + 1));
		que.push(MP(left(p.first), p.second + 1));
		que.push(MP(right(p.first), p.second + 1));
	}

	return 0;
}

Measured memory_bytes: 20540
n=int(input())
a=list(map(int,input().split()))
while len(a)>1:
    m=min(a)
    def f(n):
        return n%m
    a=map(f,a)
    a=set(a)
    a.add(m)
    a.remove(0)
    a=list(a)
print(a[0])


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

const int N = 200010;
typedef long long ll;

int a[N];
ll pre[N];

int main(){
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++ i){
        scanf("%d", &a[i]);
        pre[i] = pre[i - 1] + a[i];
    }
    ll min = LLONG_MAX;
    for (int i = 2; i <= n - 2; ++ i){
        int sit1 = std::lower_bound(pre + 1, pre + i + 1, pre[i] / 2) - pre;
        ll ans1 = LLONG_MAX;
        for (int j = sit1 - 5; j <= sit1 + 5; ++ j){
            if (j >= 1 && j < i){
                ans1 = std::min(ans1, std::max(pre[j], pre[i] - pre[j]));
            }
        }
        int sit2 = std::lower_bound(pre + i + 1, pre + n + 1, pre[i] + (pre[n] - pre[i]) / 2) - pre;
        ll ans2 = LLONG_MAX;
        for (int j = sit2 - 5; j <= sit2 + 5; ++ j){
            if (j > i && j < n){
                ans2 = std::min(ans2, std::max(pre[j] - pre[i], pre[n] - pre[j]));
            }
        }
        min = std::min(min, std::max(ans1, ans2) - std::min(pre[i] - ans1, pre[n] - pre[i] - ans2));
    }
    printf("%lld\n", min);
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define fi first
#define se second
#define pb push_back
#define mp make_pair 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
#define all(x) (x).begin(),(x).end()
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define eprintf(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using vi = vector<int>;
using vll = vector<ll>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}


clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
const int N = 100100;
ll mod=1000000007;

void solve(ll a, double b){
	double ans = (double)a*(double)(b*100)/100;
	printf("%lld \n",(ll)trunc(ans));
}
void test_solution(){
		for(int i = 0; i <= 100000000; i++){
			ll a = rand()%1000000000000000;
			double b = (rand()%100)*0.1;
			eprintf("%lld %f \n", a,b);	
			solve(a,b);
		}	
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	startTime = clock();
	long double a;
	long double b;
	cin>>a>>b;
	cout<<(ll)floor(a*b)<<nl;
	return 0;
}



Measured memory_bytes: 3748
import sys
input = sys.stdin.buffer.readline

n, c = map(int, input().split())
X = [0]*n
V = [0]*n
for i in range(n):
    x, v = map(int, input().split())
    X[i] = x
    V[i] = v

from itertools import accumulate
# clock
A1 = [0]+V
A1 = list(accumulate(A1))
for i, x in enumerate(X):
    A1[i+1] -= x
#print(A1)

# counterclock
B1 = [0]+list(reversed(V))
B1 = list(accumulate(B1))
for i, x in enumerate(reversed(X)):
    B1[i+1] -= c-x
#print(B1)

import copy
MA1 = copy.copy(A1)
for i in range(1, n+1):
    MA1[i] = max(MA1[i-1], A1[i])

MB1 = copy.copy(B1)
for i in range(1, n+1):
    MB1[i] = max(MB1[i-1], B1[i])

#print(MA1)
#print(MB1)

A2 = copy.copy(A1)
for i, x in enumerate(X):
    A2[i+1] -= x
#print(A2)

B2 = copy.copy(B1)
for i, x in enumerate(reversed(X)):
    B2[i+1] -= c-x
#print(B2)

MA2 = copy.copy(A2)
for i in range(1, n+1):
    MA2[i] = max(MA2[i-1], A2[i])

MB2 = copy.copy(B2)
for i in range(1, n+1):
    MB2[i] = max(MB2[i-1], B2[i])

#print(MA2)
#print(MB2)

ans = 0
# clock > counterclock
for i in range(n+1):
    temp = MA2[i]+MB1[n-i]
    ans = max(ans, temp)
# counterclock > clock
for i in range(n+1):
    temp = MB2[i]+MA1[n-i]
    ans = max(ans, temp)
print(ans)


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

  ll n, m;
  cin >> n >> m;
  vector<ll> x(m);
  REP(i, m) cin >> x[i];
  sort(ALL(x));

  vector<ll> v;
  FOR(i, 1, m) v.push_back(x[i]-x[i-1]);
  sort(ALL(v));

  ll ret = 0;
  REP(i, m-n) ret += v[i];
  cout << ret << endl;

  return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N, M, K;
	cin >> N >> M >> K;
	vector<int64> A(N), B(M);
	for (auto&& x : A) cin >> x;
  for (auto&& x : B) cin >> x;
  A.insert(A.begin(), 0);
  B.insert(B.begin(), 0);
  REP(i, A.size()-1) A[i+1] += A[i];
  REP(i, B.size()-1) B[i+1] += B[i];
  int64 res = 0;
  int64 idx = M;
  for (int64 i = 0; i < N+1; i++) {
    while (idx > 0 && A[i] + B[idx] > K) {
      idx--;
    }
    if (A[i] + B[idx] <= K) {
      chmax(res, i + idx);
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 7948
#include<iostream>
#include<vector>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	int ans=a[n-1]-a[0];
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String S = scan.next();
        int K = scan.nextInt();
        StringBuilder sb = new StringBuilder();
        char c = S.toCharArray()[K-1];
        for(char x : S.toCharArray()) {
            sb.append(x == c ? c : '*');
        }
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 21844
#include <iostream>
  #include <algorithm>

  using namespace std;

  int main(int argc, char const *argv[])
  {
    int a, b, c;
    cin >> a >> b >> c;

    int ab = abs(a - b),
        bc = abs(b - c),
        ca = abs(c - a);

    cout << min({ab+bc, bc+ca, ca+ab}) << endl;
    return 0;
  }


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

using namespace std;


int main()
{

  int a;
  cin >> a;

  string s;
  cin >> s;

  if(a < 3200){
    cout << "red" <<endl;
  }
  else if(a >= 3200){
    cout << s << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
 int i,j,a[100],count=0,n,tmp;
 
 scanf("%d",&n);
 for(i=0;i<n;i++) scanf("%d",&a[i]);
 for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
        if(a[j]<a[j-1]){
            tmp=a[j];
            a[j]=a[j-1];
            a[j-1]=tmp;
            count++;
        }
    }
 }
 for(i=0;i<n-1;i++){
     printf("%d ",a[i]);
 }
 printf("%d\n",a[n-1]);
 printf("%d\n",count);
 return 0;
}



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

using namespace std;


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

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

namespace Main
{
    class Program
    {
        static void Main(string[] arg)
        {

            int[] nk = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int n = nk[0];
            int k = nk[1];

            int answer = n + (k / 2);

            Console.WriteLine(answer);
            Console.ReadLine();

        }
    }
}


Measured memory_bytes: 13268
import copy
loss=0
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
def warshall_floyd2(d):
    #d[i][j]: iからjへの最短距離
    ans=0
    for i in range(n):
        for j in range(n):
            flg=0
            for k in range(n):
                if i==j or j==k or k==i:
                    continue
                if d[i][j]==d[i][k] + d[k][j]:
                    flg=1
            if flg==0:
                ans+=d[i][j]
    #print(loss)
    return ans

n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
b=copy.deepcopy(a)
b=warshall_floyd(b)
#print(a)
#print(b)
flg=True
for i in range(n):
    for j in range(n):
        if a[i][j]!=b[i][j]:
            flg=False
            break
    else:
        continue
    break
if flg:
    ans=warshall_floyd2(b)
    print(ans//2)
else:
    print(-1)


Measured memory_bytes: 56284
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string str;
	while(cin >> str)
	{
	char ch[10]; for(int i=0;i<10;i++) ch[i]=str[i];
	int a[10][10]; for(int i=0;i<10;i++) a[0][i]=ch[i]-'0';
	for(int j=1;j<=9;j++)
		for(int i=0;i<10-j;i++)
			a[j][i]=(a[j-1][i]+a[j-1][i+1])%10;
	cout << a[9][0] << endl;
	}
}

Measured memory_bytes: 1180
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>

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

using namespace std;

const double EPS=1e-3;

const int N_MAX=6;

bool Gauss_Jordan(int n,const double A[N_MAX][N_MAX],const double *b,double *x){
	static double B[N_MAX][N_MAX+1];
	rep(i,n){
		rep(j,n) B[i][j]=A[i][j];
		B[i][n]=b[i];
	}

	rep(i,n){
		int piv=i;
		for(int j=i;j<n;j++) if(abs(B[j][i])>abs(B[piv][i])) piv=j;
		rep(j,n+1) swap(B[i][j],B[piv][j]);

		if(abs(B[i][i])<EPS) return false;

		for(int j=i+1;j<=n;j++) B[i][j]/=B[i][i];
		rep(j,n) if(i!=j) for(int k=i+1;k<=n;k++) B[j][k]-=B[j][i]*B[i][k];
	}

	rep(i,n) x[i]=B[i][n];
	return true;
}

int main(){
	for(int n;scanf("%d",&n),n;){
		double v[8];
		rep(i,n+3) scanf("%lf",v+i);

		int out;
		for(out=0;;out++){
			vector<int> x;
			vector<double> f;
			rep(i,n+3) if(i!=out) {
				x.push_back(i);
				f.push_back(v[i]);
			}

			double A[N_MAX][N_MAX],coe[N_MAX],b[N_MAX];
			rep(i,n+1){
				rep(j,n+1) A[i][j]=(x[i]==0&&j==0?1:pow(x[i],j));
				b[i]=f[i];
			}

			Gauss_Jordan(n+1,A,b,coe);

			double w=0;
			rep(j,n+1) w+=coe[j]*pow(x.back(),j);
			if(abs(w-f.back())<EPS) break;
		}
		printf("%d\n",out);
	}

	return 0;
}

Measured memory_bytes: 1156
(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(defparameter lst (mapcar #'parse-integer (split " " (read-line))))
(defparameter N (car lst))
(defparameter A (cadr lst))
(defparameter B (caddr lst))


(if (oddp (- A B))
    (format t "~A"  (+ 1 (floor (/ (- B A 1) 2)) (min (1- A) (- N B))))
    (format t "~A" (floor (/ (- B A) 2))))


Measured memory_bytes: 9700
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>

auto& in = std::cin;
auto& out = std::cout;

int32_t N,M;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N>>M;
	out << (((N - M) * 100 + M * 1900) << M) << endl;

	return 0;
}
#endif


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

void solve()
{
  int k,n;
  cin>>k>>n;
  vector<int>v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
    sort(all(v));
    int ans=v[0]+k-v[n-1];
    for(int i=0;i<n;i++){
        int dis=v[i+1]-v[i];
        ans=max(ans,dis);
    }
    cout<<k-ans<<endl;
}

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

        solve();

    return 0;
}



Measured memory_bytes: 3972
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import combinations
#import bisect# lower_bound etc
#import numpy as np
def run():
    A,B,C,K = map(int, sysread().split())
    ret = 0
    for i, x in zip((1,0,-1), (A, B, C)):
        tmp = min(x,K)
        K -= tmp
        ret += tmp * i
        if K == 0:break
    print(ret)
if __name__ == "__main__":
    run()

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


int main()
{
	int N;
	cin>>N;
	vector<int> D(N+1);
	D[0]=0;
	rep(i,N) cin>>D[i+1];
	sort(D.begin(),D.end());
	rep(i,N+1)
	{
		if(i%2==1)
		{
			D[i]=24-D[i];
		}
	}
	int ans=24;
	for(int i=0;i<N;i++)
	{
		for(int j=i+1;j<N+1;j++)
		{
			int diff=abs(D[i]-D[j]);
			ans=min(ans,min(diff,24-diff));
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

const int inf = 1e9;
const ll linf = 1e18;

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

    int a, b; cin >> a >> b;
    cout << (a + b + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/abc115

#define SUBMIT

#include <bits/stdc++.h>

using namespace std;

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(5 3
10
15
11
14
12
)");
#endif
    int n, k;
    in >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) in >> h[i];

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

    int ans = INT_MAX;
    for (int i = 0; i < n - k + 1; ++i) {
        ans = min(ans, abs(h[i] - h[i + k - 1]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <stdint.h>

int64_t as[100005],bs[100005];

int main(){
  int N,K;
  scanf("%d %d",&N,&K);
  int64_t sum=0;
  for(int i=1;i<=N;i++){
    int X;
    scanf("%d",&X);
    if(X>0){
      as[i]=X;
      sum+=X;
    }else{
      bs[i]=X;
    }
    as[i]+=as[i-1];
    bs[i]+=bs[i-1];
  }
  int64_t best=0;//all white
  for(int i=K;i<=N;i++){
    best=std::max(best,sum-(as[i]-as[i-K]));
    best=std::max(best,sum+(bs[i]-bs[i-K]));
  }
  printf("%ld\n",best);
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    VEC(int) A(N);
    READRANGE(A.rbegin(), A.rend());

    VEC(int) Lis;
    FOR(i, 0, N) {
        auto u = upper_bound(ALL(Lis), A[i]);
        if (u == END(Lis))
            Lis.push_back(A[i]);
        else
            *u = A[i];
    }

    cout << Lis.size() << endl;
    return 0;
};


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

int main(void)
{
    while(1) {
        string str,str1;
        cin >>str;
        if(str == "-") return 0;
        int m=0;
        cin >>m;
        for(int i=0;i<m;i++){
            int h;
            cin>>h;
            str = str.substr(h)+str.substr(0, h);
        }
        cout << str <<endl;
    }
}


Measured memory_bytes: 3148
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
#include<stdio.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}



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

    if(s=="AAA" ||s=="BBB"){
        cout  <<"No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

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

ll n, h;
ll a, b;
ll max_a;
ll ans;
priority_queue<ll> p_que;

int main()
{
    cin >> n >> h;
    while(n--) {
        cin >> a >> b;

        p_que.push(b);
        max_a = max(max_a, a);
    }

    while (h > 0 && !p_que.empty() && max_a < p_que.top()) {
        h -= p_que.top();
        p_que.pop();
        ans++;
    }

    if (h > 0) {
        ans += (h + max_a - 1) / max_a;
    }

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


Measured memory_bytes: 1400
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if i!=1:
                divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def resolve():
    N = int(input())
    divs = make_divisors(N)
    divs.sort()
    count = 0
    pdivs = []
    while divs:
        pdivs.append(divs[0])
        divs = [i for i in divs if i % divs[0] != 0]

    count = 0
    for i in pdivs:
        x = i
        while N % x ==0:
            count +=1
            N //= x
            x *= i
    print(count)
resolve()

Measured memory_bytes: 65824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
pair<ll, ll> extgcd(const ll a, const ll b)
{
    if (b == 0) { return pair<ll, ll>{1, 0}; }
    const auto p = extgcd(b, a % b);
    return {p.second, p.first - p.second * (a / b)};
}
ll inverse(const ll a) { return (MOD + extgcd(a, MOD).first % MOD) % MOD; }
int main()
{
    vector<ll> inv(2001, 0);
    for (ll i = 1; i <= 2000; i++) { inv[i] = inverse(i); }
    while (true) {
        ll N, D, X;
        cin >> N >> D >> X;
        if (N == 0 and D == 0 and X == 0) { break; }
        vector<ll> dp1(N + 1, 1), dp2(N + 1, 0);
        auto get = [&](const ll i) { return (dp1[i - 1] + MOD - (i < X ? 0 : dp1[i - X])) % MOD; };
        for (ll i = 1; i <= N; i++) {
            for (ll j = N; j >= 1; j--) { dp1[j] = get(j); }
            dp2[i] = dp1[N], dp1[0] = 0;
            for (int j = 1; j <= N; j++) { (dp1[j] += dp1[j - 1]) %= MOD; }
        }
        auto comb = [&](const ll k) {
            if ((D % MOD) < k or D < k) { return 0LL; }
            ll ans = 1;
            for (ll j = D; j > D - k; j--) { (ans *= (j % MOD)) %= MOD; }
            for (ll j = 1; j <= k; j++) { (ans *= inv[j]) %= MOD; }
            return ans;
        };
        ll ans = 0;
        for (ll i = 0; i <= N; i++) { (ans += (dp2[i] * comb(i) % MOD)) %= MOD; }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3048
s = gets.split(//).map(&:to_s)

count = Hash.new(0)
s.each do |str|
    count[str] += 1
end

d = count.values
flg = 0
d.each do |d|
    if d == 2
        flg += 1
    end
end

if flg == 2
    puts "Yes"
else
    puts "No"
end

Measured memory_bytes: 1788
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        String s = sc.next();
        
        HashMap<String, Long> h = new HashMap<>();
        
        for(int i=0; i< 1<<n; i++){
            String red = "";
            String blue = "";
            for(int j=0; j<n; j++){
                if((i&(1<<j)) > 0){
                    red += s.charAt(j);
                }else{
                    blue += s.charAt(j);
                }
            }
            String key = red+":"+blue;
            long tmp = h.getOrDefault(key, 0L);
            h.put(key, tmp+1);
        }
        
        long ans = 0;
        for(int i=0; i< 1<<n; i++){
            String red = "";
            String blue = "";
            for(int j=0; j<n; j++){
                if((i&(1<<j)) > 0){
                    red += s.charAt(2*n-1-j);
                }else{
                    blue += s.charAt(2*n-1-j);
                }
            }
            String key = red+":"+blue;
            long tmp = h.getOrDefault(key, 0L);
            ans += tmp;
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 342584