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

int main() {
  bool p = false;
  for(int i=0;i<3;i++){
    char j;
    cin >> j;
    if(j=='7')
      p = true;
  }
  if(p)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

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

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
const int maxn=1000100;
int rev[maxn<<2],n,m;
struct Complex
{
	double x,y;
	Complex(){}
	Complex(double _x,double _y){x=_x;y=_y;}
	Complex operator +(const Complex &p)const{return Complex(x+p.x,y+p.y);}
	Complex operator -(const Complex &p)const{return Complex(x-p.x,y-p.y);}
	Complex operator *(const Complex &p)const{return Complex(x*p.x-y*p.y,x*p.y+y*p.x);}
}a[maxn<<2],b[maxn<<2];
inline void fft(Complex *f,int opt)
{
	for(int i=0;i<n;i++) if(i<rev[i]) swap(f[i],f[rev[i]]);
	for(int p=2;p<=n;p<<=1)
	{
		int len=p>>1;
		Complex Tmp=Complex(cos(pi/len),sin(pi/len)*opt);
		for(int k=0;k<n;k+=p)
		{
			Complex buf=Complex(1,0);
			for(int l=k;l<k+len;l++)
			{
				Complex tt=buf*f[len+l];
				f[len+l]=f[l]-tt;
				f[l]=f[l]+tt;
				buf=buf*Tmp;
			}
		}
	}
}
const int mod=200003;
int N,cnt[mod],pv[mod];
int v[mod<<2];
int main()
{
	for(int i=pv[0]=1;i<mod-1;i++) pv[i]=pv[i-1]*2%mod;
	for(int i=0;i<mod-1;i++) cnt[pv[i]]=i;
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
	{
		int x;scanf("%d",&x);
		if(x) v[cnt[x]]++;
	}
	n=mod;m=mod;
	for(int i=0;i<mod;i++) a[i].x=b[i].x=v[i];
	int Tmp=1;for(;Tmp<=n+m;Tmp<<=1);m=n+m;n=Tmp;
	for(int i=0;i<n;i++) rev[i]=(rev[i>>1]>>1)|((i&1)?n>>1:0);
	fft(a,1);fft(b,1);
	for(int i=0;i<n;i++) a[i]=a[i]*b[i];
	fft(a,-1);
	long long ans=0;
	for(int i=0;i<n;i++)
	{
		long long vi=round(a[i].x/n);
		if(i%2==0) vi-=v[i>>1];
		vi>>=1;
		ans+=1ll*pv[i%(mod-1)]*vi;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 24856
program abc140c
  implicit none
  integer :: n
  integer,dimension(:),allocatable :: a, b, c
  read *, n
  n = n - 1
  allocate(c(n))
  read *, c
  a = [c(1),c]
  b = [c,c(n)]
  print *, sum(merge(a,b,a<b))
end program abc140c


Measured memory_bytes: 640
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int ff=255;
int conv(char *str){
    int ret=0;
    for(int i=0;i<2;i++){
        int val;
        if(str[i]>='0'&&str[i]<='9')val=str[i]-'0';
        else val=str[i]-'a'+10;
        ret=(ret<<4)+val;
    }
    return ret;
}
int main(){
    char *Name[8]={"black","blue","lime","aqua","red","fuchsia","yellow","white"};
    int rgb[3][8]={{0,0,0,0,ff,ff,ff,ff},{0,0,ff,ff,0,0,ff,ff},{0,ff,0,ff,0,ff,0,ff}};
    char str[100];
    while(scanf("%s",str),str[0]!='0'){
        int rgb_[3];
        for(int i=0;i<3;i++){
            rgb_[i]=conv(str+1+i*2);
        }
        int mav,mac=1e9;
        for(int i=0;i<8;i++){
            int val=0;
            for(int j=0;j<3;j++)val+=(rgb_[j]-rgb[j][i])*(rgb_[j]-rgb[j][i]);
            if(mac>val){
                mac=val;
                mav=i;
            }
        }
        printf("%s\n",Name[mav]);

    }
    return 0;
}

Measured memory_bytes: 944
#include <bits/stdc++.h>
using namespace std;
template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  cin >> s;
  cin >> t;
  bool ok = false;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<int>());
  for(int i=0;i<s.size();i++){
    if (s[i] < t[i]){
      ok = true;
      break;
    }
    else if(s[i] > t[i]){
      break;
    }
    if(i == s.size()-1 && s.size() < t.size()) ok = true;
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

using namespace std;

int main(){
   int a,b,c,d,x,y;
   cin>>a>>b>>c>>d;
   y=a*b;
   x=c*d;
   if(y>x){
    cout<<y<<endl;
    return 0;
}
   if(x>y){
    cout<<x<<endl;
       return 0;
}
   else
    cout<<x<<endl;
    return 0;
}


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

signed main() {
    string s;
    cin >> s;
    ll ans = 0;
    vi a(s.length()+1);
    for(int i = 0; i < s.length(); i++){
        if(s[i] == '<'){
            a[i+1] = max(a[i+1], a[i]+1);
        }
    }
    cout << endl;
    for(int i = s.length()-1; i >= 0; i--){
        if(s[i] == '>'){
            a[i] = max(a[i+1]+1, a[i]);
        }
    }
    rep(i, a.size()){
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5864
# https://atcoder.jp/contests/abc131/tasks/abc131_d

import sys
# sys.setrecursionlimit(100000)
import heapq


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    """
    締切がはやい順に仕事を行う。
        全て完了できれば: Yes
        できなければ: No
    """
    n = input_int()
    hq = []
    for _ in range(n):
        a, b = input_int_list()
        heapq.heappush(hq, (b, a))
    t = 0
    while hq:
        b, a = heapq.heappop(hq)
        t += a
        if t > b:
            print("No")
            return
    print("Yes")
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 93932
#include <iostream>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a > b) {
    int swap = a;
    a = b;
    b = swap;
  }
  if (b > c) {
    int swap = b;
    b = c;
    c = swap;
  }
  if (a > b) {
    int swap = a;
    a = b;
    b = swap;
  }
  cout << a << " " << b << " " << c << endl;
  return 0;
}


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

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(0);    
    cin.tie(0);
    int n,k;
    cin>>k;
    string s,c;
    cin>>s;
    int l=s.length();
    if(l>k)
    {
    	for(int i=0;i<k;i++)
    	{
    		c+=s[i];
    	}
    	c+='.';
    	c+='.';
    	c+='.';
    	cout<<c;

    }
    else
    {
    	cout<<s;
    }
  }		


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    int a[n - 1], b[n - 1];
    rep(i, 0, n - 1) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }
    set<int> usedcolor;
    map<pair<int, int>, int> mp;
    queue<pair<int, int>> que;
    que.push({-1, 0});
    bool visited[n] = {};
    while (!que.empty()) {
        int p = que.front().first;
        int v = que.front().second;
        que.pop();
        visited[v] = true;
        int pc = 0;
        if (v != 0) pc = mp[{p, v}];
        int c = 0;
        for (auto nv : g[v]) {
            if (visited[nv]) continue;
            if (v == 0) {
                mp[{v, nv}] = c;
                usedcolor.insert(c);
                c++;
            } else {
                if (c == pc) c++;
                mp[{v, nv}] = c;
                usedcolor.insert(c);
                c++;
            }
            que.push({v, nv});
        }
    }

    cout << usedcolor.size() << endl;
    rep(i, 0, n - 1) {
        cout << mp[{a[i], b[i]}] + 1 << endl;
    }
    return 0;
}


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

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

    string in; cin >> in;
    int n = (int)in.size();

    int m = 'z' - 'a' + 1;
    vll hist(m);
    for(auto& e : in) hist[e - 'a']++;

    ll res = 1;
    for(auto& e : in){
        int c = e - 'a';

        rep(i, m){
            if(i == c) continue;
            res += hist[i];
        }
        hist[c]--;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 720
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

const long long mod = pow(10, 9) + 7;

int main() {
	int N,ma=0; cin >> N;
	vector<string> S(N),M;
	map<string, int> T;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
		T[S[i]]++;
	}
	for (int i = 0; i < N; i++) ma = max(T[S[i]], ma);
	for (int i = 0; i < N; i++) {
		if (T[S[i]] == ma) {
			M.push_back(S[i]); T[S[i]] = 0;
		}
	}
	sort(M.begin(), M.end());
	for (int i = 0; i < M.size(); i++) cout << M[i] << endl;
}





