akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n; cin>>n;
  vector<int> a(n+2,0);
  for(int i=1; i<=n; ++i) cin>>a[i];
  int res=0;
  for(int i=0; i<=n; ++i) res+=abs(a[i+1]-a[i]);
  for(int i=1; i<=n; ++i) cout<<res-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1])<<endl;
  return 0;
}

Measured memory_bytes: 3764
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
x = gets.chomp.to_i
count = 0

([x/500, a].min + 1).times do |i|
  r = x - 500 * i

  ([r/100, b].min + 1).times do |j|
    if (r - 100 * j)/50 <= c
      count += 1
    end
  end
end

puts count


Measured memory_bytes: 1788
#include<cstdio>
typedef long long ll;
int x[90010],y[90010],p[90010][20];
ll s[90010][20];
int abs(int x) {return x>0?x:-x;}
int main()
{
	int n,m,d,t;scanf("%d%d%d",&n,&m,&d);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++) scanf("%d",&t),x[t]=i,y[t]=j;
	for(int i=1;i<=n*m-d;i++) p[i][0]=i+d,s[i][0]=abs(x[i+d]-x[i])+abs(y[i+d]-y[i]);
	for(int j=1;j<=17;j++)
	for(int i=1;i<=n*m;i++) p[i][j]=p[p[i][j-1]][j-1],s[i][j]=s[i][j-1]+s[p[i][j-1]][j-1];
	int q;scanf("%d",&q);
	for(;q--;)
	{
		int l,r;ll ans=0;scanf("%d%d",&l,&r);
		int g=(r-l)/d,st=l;
		for(int i=17;i>=0;i--)
		if(g>=(1<<i)) g-=(1<<i),ans+=s[st][i],st=p[st][i];
		printf("%lld\n",ans);
	}
	return 0;
} 

Measured memory_bytes: 22784
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

#include <sstream>
#include <istream>

using namespace std;

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

int main(){
	char s[100001];
	cin >> s;

	int n = strlen(s);
	int ans = 100000;
	if(n==1){
		ans = 1;
	}else{
		for(int i=1;i<n;i++){
			int tmp = 100000;
			if(s[i-1]!=s[i]){
				tmp = max(n-i,i);
			}
			ans = min(ans,tmp);
		}
	}
	if(ans==100000){
			cout << n << endl;
		}else{
			cout << ans << endl;
		}

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{
	int a, b;
	char op;
	scanf("%d %c %d", &a, &op, &b);
	while (op != '?')
	{
		switch (op)
		{
		case '+':
			printf("%d\n", a + b);
			break;
		case '-':
			printf("%d\n", a - b);
			break;
		case '*':
			printf("%d\n", a * b);
			break;
		case '/':
			printf("%d\n", a / b);
			break;
		}
			scanf("%d %c %d", &a, &op, &b);
	}
	return 0;
}



Measured memory_bytes: 2100
points = {}
loop do
  i,n = gets.split(",").map(&:to_i)
  break if i==0 && n==0
  points[i] = n
end

ranks = []
points.values.uniq.sort.reverse.each_with_index do |point,rank|
  points.select{|k,v| v==point}.keys.each do |i|
    ranks[i] = rank+1
  end
end

readlines.each do |l|
  puts ranks[l.to_i]
end

Measured memory_bytes: 6100
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
#define fi first
#define se second
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef vector<i64> vi;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  i64 ans = 0;
  i64 tmp = 0;
  string acgt = "ACGT";
  char c;
  while(cin>>c){
    bool flag = false;
    rep(i,4){
      if(c==acgt[i]){
        flag = true;
        break;
      }
    }
    if(flag){
      tmp++;
      chmax(ans,tmp);
      continue;
    }
    tmp=0;
  }
  cout << ans << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}


Measured memory_bytes: 256
n,m = map(int,input().split())
 
sc=[list(map(int,input().split())) for _ in range(m)]
 
def main():
  for i in range(10**n):
    scstr = str(i)
    f = True
    if len(scstr) == n:
      for j in range(m):
        if scstr[sc[j][0]-1] != str(sc[j][1]):
          f = False
      if f:
        print(i)
        return
  print('-1')
 
main()

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

using namespace std;

int main(){
  for(int A,B,P;cin>>A>>B>>P,A;){
    vector<int> as{0};
    for(int i=A;i<=B;i++){
      int pt=1;
      while(pt*10LL<=i){
	pt*=10;
      }
      int c=1;
      for(int j=i;j>=A;j/=10,pt/=10){
	int cs=(as[max(0,j-1-(A-1))]-as[max(0,pt-1-(A-1))]+P)%P;
	c=(c+cs)%P;
	if(j!=i){
	  int cc=(as[j-(A-1)]-as[j-1-(A-1)]+P)%P;
	  c=(c+cc)%P;
	}
      }
      c=(c+as.back())%P;
      as.push_back(c);
    }
    cout<<as.back()<<endl;
  }
}

      