Measured memory_bytes: 28404
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<vector<int>>adj(n, vector<int>(n));
	for (int i = 0;i < n;i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0;j < k;j++) {
			int v;
			cin >> v;
			adj[u - 1][v - 1] = 1;
		}
	}
	for (int i = 0;i <n;i++) {
		for (int j = 0;j <n;j++) {
			if (j == 0) {
				cout << adj[i][j];
			}
			else {
				cout << " " << adj[i][j];
			}

		}
		cout << endl;
	}

}

Measured memory_bytes: 3148
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace __gnu_pbds;
using namespace std;
typedef tree<
ll,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
struct Node
{
    ll pos, val, color;
    bool operator<( const Node &A) const
    {
        return A.val > val;
    }
};


int main()
{
    ll n, m, k, t;
    cin>>m>>n;
    if(m > n) puts("safe");
    else puts("unsafe");
    return 0;
}



Measured memory_bytes: 3628
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if(s.charAt(0) != s.charAt(1) && s.charAt(0) != s.charAt(2) && s.charAt(1) != s.charAt(2)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 22480
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		String alp = "abcdefghijklmnopqrstuvwxyz";
		int [] count = new int[26];
		Scanner sc = new Scanner(System.in);
		String in = sc.nextLine();
		char[] cArray = in.toCharArray();
		for (int i = 0; i < cArray.length;i++){
			String a = Character.toString(cArray[i]);
			int pos = alp.indexOf(a);
			count[pos] = count[pos] + 1;
		}

		boolean result = true;
		for (int i = 0; i < count.length;i++){
			if (count[i] >= 2){
				result = false;
				break;
			}
		}
		if (result) {
			System.out.println("yes");
		} else {
			System.out.println("no");

		}

		sc.close();
	}



}


Measured memory_bytes: 22740
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// 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>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    string s;
    cin >> s;

    for(int i=0; i<3; i++){
        if(s[i] == '1')
            s[i] = '9';
        else
        {
            s[i] = '1';
        }
        
    }


    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  string S, T;
  while (cin >> N >> S >> T) {
    for (int i = 0; i < N; i++) {
      cout << S[i] << T[i];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

int main() {
	ll N; cin >> N;
	ll a[100100];
	REP(i, N)cin >> a[i];
	ll ans = 0;
	for (int i = 0; i < N-1; ++i) {
		if (a[i] % 2 == 0) {
			ans += a[i] / 2;
		}
		else {
			ans += a[i] / 2;
			if (a[i + 1] != 0) {
				ans++;
				a[i + 1]--;
			}
		}
	}
	ans += a[N - 1] / 2;
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin>>n;
    vector<int>v(n);
    for (int i = 0; i < n; ++i) {
        cin>>v[i];
    }
    bool ok = true;
    for (int i = 1; i < n; ++i) {
        if(v[i]<v[i-1]){
            ok  = false;
            break;
        }
        if((v[i]-1)>=v[i-1])v[i]-=1;
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {
			int n = sc.nextInt();
			if (n == 0) break;
			long mss = Long.MIN_VALUE, s = 0;
			for (int i = 0; i < n; i++) {
				s += sc.nextInt();
				if (mss < s) mss = s;
				if (s < 0) s = 0;
			}
			System.out.println(mss);
		}

	}

}

Measured memory_bytes: 26388
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>

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

using namespace std;
int mod = 1000000007;

int N;
vector<int> A;

int main() {
  cin >> N;
  ll sum = 0;
  rep(i, N) {
    int a;
    cin >> a;
    sum += a;
    A.push_back(a);
  }
  sort(A.rbegin(), A.rend());

  rep(i, N) {
    int now = A.at(i);
    sum -= A.at(i);
    if ((ll)A.at(i) > sum*2) {
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << N << endl;
}

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

int main()
{
   std::string s;
   cin >> s;
   bool b = true;
   if(s.size()%2 != 0){
               cout << "No" << endl;
               return 0;
   }
   for(int i=0; i<s.size(); i++){
       if(b == true){
           if(s[i]!='h'){
               cout << "No" << endl;
               return 0;
           }
        }else{
           if(s[i]!='i'){
               cout << "No" << endl;
               return 0;
           }
        }
        b = !b;
   }
   cout << "Yes" << endl;
   return 0;
}

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

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

  int ap[n];
  for(int i = 1; i <= n; i++) ap[i] = l+i-1;

  int left = -1000, right = 1000, sum = 0;
  for(int i = 1; i <= n; i++) {
    if(ap[i] < 0 && left < ap[i]) left = ap[i];
    else if(right > ap[i]) right = ap[i];

    sum += ap[i];
  }

  if(0 - left < right) cout << sum - left;
  else cout << sum - right;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int x,y;
  cin >> x >> y;
  if(y%2==1||x*2>y||x*4<y)cout << "No" << endl;
  else cout << "Yes" << endl;
}   


Measured memory_bytes: 3652
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1000000007;

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

  vector<int> a(n + 1, 0);
  // 1-index で受け取る
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }

  // dp[i][j] := i番目の人まででj個のアメちゃんを分けるときの場合の数
  vector<vector<long long>> dp(n + 10, vector<long long>(k + 10, 0));

  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    // dp_sum[x] := sum(dp[i-1][y]) (y: 0->x-1)
    vector<int> dp_sum(k + 10, 0);
    for (int j = 0; j <= k; j++) {
      dp_sum[j + 1] += dp_sum[j] + dp[i - 1][j];
      dp_sum[j + 1] %= MOD;
    }
    for (int j = 0; j <= k; j++) {
      dp[i][j] = dp_sum[j + 1] - dp_sum[max(0, j - a[i])];
      dp[i][j] %= MOD;
    }
  }

  if (dp[n][k] < 0) {
    dp[n][k] += MOD;
  }
  cout << dp[n][k] << endl;

  return 0;
}

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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"