Measured memory_bytes: 1864
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int h,w;
    while(cin >> h >> w && (h != 0 || w != 0))
    {
        for(int i = 0;i < h;i++)
        {
            for(int j = 0;j < w;j++)
            {
                cout << "#";
            }
            cout << "\n";
        }
        cout << "\n";
    }
    
    return 0;
}


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

int main(void)
{
    int N;
    string s;
    vector<char> vec;
    cin >> N >> s;
    
    for (int i = 0; i < s.size(); i++) {
        if (int(s[i]) + N > 90) cout << char(int(s[i]) - 26 + N);
        else cout << char(int(s[i] + N));
    }
    cout << "\n";
}


Measured memory_bytes: 3652
s = input()[::-1]
n = len(s)
words = ['maerd', 'remaerd', 'esare', 'resare']
while True:
    if s[:5] == words[0]:
        s = s[5:]
        continue
    elif s[:7] == words[1]:
        s = s[7:]
        continue
    elif s[:5] == words[2]:
        s = s[5:]
        continue
    elif s[:6] == words[3]:
        s = s[6:]
        continue
    break
print('NO' if s else 'YES')


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

int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  for(int i=0;i<n;i++)
  {
    cin>>b[i];
  }
  
  int sum=0;
  for(int i=0;i<n;i++)
  {
    if(a[i]>b[i])sum+=a[i]-b[i];
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b;
  char op;
  while(op != '?'){
    scanf("%d %c %d",&a,&op,&b);
    switch (op){
      case '+':
        printf("%d\n",a+b);
        break;
      case '-':
        printf("%d\n",a-b);
        break;
      case '*':
        printf("%d\n",a*b);
        break;
      case '/':
        printf("%d\n",a/b);
        break;
    }
  }
  return 0;
}

Measured memory_bytes: 600
# -2進数でn桁のときの取りうる最大値と最小値を返す
def cal_min_max n
  if n.even?
    max = (0..n).step(2).inject(0){|sum, i| sum + (-2) ** i}
    min = (1..n).step(2).inject(0){|sum, i| sum + (-2) ** i} + (-2) ** n
  else
    max = (0..n).step(2).inject(0){|sum, i| sum + (-2) ** i} + (-2) ** n
    min = (1..n).step(2).inject(0){|sum, i| sum + (-2) ** i}
  end
  [max, min]
end
 
n = gets.chomp.to_i
ans_hash = Hash.new{nil}

until n.zero? do
  i = Math.log(n.abs, 2).to_i
  i = if n > 0
    i.to_i.even? ? i : i + 1
  else # n < 0
    i.to_i.odd? ? i : i + 1
  end
  max, min = cal_min_max(i)
  i += 2 unless min <= n && n <= max
  ans_hash[i] = 1
  n -= (-2) ** i
end
 
digits = ans_hash.keys.max || 0
ans = "0" * (digits + 1)
ans_hash.each do |k, _v|
  ans[k] = "1"
end
 
puts ans.reverse

Measured memory_bytes: 14276
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  ll n;
  cin>>n;
  ll x=0;
  for(int i=1;i<2000000;i++)
  {
    x=(x*10+7)%n;
    if(x==0)
    {
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef tuple<int,int,int> TP;
constexpr int INF = 2e9;

int main() {
  string s;
  cin >> s;
  int K;
  cin >> K;
  int n = s.size();
  vector<vector<int>> dp(2, vector<int>(K + 2, 0));
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    vector<vector<int>> ndp(2, vector<int>(K + 2, 0));
    int c = s[i] - '0'; 
    for (int j = 0; j < 2; j++) {
      for (int d = 0; d <= (j ? 9 : c); d++) {
        for (int k = 0; k <= K; k++) {
          ndp[j | (d < c)][k + (d != 0)] += dp[j][k];
        }
      }
    }
    dp = move(ndp);
  }
  cout << dp[0][K] + dp[1][K] << endl;
  return 0;
} 

Measured memory_bytes: 3604
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    static final long MOD = (long) 1e9 + 7;

    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt(), count = 0;
	int[] occ = new int[n];
	boolean flag = true;
	for (int i = 0; i < n; i++) {
	    int x = sc.nextInt();
	    occ[x]++;
	    if ((occ[0] == 1 && (n & 1) == 0) || occ[0] >= 2 || occ[x] > 2)
		flag = false;
	    if ((x + (n - 1)) % 2 != 0)
		flag = false;
	}
	//System.err.println(Arrays.toString(occ));
//	System.err.println(flag);
	if (!flag)
	    System.out.println(0);
	else {
	    for (int i = 0; i < n; i++)
		if (occ[i] == 2)
		    count++;
	    //System.err.println(count);
	    System.out.println(BigInteger.valueOf(2).modPow(BigInteger.valueOf(count), BigInteger.valueOf(MOD)));
	}
    }

}