int main(){
	lli n,k;
	cin>>n>>k;
	cout<<min(n%k, k-(n%k));

	//system("pause");
}

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

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

typedef long long ll;
using namespace std;

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

  int H, A, ans;
  cin >> H >> A;

  ans = H / A;
  if (H % A > 0) {
    ++ans;
  }

  cout << ans << endl;

  return 0;
}


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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL


int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vi low (n);
	vi mid (n);
	vi up (n);
	for(int i = 0; i < n; i++) {
		cin >> low[i];
	}
	for(int i = 0; i < n; i++) {
		cin >> mid[i];
	}
	for(int i = 0; i < n; i++) {
		cin >> up[i];
	}
	sort(low.begin(),low.end());
	sort(mid.begin(),mid.end());
	sort(up.begin(),up.end());
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		int md = mid[i];
		auto lowpos = lower_bound(low.begin(),low.end(),md);
		ll cnt = lowpos-low.begin();
		auto uppos = upper_bound(up.begin(),up.end(),md);
		//cout << up.end()-uppos << " " << lowpos-low.begin() << endl;
		cnt *= up.end()-uppos;
		ans+= cnt;
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 1408
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


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


N = int(input())
A = list(map(int, input().split()))
L = [0]*(N+1)
R = [0]*(N+1)

for i in range(N):
    L[i+1] = gcd(L[i], A[i])

for i in reversed(range(N)):
    R[i] = gcd(R[i+1], A[i])

ans = max([gcd(x, y) for x, y in zip(L, R[1:])])
print(ans)


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

typedef long long ll;

ll value(string& s, vector<bool>& plus) {
	ll num = 0;
	ll tmp = s.at(0) - '1' + 1;
	for (int i = 0; i < s.size() - 1; i++) {
		if (plus.at(i)) {
			num += tmp;
			tmp = s.at(i + 1) - '1' + 1;
		}
		else {
			tmp = tmp * 10 + s.at(i + 1) - '1' + 1;
		}
	}
	num += tmp;
	return num;
}

void calc(ll &total, string& s, vector<bool> &plus, int i) {
	if (i == s.size() - 1) {
		total += value(s, plus);
		return;
	}
	plus.at(i) = true;
	calc(total, s, plus, i + 1);
	plus.at(i) = false;
	calc(total, s, plus, i + 1);
}

int main() {
	string S;
	cin >> S;
	int N = S.size();
	vector<bool> plus(N, false);
	ll answer = 0;
	calc(answer, S, plus, 0);
	cout << answer << endl;
}



Measured memory_bytes: 256
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N, T = gets_i_list
t_list = gets_i_list

total_time = 0
end_time   = 0

t_list.each do |t|
  if end_time > t
    total_time += T - (end_time - t)
  else
    total_time += T
  end
  end_time = t + T
end

puts total_time


Measured memory_bytes: 18168
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> d(n);
	for(int i=0;i<n;i++)
		cin >> d[i];
	sort(d.begin(),d.end());

	cout << d[n/2]-d[n/2-1] << endl;




}

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

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    string a, b, c;
    int aa = 0, bb = 0, cc = 0;
    cin >> a >> b >> c;
    char before = 'a';
    char ans;
    while(true) {
        if (aa == a.size() && before == 'a') {
            ans = 'A';
            goto last;
        }
        else if (bb == b.size() && before == 'b') {
            ans = 'B';
            goto last;
        }
        else if (cc == c.size() && before == 'c') {
            ans = 'C';
            goto last;
        }
        if (before == 'a') {
            before = a.at(aa);
            aa++;
        }
        else if (before == 'b') {
            before = b.at(bb);
            bb++;
        }
        else if (before == 'c') {
            before = c.at(cc);
            cc++;
        }
    }
    last:
    cout << ans << endl;
}

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