Measured memory_bytes: 32412
#include <iostream>

using namespace std;

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

    if ( (N[0] == N[1] && N[1] == N[2]) ||
         (N[1] == N[2] && N[2] == N[3]) )
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int top, S[1000];

void push(int x) {
	/* top?????????????????????????????????????????\ */
	S[++top] = x;
}

int pop() {
	top--;
	/* top??????????????????????´?????????? */
	return S[top+1];
}

int main(void) {
	int a, b;
	top = 0;
	char s[100];
	
	while ( scanf("%s", s) != EOF ) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		} else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		} else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}else {
			push(atoi(s));
		}
		if (getchar() == '\n') break;
	}
	printf("%d\n", pop());

	return 0;
}

Measured memory_bytes: 548
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
  
  int k, x; cin >> k >> x;
  for(int i = x - k + 1; i < x + k; i++) cout << i << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
D = list(map(int, input().split()))
dic = {}
ABCs = 0
count = 0
flag = 0

for i in range(N):
    if D[i] in dic:
        dic[D[i]] += 1
    else:
        dic[D[i]] = 1

diffs = sorted(dic.keys())

for k in range(diffs[-1]+1):
    if flag == 0:
        if ABCs == N / 2:
            count += 1
            flag += 1
    else:
        if ABCs > N / 2:
            break
        count += 1

    if k in dic:
        ABCs += dic[k]

print(count)


Measured memory_bytes: 93772
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }


int main() {
    int N,A,B,C;
    int ans=0;
    cin>>N>>B;
    rep(i,B){
        if(1+(N-1)*i>=B){
            Out(i);
            return 0;
        }
    }

    

    Out(ans);
    return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long[] sum = new long[2];
		long max = -(long) 1e18;
		int midx = -1;
		for(int i=0;i<N;i++){
			sum[i % 2] += Math.Max(0, A[i]);
			if(max < A[i]){
				max = A[i];
				midx = i; 
			}
		}
		
		int pref = sum[0] >= sum[1] ? 0 : 1;
		if(max <= 0) pref = midx % 2;
		
		List<Pair> L = new List<Pair>();
		for(int i=0;i<N;i++){
			if(i % 2 == pref){
				if(A[i] > 0 || i == midx) {
					L.Add(new Pair(A[i],2));
				} else {
					L.Add(new Pair(A[i],0));
				}
			} else {
				L.Add(new Pair(A[i], 1));
			}
		}
		
		List<int> ans = new List<int>();
		while(true){
			bool update = false;
			List<Pair> nxt = new List<Pair>();
			for(int i=0;i<L.Count;i++){
				if(update || L[i].Opt != 0){
					nxt.Add(L[i]);
				} else {
					update = true;
					if(i == 0 || i == L.Count - 1){
						ans.Add(i + 1);
					} else {
						var merge = nxt[nxt.Count - 1] + L[i + 1];
						nxt.RemoveAt(nxt.Count - 1);
						nxt.Add(merge);
						ans.Add(i + 1);
						i++;
					}
				}
			}
			L = nxt;
			if(!update) break;
		}
		while(true){
			bool update = false;
			List<Pair> nxt = new List<Pair>();
			for(int i=0;i<L.Count;i++){
				if(update || L[i].Opt != 1){
					nxt.Add(L[i]);
				} else {
					update = true;
					if(i == 0 || i == L.Count - 1){
						ans.Add(i + 1);
					} else {
						var merge = nxt[nxt.Count - 1] + L[i + 1];
						nxt.RemoveAt(nxt.Count - 1);
						nxt.Add(merge);
						ans.Add(i + 1);
						i++;
					}
				}
			}
			L = nxt;
			if(!update) break;
		}
		
		Console.WriteLine(L[0].Val);
		Console.WriteLine(ans.Count);
		Console.WriteLine(String.Join("\n", ans));
		
	}
	
	class Pair{
		public long Val;
		public int Opt;
		public Pair(long val, int opt){
			Val = val; Opt = opt;
		}
		public static Pair operator+ (Pair p, Pair q){
			return new Pair(p.Val + q.Val, p.Opt);
		}
	}
	
	
	
	int N;
	long[] A;
	public Sol(){
		N = ri();
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 18400
#include <stdio.h>
int main(void){
    int h,w,i,j;
    while(1){
        scanf("%d %d",&h,&w);
        if( h==0 && w==0)
              break;
            for(i=1; i<=h; i++){
            for(j=1; j<=w; j++){
              if((i+j)%2 == 0)
              printf("#");
             else
              printf(".");
             }printf("\n");
        }printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2088
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
int main(){
    ll n; cin>>n;
    ll sum=0;
    vl v(n+2,0);rep(i,n){cin>>v[i];sum+=v[i];}
    ll k=(sum)*2/(n*n+n);
    if((sum*2%(n*n+n))||(sum*2)/(n*n+n)==0)return puts("NO") * 0;
    vl d(n+2,0); rep(i,n){d[i]=v[i+1>n-1?0:i+1]-v[i]-k;}
    ll cnt=k;
    rep(i,n){
        if(d[i]==0)continue;
        else if(d[i]%n||d[i]/n>0)return puts("NO")*0;
        cnt+=d[i]/n;}
    if(cnt==0)puts("YES");
    else puts("NO");
    
}

Measured memory_bytes: 1792
#include<iostream>

int main()
{
    int card[4][13];

    int x,y,i,n,r;

    char c;

    // Initialize

    for (x= 0; x < 4; x++)
        for (y = 0; y< 13; y++)
            card[x][y] = 0;

    std::cin >> n;

    for (i = 0; i < n; i++) {
        std::cin >> c >> r;

        switch (c) {
        case 'S':
            card[0][r-1] = 1;
            break;
        case 'H':
            card[1][r-1] = 1;
            break;
        case 'C':
            card[2][r-1] = 1;
            break;
        case 'D':
            card[3][r-1] = 1;
            break;
        }
    }

    for (x = 0; x < 4; x++)
        for (y = 0; y < 13; y++) {
            if (card[x][y] != 1) {
                switch (x) {
                case 0:
                    std::cout << "S";
                        break;
                case 1:
                    std::cout << "H";
                        break;
                case 2:
                    std::cout << "C";
                        break;
                case 3:
                    std::cout << "D";
                        break;
                }
                std::cout << " " << (y + 1) << std::endl;
            }
        }
    return 0;
}


Measured memory_bytes: 3068
#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a+b>=b+c){
		if(b+c<=a+c){
			printf("%d",b+c);
		}else{
			printf("%d",a+c);
		}
	}else{
		if(a+b>=a+c){
			printf("%d",a+c);
		}else{
				printf("%d",b+a);
			
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		int r = Math.min(a*n, b);
		System.out.println(r);
	}
}


Measured memory_bytes: 21332
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b;
	if ((a + b) % 2 != 0) cout << "IMPOSSIBLE";
	else cout << (a + b) / 2;
}

Measured memory_bytes: 384
let k, t, ss = Scanf.scanf "%d %d %d %d %d %s" @@ fun n k r s p t -> k, t, Array.init n (fun i -> match t.[i] with 'r' -> p | 's' -> r | _ -> s)
let _ = Array.(iteri (fun i _ -> if i >= k && ss.(i - k) > 0 && t.[i] = t.[i - k] then ss.(i) <- 0) ss; fold_left (+) 0 ss) |> Printf.printf "%d\n"

Measured memory_bytes: 3456
N = int(input())

ans = 0
dic = {"A": 0, "B": 0}
dic2 = {"AB": 0, "A": 0, "B": 0}
for i in range(N):
    S = list(str(input()))
    pre = S[0]
    for j in range(1, len(S)):
        if (S[j - 1] + S[j]) == "AB":
            ans += 1
    if S[-1] == "A":
        dic["A"] += 1
    if S[0] == "B":
        dic["B"] += 1

    if S[-1] == "A" and S[0] == "B":
        dic2["AB"] += 1
    elif S[-1] == "A":
        dic2["A"] += 1
    elif S[0] == "B":
        dic2["B"] += 1

if dic2["A"] == 0 and dic2["B"] == 0:
    print(ans + max(dic2["AB"] - 1, 0))
else:
    print(ans + min(dic["A"], dic["B"]))

Measured memory_bytes: 3188
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lint;
typedef double ld;
int m, n, q;
int ans = 0;
int a[100], b[100], c[100], d[100];
vi A;

void gen(vi v){
	if((int)v.size() == n){
		int cans = 0;
		forn(i, q){
			if(v[b[i] - 1] -v[a[i] - 1] == c[i]){
				cans += d[i];
			}
		}
		ans = max(ans, cans);
	}else{
		forn(i, m){
			if(v.size() > 0 && A[i] >= v.back()){
				v.pb(A[i]);
				gen(v);
				v.pop_back();
			}
		}
	}
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
	cin >> n >> m >> q;
	forn(i, q){
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	for1(i, m)A.pb(i);
	for(int i = 1; i <= m; i++){
		vi v;
		v.pb(i);
		gen(v);
	}
	cout << ans << '\n';
    return 0;
}
// Write Here


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    unsigned long long int dp[n];
    for(int i=1;i<n;i++)
        dp[i]=1000000000;
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i+j<n)
            {
                dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
            }
        }
    }
   cout<<dp[n-1];
}