int main() {
    long int h;
    cin >> h;

    long double m_double = log2(h);
    long int m = m_double;

    long double c = 0;

    for(int i=0;i<=m;i++){
        c += powl(2.0,(long double)i);
    }

    long int c_int = c;
    cout << c_int << endl;
}


Measured memory_bytes: 256
#define dbg(...) "amit_dwivedi"
#define db(...)  "Too OP"
#include "bits/stdc++.h"        
using namespace std;using ll=long long;
ll n,m,L,R;
const int mod = 1e9+7;

void sol(){
    int n,k;
    cin>>n>>k;
    bool snuke[n+1] = {0};
    for(int i = 0,temp; i <k;i++){
        cin>>temp;
        for(int j=0,l; j<temp; j++) {
            cin>>l;
            snuke[l] = true;
        }
    }
    int ans = 0;
    for(int i=1; i<=n; i++) {
        ans += (!snuke[i]);
    }
    cout << ans << endl;

}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);
    // int t;cin>>t;while(t--)
    sol();
}
 

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

int main() {
  ios::sync_with_stdio(false);

  int X, N;
  cin >> X >> N;

  vector<int> ng(200);
  for (int i = 0; i < N; ++i) {
    int p;
    cin >> p;
    ng[p] = 1;
  }

  vector<int> P;
  for (int i = -500; i < 500; ++i) {
    if (i < 0 || !ng[i]) P.push_back(i);
  }

  pair<int, int> r(abs(X - P[0]), P[0]);
  for (int i = 0; i < P.size(); ++i) {
    r = min(r, make_pair(abs(X - P[i]), P[i]));
  }

  cout << r.second << endl;

  return 0;
}



Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int ans;
int ans2;
int N;
int x, y, b, p;
int flag;

int main(){
	cin >> N;
	for (int i = 0; i < N; i++){
		cin >> x >> y >> b >> p;
		ans = x*b + y*p;
		if (b < 5 && p < 2){
			ans2 = x * 5 + y * 2;
		}
		else if (b < 5){
			ans2 = x * 5 + y*p;
		}
		else if (p < 2){
			ans2 = x*b + y * 2;
		}
		else{
			ans2 = x*b + y*p;
		}

		ans2 = ans2 - (ans2*0.2);
		if (ans > ans2){
			ans = ans2;
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = max(a*b, c*d);
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#define MAX 20
#define INF 1000000
using namespace std;

struct Eg{
	int from;
	int to;
	int time;
//	int kind; //1なら親、-1なら子
};

int SB[MAX];//こいつらグローバル
int SG[MAX];

Eg br[MAX];

int counter=0,flag=0;
int ans[1000];

int solve_back(int n,int N){//出発点,Eg本数+1 //メモ化
	if(SB[n]!=INF) return SB[n];
	int X=0;
	bool check=false;
	for(int i=0;i<N-1;i++){
		if(br[i].from==n) { check=true;
			X+=(solve_back(br[i].to,N)+br[i].time*2);
		}
	}
	if(check) {SB[n]=X; return X;}//子を持つとき
	else for(int i=0;i<N-1;i++){
		if(br[i].to==n) {SB[n]=br[i].time*(-2); return SB[n];}
	}
	return 0; 
}

int solve_gone(int n,int N){//出発点,Eg本数+1 //メモ化
	if(SG[n]!=INF) return SG[n];//メモされているとき
	
	
	int count=0;//countは子の数
	for(int i=0;i<N-1;i++){
		if(br[i].from==n) count++;
	}
	
	if(count==0) for(int i=0;i<N-1;i++){
		if(br[i].to==n) {SG[n]=br[i].time*(-1); return SG[n];}//子を持たないとき
	}
	
	
	int min=INF;//子を持つとき
	for(int k=1;k<count+1;k++){
		int ct=k,X=0;
		for(int i=0;i<N-1;i++){
			if(br[i].from==n) {
				ct--;
				if(ct==0) X+=(solve_gone(br[i].to,N)+br[i].time*1);
				else	X+=(solve_back(br[i].to,N)+br[i].time*2);
			}
		}
		if (min>X) min=X;
	}
	SG[n]=min; return SG[n];
}



void solve (){
	int N;
	cin >>N;
	if(N==0) {flag=1; return;}
	//Eg br[MAX];//橋の情報(N-1本しか無い)
	//int F[MAX][MAX]={0};//島ごとの橋の情報管理、0で初期化
	int dis[MAX];//根からの次数
			
	for(int i=0;i<N-1;i++){//入力
		int a,b,t;
		cin >>a>>b>>t;
		br[i].from=--a;//番号をずらす
		br[i].to=--b;
		br[i].time=t;
	//	F[a][b]=F[b][a]=t;
	}
	
	//木として扱いたい,根からの距離必要
	for(int i=1;i<N;i++){
		dis[i]=INF;
	}
	dis[0]=0;//
	while(true){
		bool update=false; //updateあればtrue
		
		for(int j=0;j<N-1;j++){//エッジでまわす
			Eg es=br[j];
			if(dis[es.from]!=INF && 
						dis[es.to]>dis[es.from]+1){
				dis[es.to]=dis[es.from]+1;
				update=true;
			}
		}
		for(int j=0;j<N-1;j++){//エッジでまわす
			Eg es=br[j];
			if(dis[es.to]!=INF && 
						dis[es.from]>dis[es.to]+1){
				dis[es.from]=dis[es.to]+1;
				update=true;
			}
		}
		
		if(!update) break;
	}
	
	for(int j=0;j<N-1;j++){//fromとtoの関係を直す
		if (dis[br[j].from]>dis[br[j].to]){
			int x;
			x=br[j].from; br[j].from=br[j].to; br[j].to=x;
		}
	}
	
	//disは用済み
	for (int i=0;i<MAX;i++){
		SB[i]=SG[i]=INF;
	}
	ans[counter]=solve_gone(0,N);
	counter++;
}
	
	
int main(){
	while(flag==0){
		solve();}
	
	for(int i=0;i<counter;i++)
	cout << ans[i]<<"\n";
}
	

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    cout << min((N + (H - 1)) / H, (N + (W -1))/W) << endl;
}

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

using ll = long long;
using ld  = long double;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll)(n) ; i++ )
#define DREP(i,m,n) for(ll i=(ll)(m) ; i > (ll)(n) ; i-- )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //




// --------- library end - //


int main(){

  ll N = il();

  vector<ll> fib(N+1, 0);
  fib[0] = 1;

  if (N != 0){
    fib[1] = 1;
    REP(i, 2, N+1){
      fib[i] = fib[i-1] + fib[i-2];
    }
  }

  cout << fib[N] << endl;

}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
map<int,int> ma;
int main() 
{
	int a[200005];
	int n;
	cin>>n;
	for(int i=2;i<=n;i++)
	{
		int x;
		cin>>x;
		ma[x]++;
	}
	for(int i=1;i<=n;i++)
		cout<<ma[i]<<endl;
}

Measured memory_bytes: 13008
import * as fs from 'fs'

const input = fs.readFileSync('/dev/stdin', 'utf8');
const args = input.split('\n').map(l => l.split(' '));

const s = args[0][0];
const t = args[1][0];

const flag = induceFromAlphabets(s, t) && induceFromAlphabets(t, s);

const msg = flag ? 'Yes' : 'No';

console.log(msg);

function induceFromAlphabets(s: string, t: string): boolean {
  const d: { [s: string]: string } = {};

  for (let i = 0; i < s.length; i++) {
    if (typeof d[s[i]] === 'undefined') {
      d[s[i]] = t[i];
      continue
    }

    if (d[s[i]] !== t[i]) {
      return false
    }
  }

  return true
}


Measured memory_bytes: 7372
#include<iostream>
using namespace std;
#define ll long long
#include<bits/stdc++.h>
int main(){
  string s;
  cin>>s;
  int n=s.size();
  string l=s;
  reverse(l.begin(),l.end());
  string p=s.substr(0,n/2);
  string q=p;
  reverse(p.begin(),p.end());
  string r=s.substr((n/2)+1);
  string t=r;
  reverse(r.begin(),r.end());
  if(l==s and p==q and r==t)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
const int mxN=4e3+10,M=1e9+7;
int fat[mxN],inv[mxN];
int n,k,temp;
int mod(int a,int M){int ret=a%M;if(ret<0)ret+=M;return ret;}
int exp(int a,int b,int M){
    if(b==0LL)return 1LL;
    if(b==1LL)return mod(a,M);
    int t=exp(a,b/2,M);
    if(b&1)return mod(a*mod(t*t,M),M);
    return mod(t*t,M);
}
int C(int n,int k){
    if(n-k<0)return 0;
    return mod(fat[n]*mod(inv[k]*inv[n-k],M),M);
}

// LONG LONG CASE
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>k;
    fat[0]=inv[0]=1LL;
    for(int i=1;i<=mxN;i++){
        fat[i]=mod(fat[i-1]*i,M);
    }
    inv[mxN-1]=exp(fat[mxN-1],M-2,M);
    for(int i=mxN-2;i>=1;i--){
        inv[i]=mod(inv[i+1]*(i+1),M);
    }
    for(int i=1;i<=k;i++){
        cout<<mod(C(k-1,k-i)*C(n-k+1,i),M)<<"\n";       
    }
}