Measured memory_bytes: 1408
function Main(s) {
  s = s.split("\n");
  var a = s[1].split(" ").map(a => +a);
  s = s[0].split(" ").map(a => +a);
  var l = 0, r = 0, k = 0;
  for(var i = 1; i < s[0]; i++){
    if(i === a[k]){
      k++;
      if(i < s[2])l++;
      else r++;
    }
  }
  console.log(l < r ? l : r);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 21064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

//dp用配列準備
const int imax = 41;
const int jmax = 410;
const int kmax = 410;

int dp[imax][jmax][kmax];

int main() {

	int n, ma, mb; cin >> n >> ma >> mb;

	//dp初期化
	for (int i = 0; i < imax; i++) {
		for (int j = 0; j < jmax; j++) {
			for (int k = 0; k < kmax; k++) {
				dp[i][j][k] = INF;
			}
		}
	}

	dp[0][0][0] = 0;

	for (int i = 0; i < n; i++) {
		int a, b, c; cin >> a >> b >> c;
		for (int j = 0; j < jmax; j++) {
			for (int k = 0; k < kmax; k++) {
				if (dp[i][j][k] == INF)continue;

				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
				dp[i + 1][j+a][k+b] = min(dp[i + 1][j+a][k+b], dp[i][j][k]+c);
			}
		}
	}

	int ans = INF;

	for (int j = 1; j < jmax; j++) {
		for (int k = 1; k < kmax; k++) {
			if (j*mb == k * ma) {
				ans = min(ans, dp[n][j][k]);
			}
		}
	}

	if (ans == INF) {
		cout << "-1" << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 27264
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class DCandyDistribution {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n, m;
    cin >> n >> m;
    vector<int64_t> A(n);
    for (auto &a: A) cin >> a;
    vector<int64_t> acc(n + 1);
    acc[0] = 0;
    partial_sum(A.begin(), A.end(), acc.begin() + 1);

    int64_t ans = 0;
    map<int64_t, int64_t> C;

    for (const auto &a: acc)
        C[a % m]++;

    for (const auto& c: C)
        ans += c.second * (c.second - 1) / 2;

    cout << ans << endl;

}
};

int main() {
	DCandyDistribution solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 5760
import java.util.Scanner;                                                   

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(true){
            String a = in.nextLine();
            if(a.equals("0")){
                break;
            }
            int s = 0;
            String sary[] = a.split("");
            for (int i = 0; i < a.length(); i++){
                s += Integer.parseInt(sary[i]);
            }
            System.out.println(s);
        }
        }
}

Measured memory_bytes: 27280
from itertools import product

S = input()
n = len(S)

op = list(product(['', '+'], repeat=n - 1))

total = 0
for o in op:
    ans = S[0]
    for i in range(n - 1):
        ans += o[i] + S[i + 1]
    total += eval(ans)
print(total)

Measured memory_bytes: 3064
A, B, C, D = map(int, input().split())
mod = 998244353

dp = [[0] * (D+1) for j in range(C+1)]

dp[A][B] = 1

for i in range(A, C+1):
    for j in range(B, D+1):
        if i > A:
            dp[i][j] += dp[i-1][j] * j
        if j > B:
            dp[i][j] += dp[i][j-1] * i
        if i > A and j > B:
            dp[i][j] -= dp[i-1][j-1] * (i - 1) * (j - 1)
        dp[i][j] %= mod

print(dp[C][D])

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

int ans;
void dfs(int res, int now){
    if(now == 1){
        ans++;
        return;
    }
    for(int j = res/(now*now); j >= 0; j--){
        dfs(res-j*now*now, now-1);
    }
}

int main(){
    int n;
    while(cin >> n, n)  ans = 0, dfs(n, 17), cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3092
arr = Array.new
while line = $stdin.gets
arr << line.chomp.split(" ").map(&:to_i)
end
core = arr[1..-1]
a = Array.new(arr[0][0]).fill("k")
core.sort!
core.each{|item|
if a[item[0]-1] == "k"
    a[item[0]-1] = item[1]
elsif a[item[0]-1] != item[1]
    puts "-1"
    exit
end
}
str=""
a.each{|item|
 if item == nil or item =="k"
    str+="."
 else
    str+=item.to_s
 end
}
rp1=Regexp.new(str)
(10**arr[0][0]).times{|t|
    if rp1 =~ t.to_s
            puts t
            exit
    end
}
puts "-1"

Measured memory_bytes: 3836
fun main(args: Array<String>) {
    val a = readLine()!!
    val b = readLine()!!
    val ans = when {
        a == b -> "EQUAL"
        a.length < b.length || (a.length == b.length && a < b) -> "LESS"
        else -> "GREATER"
    }
    println(ans)
}


Measured memory_bytes: 31840
#include <bits/stdc++.h>
#define LL long long
using namespace std;
 
vector<int> bit, val;
int cnt[30];
 
int main()
{
    int n;
    scanf("%d", &n);
    val.push_back(0);
 
    for(int i = 0; i < n; i ++) {
        int x;
        scanf("%d", &x);
 
        if(x < 12)
            cnt[x] ++;
        else
            cnt[24 - x] ++;
 
    }
 
    for(int i = 0; i <= 12; i++) {
        if(cnt[i] > 2)
            return !printf("0");
        else if(cnt[i] == 2)
            val.push_back(i), val.push_back(24 - i);
        else if (cnt[i] == 1)
            bit.push_back(i);
    }
 
 
    int ans = -1;
 
    for(int i = 0; i < 1 << bit.size(); i++) {
        int cur = 100;
        for(int j = 0; j < bit.size(); j++) {
            if(i & (1 << j))
                val.push_back(bit[j]);
            else
                val.push_back(24 - bit[j]);
        }
        for(int j = 0; j < val.size(); j++) {
            for(int k = j + 1; k < val.size(); k++) {
                int t = val[j], tt = val[k];
                if(t > tt)
                    swap(t, tt);
                tt -= t;
                cur = min(cur, min(tt, 24 - tt));
            }
        }
        for(int j = 0; j < bit.size(); j++)
            val.pop_back();
        ans = max(ans, cur);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

main = do
    n <- readInt
    xs <- readInts
    let (smallest:sec:xs')  = (fromIntegral <$> sortOn id xs :: [Float])
    print $ foldl' (\a b -> (a + b) / 2) ((smallest + sec) / 2) xs'


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

using namespace std;

using ll = long long;

const int N=1e5+10;
const ll INF=1e18L+10;

int main(){
	#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);cin.tie(0);
	/*Input*/
	int n,W;
	cin >> n >> W;
	vector<int> weight(n),value(n);
	for (int i=0;i<n;i++)
		cin >> weight[i] >> value[i];
	/*Process*/
	int sum=0;
	for (int val:value)
		sum+=val;
	vector<ll> dp(sum+1,INF);
	//dp[i] : minimum weight to get value i
	dp[0]=0;
	for (int i=0;i<n;i++)
		for (int j=sum-value[i];j>=0;j--)
			dp[j+value[i]]=min(dp[j+value[i]],dp[j]+weight[i]);

	int ans=0;
	for (int i=1;i<=sum;i++)
		if (dp[i]<=(ll)W)
			ans=max(ans,i);
	cout << ans << '\n';
	//Ideas:
	
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int t = sc.nextInt();
      int a = sc.nextInt();
      int[] h = new int[n];
      double[] temp = new double[n];
      double min = 1000000;
      for(int i = 0;i < n;i++){
      	h[i] = sc.nextInt();
        temp[i] = t-h[i]*0.006;
        min = Math.min(min,Math.abs(temp[i]-a));
      }
      for(int i = 0;i < n;i++){
      	if(min == Math.abs(temp[i]-a)) System.out.println(i+1);
      }
    }
}


Measured memory_bytes: 22100
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int D = sc.nextInt();
		int T = sc.nextInt();
		int S = sc.nextInt();
		System.out.println(((double)D / S <= T) ? "Yes" : "No");
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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

Measured memory_bytes: 32456
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m,cnt=0,o,aa[220000],cntl=0,ab[220000];
pair<int,int> p[220000];
string s,ss[220000];
char c,cc[5000][5000]={};
queue<int> que;
signed main(){
    cin>>n>>m;
    if(n>m){
        cout<<"safe"<<endl;
    }else{
        cout<<"unsafe"<<endl;
    }
}


Measured memory_bytes: 10484
#include<bits/stdc++.h>
#include<string.h>
#include<cstring>
#define pb push_back
#define FAST ios::sync_with_stdio(0);cin.tie(),cout.tie();
typedef long long ll;
const long double pi = acos(-1.0);
const int mod = 1e9+7;
using namespace std;
 int is_prime(int n)
 {
     int i, root;
     if(n == 2) {
         return 1;
     }
     if(n % 2 == 0) {
         return 0;
     }
     root = sqrt(n);
     for(i = 3; i <= root; i = i + 2) {
         if(n % i == 0) {
             return 0;
         }
     }
     return 1;
 }

 int main()
 {
     int n, m,i;
         scanf("%d", &n);
         for( i=n;;i++)
         {
             if(is_prime(i))
                break;
         }

     cout<<i<<endl;
     return 0;
 }


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <functional>
#include <vector>

#define MAX_N (100)

using namespace std;

int main() {
  // read inputs
  long N, W, ws[MAX_N], vs[MAX_N];
  scanf("%ld %ld", &N, &W);
  for (int i = 0; i < N; i++) {
    scanf("%ld %ld", &ws[i], &vs[i]);
  }

  // count number of elements with each weight
  const long w0 = ws[0];
  vector<vector<long>> vss(4, vector<long>());
  for (int i = 0; i < N; i++) {
    vss[ws[i] - w0].push_back(vs[i]);
  }
  for (int k = 0; k < 4; k++) {
    sort(vss[k].begin(), vss[k].end(), greater<long>());
  }

  // search all
  long ans = 0;
  long total_v0 = 0, total_w0 = 0;
  for (int i0 = 0; i0 <= vss[0].size(); i0++) {
    total_v0 += i0 > 0 ? vss[0][i0 - 1] : 0;
    total_w0 += i0 > 0 ? w0 : 0;
    long total_v1 = 0, total_w1 = 0;
    for (int i1 = 0; i1 <= vss[1].size(); i1++) {
      total_v1 += i1 > 0 ? vss[1][i1 - 1] : 0;
      total_w1 += i1 > 0 ? w0 + 1 : 0;
      long total_v2 = 0, total_w2 = 0;
      for (int i2 = 0; i2 <= vss[2].size(); i2++) {
        total_v2 += i2 > 0 ? vss[2][i2 - 1] : 0;
        total_w2 += i2 > 0 ? w0 + 2 : 0;
        long total_v3 = 0, total_w3 = 0;
        for (int i3 = 0; i3 <= vss[3].size(); i3++) {
          total_v3 += i3 > 0 ? vss[3][i3 - 1] : 0;
          total_w3 += i3 > 0 ? w0 + 3 : 0;
          if (total_w0 + total_w1 + total_w2 + total_w3 <= W) {
            ans = max(ans, total_v0 + total_v1 + total_v2 + total_v3);
          }
        }
      }
    }
  }
  printf("%ld\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define M 100010


int main(){
    IOS;
     
    ll n;cin>>n;
    map<string,ll>mp;
    rep(i,0,n){
    	string s;cin>>s;
    	mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<"\n";
    cout<<"WA x "<<mp["WA"]<<"\n";
    cout<<"TLE x "<<mp["TLE"]<<"\n";
    cout<<"RE x "<<mp["RE"]<<"\n";
     
     
     
     
    return 0;
}


Measured memory_bytes: 3664
N = gets.to_i
A = []
N.times do
	A.push gets.to_i
end

answer = 0
(N-1).times do |i|
	if A[i] % 2 == 1 && A[i+1] > 0
		answer += 1
		A[i] -= 1
		A[i+1] -= 1
	end
	answer += A[i] / 2
	A[i] -= A[i] / 2
end
answer += A[N-1] / 2
puts answer

Measured memory_bytes: 2996
def solve():
    N = int(input())
    A_1 = list(map(int, input().split(" ")))
    A_2 = list(map(int, input().split(" ")))
    max_candi = 0
    for i in range(N):
        max_candi = max((sum(A_1[0:max(1, i)]) + sum(A_2[max(0, i-1):N])), max_candi)
    print(max_candi)
    return

solve()


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s;
	cin >> s;
	if (s.length() == 3) reverse(s.begin(), s.end());
	cout << s << "\n";
		
	return 0;
}


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

using namespace std;

#define ll  long long
#define vi  vector<int>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a/gcd(a , b))*b;
}

int main(){

  int n;
  cin >> n;
  vi v;
  for(int i = 0;i < n; i++){
    int a;
    cin >> a;
    v.pb(a);
  }
  sort(all(v));

  int amax=0;
  for(int i = 0;i < n-1; i++){
    if(amax < min(v[i], v[n-1]-v[i])) amax = v[i];
  }

  cout << v[n-1] <<' '<< amax << endl;

 return 0;
}


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

typedef long long ll;

const int M = (int)1e2;
const int inf = 0x3f3f3f3f;
const ll mod = (ll)1e9 + 7;
const double eps = 1e-8;

int main()
{
    int r; scanf("%d", &r);
    printf("%.12f\n", 2.0 * acos(-1.0) * r);
    return 0;
}


Measured memory_bytes: 3828
import numpy as np
 
s=input()
n=len(s)
MOD=1000000007
wayA=np.array([0,0,0,0],dtype=np.int64)
wayB=np.array([0,0,0,0],dtype=np.int64)
wayC=np.array([0,0,0,0],dtype=np.int64)
MOD2=np.array([MOD,MOD,MOD,MOD],dtype=np.int32)
hatena=0
for c in s:
	if c=="A":
		wayA[0]+=1
	if c=="B":
		wayB+=wayA
	if c=='C':
		wayC+=wayB
	if c=='?':
		wayC[1]=wayC[1]+wayB[0]
		wayC[2]=wayC[2]+wayB[1]
		wayC[3]=wayC[3]+wayB[2]
		wayB[1]=wayB[1]+wayA[0]
		wayB[2]=wayB[2]+wayA[1]
		wayA[1]=wayA[1]+1
		hatena+=1
	wayA%=MOD2
	wayB%=MOD2
	wayC%=MOD2
ans=0
for i in range(0,4):
	p3=1
	if wayC[i]<=0:
		continue
	for k in range(0,hatena-i):
		p3=p3*3
		p3=p3%MOD
	ans=ans+p3*wayC[i]
	ans=ans%MOD
print(int(ans))

Measured memory_bytes: 21404
#include<iostream>
#include<queue>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<functional>
#include<set>
using namespace std;
#define int long long
signed main() {
	int n, a; cin >> n >> a;
	if (n % 500 <= a)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
N = int(input())
S = input()


"""考え方
「右側のE」+「左側のW」の合計が一番小さくなるインデックスを探索する。
"""
left_w = 0
right_e = S.count('E')
ans = 10**6
## 西の端から東に向かって確認していく
for n in range(0,N):
  if S[n] == "W":
    cnt = left_w + right_e
    left_w += 1
  else:
    cnt = left_w + right_e - 1
    right_e -= 1
    
  ans = min(ans,cnt)

print(ans)

Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (u == s) a--;
	if (u == t) b--;

	cout << a << " " << b << "\n";

	return 0;
}


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

int main(){
  int A,B,sum;
  
  cin >> A>>B;
  
  if(A>=13){
  sum=B;
  }else if(A>5 && A<13){
  sum = B/2;
  }else{
    sum=0;
  }
  cout << sum <<endl;
}


Measured memory_bytes: 256
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    long long n, k;
    cin >> n >> k;
    vector<int> a(n+1);
    rep(i, n){
        cin >> a[i+1];
    }
    vector<int> num(n+1);
    rep(i, n+1){
        num[i] = -1;
    }
    long long nextIndex = 1;
    long long numValue = 0;
    while(num[nextIndex] == -1){
        num[nextIndex] = numValue;
        if(k == numValue){
            cout << nextIndex << endl;
            return 0;
        }
        numValue++;
        nextIndex = a[nextIndex];
    }
    //cout << nextIndex << numValue << num[nextIndex] << endl;
    long long remain = k - numValue;
    remain %= (numValue - num[nextIndex]);
    long long ansIndex = num[nextIndex] + remain;
    //cout << ansIndex << endl;
    rep(i, n){
        if(num[i+1] == ansIndex){
            cout << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4848
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

	vector<ll> A(N);
	rep(i, N) cin >> A[i];

	ll x = 0;

	rep(i, N)
	{
		x += A[i];
	}

	rep(i, N)
	{
		if (i % 2 == 1) x -= 2 * A[i];
	}


	cout << x << " ";

	rep(i, N - 1)
	{
		x = 2 * A[i] - x;

		cout << x << " ";
	}

	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string a, b, c;
    cin >> a >> b >> c;
    cout << (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0] ? "YES" : "NO") << endl;
}

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

template<typename F, typename T>
struct swag {
        F func;
        vector<T> front, back, front_acc, back_acc;
        swag(F _func) : func(_func) {}
        T fold_all() {
                assert(not front.empty() || not back.empty());
                if (front.empty()) {
                        return back_acc.back();
                } else if (back.empty()) {
                        return front_acc.back();
                } else {
                        return func(front_acc.back(), back_acc.back());
                }
        }
        void push(T x) {
                if (not back_acc.empty()) {
                        back_acc.push_back(func(back_acc.back(), x));
                } else {
                        back_acc.push_back(x);
                }
                back.push_back(x);
        }
        void pop() {
                if (front_acc.empty()) {
                        assert(not back.empty());
                        while (not back.empty()) {
                                T v = back.back();
                                back.pop_back();
                                back_acc.pop_back();
                                if (not front_acc.empty()) {
                                        front_acc.push_back(func(front_acc.back(), v));
                                } else {
                                        front_acc.push_back(v);
                                }
                                front.push_back(v);
                        }
                }
                front_acc.pop_back();
                front.pop_back();
        }
};

int main() {
        int n, l;
        scanf("%d%d", &n, &l);
        vector<int> a(n);
        rep(i, n) {
                scanf("%d", &a[i]);
        }
        auto f = [&](int a, int b) { return min(a, b); };
        swag<decltype(f), int> s(f);
        rep(i, l) {
                s.push(a[i]);
        }
        vector<int> ans;
        ans.push_back(s.fold_all());
        for (int i = l; i < n; i ++) {
                s.push(a[i]);
                s.pop();
                ans.push_back(s.fold_all());
        }
        rep(i, n - l + 1) {
                printf("%d%c", ans[i], i == n - l ? '\n' : ' ');
        }
        return 0;
}



Measured memory_bytes: 12628