Measured memory_bytes: 384
//include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
   int n;
   while(cin >> n && n){
      vi a(n);
      rep(i,n){
         cin >> a[i];
      }
      string s;
      cin >> s;
      rep(i,s.size()){
         rep(j,a[i%n]){
            s[i]--;
            if(s[i]<'A') s[i]='z';
            else if(s[i]<'a'&&s[i]>'Z') s[i]='Z';
         }
      }
      cout << s << endl;
   }
}

Measured memory_bytes: 1208
#include"stdio.h"
#include"string.h"
#include"algorithm"
   using namespace std;
int dp[200000];
int main()
{
   char str[200000];
   int N,Q;
   scanf("%d%d",&N,&Q);
   scanf("%s",str);
   int sum=0;
   memset(dp,0,sizeof(dp));
   for(int i=1;i<N;i++)
   {
       if(str[i-1]=='A'&&str[i]=='C')
           {
               dp[i]=sum+1;
               sum=dp[i];
           }
       else
         dp[i]=dp[i-1];
   }
   while(Q--)
   {
       int x,y;
       scanf("%d%d",&x,&y);
       x--;y--;
       printf("%d\n",dp[y]-dp[x]);
   }
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;

const int inf = 1e9;

void show(const VI &v1, const VI &v2) {
	for (int i = 0; i < v1.size(); i++) {
		printf("%d: %d %d\n", i+1, v1[i], v2[i]);
	}
}

VI make_dist(int st, const VVI &connect) {
	int n = connect.size();
	VI dist(n, inf);
	queue<int> que;
	que.push(st);
	dist[st] = 0;

	while (!que.empty()) {
		auto x = que.front();
		que.pop();

		for (auto y: connect[x]) {
			if (dist[y] == inf) {
				dist[y] = dist[x] + 1;
				que.push(y);
			}
		}
	}
	return dist;
}

int main() {
	int n, u, v, a, b;
	cin >> n >> u >> v;
	u--;
	v--;

	VVI connect(n);
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b;
		a--;
		b--;
		connect[a].push_back(b);
		connect[b].push_back(a);
	}

	int pos_t = u;
	int pos_a = v;
	auto dist_t = make_dist(pos_t, connect);
	auto dist_a = make_dist(pos_a, connect);

	// show(dist_t, dist_a);

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (dist_t[i] < dist_a[i]) {
			ans = max(ans, dist_a[i]);
		}
	}

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


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;

    vector<int> c(N);

    for (int i = 0; i < N; i++) {
        cin >> c[i];
    }

    sort(c.begin(), c.end(), greater<int>());

    int a = 0, b = 0;
    for (int i = 0; i < N; i++) {
         ((i & 1) ? a : b) += c[i];
    }
    cout << abs(a-b) << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace abc161
{
    class Program
    {
        static void Main()
        {
            var nk = Console.ReadLine().Split(' ');
            var n = long.Parse(nk[0]);
            var k = long.Parse(nk[1]);
            var minn = long.MaxValue;
            if (n >= k)
            {
                var ndivk = n % k;
                minn = ndivk < (k - ndivk) ? ndivk : k - ndivk;
            }
            else
            {
                minn = n < (k - n) ? n : k - n;
            }
            Console.WriteLine(minn);
        }
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <stdio.h>
#include <set>
#include <string.h>

typedef long long ll;

using namespace std;

int main() {
    std::ios::sync_with_stdio(false);
    int n; cin>>n; n*=2;
    vector<int> input(n); for (int i=0; i<n; i++) cin>>input[i];
    sort(input.begin(), input.end());

    int ans=0;
    for (int i=0; i<n; i+=2) ans+=input[i];
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
c = [0]
for i in range(1, 1000):
    c.append(c[i-1]+i)
    if c[i-1]-a > 0:
        ans = c[i-1]-a
        if a+ans == c[i-1] and b+ans == c[i]:
            break
        else:
            ans = 0
print(ans)


Measured memory_bytes: 3060
(defun main ()
  (let* ((h (read))
         (w (read))
         (k (read))
         (s (make-array (list h w) :initial-element 0))
         (c (make-array '(10 1000)))
         (inf 1001001001)
         (ans inf))
    (dotimes (i h)
      (let ((line (read-line)))
        (dotimes (j w)
          (if (char= (aref line j) #\1)
              (setf (aref s i j) 1)))))
    (dotimes (div (ash 1 (1- h)))
      (let ((g 0)
            (id (make-array h)))
        (dotimes (i h)
          (setf (aref id i) g)
          (if (= 1 (logand (ash div (- i)) 1))
              (incf g)))
        (incf g)
        (dotimes (i g)
          (dotimes (j w)
            (setf (aref c i j) 0)))
        (dotimes (i h)
          (dotimes (j w)
            (setf (aref c (aref id i) j) (+ (aref c (aref id i) j) (aref s i j)))))

        (setf num (- g 1))
        (let ((now (make-array g)))
          (labels ((add (j)
                     (dotimes (i g)
                       (setf (aref now i) (+ (aref now i) (aref c i j))))
                     (dotimes (i g)
                       (if (> (aref now i) k)
                           (return-from add nil)))
                     t))
            (dotimes (j w)
              (when (null (add j))
                (incf num)
                (dotimes (i g)
                  (setf (aref now i) 0))
                (when (null (add j))
                  (setf num inf)
                  (return))))
            (setf ans (min ans num))))))
    (format t "~d~%" ans)))

(main)


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    reverse(all(a));
    int cnt = 1;
    ll ans = a[0];
    bool ok = true;
    for(int i = 1; i < n; ++i){
        rep(j,2){
            if((cnt+1)<=(n-1)){
                ans += a[i];
                cnt++;
            }
            else {
                ok = false;
                break;
            }
        }
        if(!ok) break;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
	int l, r, d;
	cin >> l >> r >> d;
	int sol = 0;
	for(int i = l; i <= r; i++){
		if(i % d == 0) sol++;
	}
	cout << sol << '\n';
}


Measured memory_bytes: 3584
// Save Your Privacy!

#include<iostream>
#include<vector>
#include<set>
using namespace std;
int main()
{
  int N,M,K,p,l;
  while(cin>>N,N){
    vector< set<int> >member(N);
    vector<int>suspect;
    for(int i=0;i<N;i++){
      cin>>M;
      for(int j=0;j<M;j++){
        cin>>p;
	member[i].insert(p-1);
      }
    }
    cin>>K;
    vector<int>leak(K);
    for(int i=0;i<K;i++){
      cin>>l;
      leak[i]=l-1;
    }

    for(int i=0;i<N;i++){
      bool ok=true;
      for(int j=0;j<leak.size();j++){
        if(member[i].find(leak[j])==member[i].end())ok=false;
      }
      if(ok)suspect.push_back(i);
    }

    if(suspect.size()==1)cout<<suspect[0]+1<<endl;
    else puts("-1");
  }
}

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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)            \
    sort(x.begin(), x.end()); \
    x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

// ----------------------------------------------

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

    ll x;
    cin >> x;

    ll xx = 100;
    ll i = 1;

    while (1)
    {
        xx = xx * 1.01;
        debug2(xx, x);
        debug(i);
        if (xx >= x)
        {
            cout << i << endl;
            return 0;
        }
        i++;
    }

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>

//insertionsort

using namespace std;


void printA(int x[], int n){
	for(int i=0;i<n;i++){
		cout << x[i];
		if(i==n-1)cout<<"\n";
		else cout << " ";
	}
}

void swap(int *x, int *y){
	int *tmp;
	*tmp=*y;
	*y=*x;
	*x=*y;
}

int main(){
	int flag=1,n,count=0;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	while(flag){
		flag=0;
		for(int j=n-1;j>0;j--){
			if(a[j]<a[j-1]){
				swap(a[j],a[j-1]);
				flag=1;
				count++;
			}
		}
	}
	printA(a,n);
	cout << count << "\n";
	return 0;
}


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({a*c, a*d, b*c, b*d}) << endl;

	return 0;
}


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

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

    bool isApproved = true;

    int a[n];
    for (auto i= 0; i < n; i++)
    {
        cin >> a[i];

        if (a[i] % 2 == 0)
        {
            if (a[i] % 3 == 0 || a[i] % 5 == 0)
            {
                
            }
            else
            {
                isApproved = false;
                break;
            }
        }

    }

    if (isApproved)
    {
        cout << "APPROVED" << endl;
    }
    else
    {
        cout << "DENIED" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [n, m] <- getIntList
  as <- getIntList

  let th = (sum as + 4*m - 1) `div` (4*m)
      as' = filter (>= th) as
      ans = if length as' >= m then "Yes" else "No"

  putStrLn ans

Measured memory_bytes: 508