akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std;
//関数
const long INF=1000000000000000;
const long MOD=1000000007;
bool check=false;


int main(void){
    long H,W,A,B;
    cin>>H>>W>>A>>B;
    
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cout<<((j<=A)+(i<=B))%2;
            //cout<<(i<=A)<<(j<=B)<<endl;
        }
        cout<<endl;
    }
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  vector<ll> A(N+1);
  vector<ll> B(N);
  for(int i = 0; i <= N; i++){
    cin >> A[i];
  }
  for(int i = 0; i < N; i++){
    cin >> B[i];
  }

  ll ans = 0;
  for(int i = 0; i < N; i++){
    // iさんはA[i]をできるだけ倒す
    if(A[i] >= B[i]){
      ans += B[i];
      continue;
    } else { 
      ans += A[i];
      B[i] -= A[i];

      if(A[i+1] >= B[i]){
        ans += B[i];
        A[i+1] -= B[i];
      } else { 
        ans += A[i+1];
        A[i+1] = 0;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4804
n = int(input())
l = list(map(int, input().split()))

ls = sorted(l)
k = (ls[n//2-1] + ls[n//2])/2

for i in range(n):
    if l[i] < k:
        print(ls[n//2])
    else:
        print(ls[n//2-1])

Measured memory_bytes: 25220
#include <stdio.h>

void Do(int r, int D, int x){
  int i, X;
  X = x;
  for(i = 0;i < 10;i++){
    X = r * X - D;
    printf("%d\n", X);
  }
}

int main(void){
  int r, D, x;
  scanf("%d %d %d", &r, &D, &x);
  Do(r, D, x);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX=2e5+10;
int main ()
{
    int N;cin >> N;
    vector<int>A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A.rbegin(),A.rend());
    int alice=0,bob=0,f=1;
    for(int x:A){
        if(f)alice+=x,f=0;
        else bob+=x,f=1;
    }
    cout<<alice-bob;
    return 0;
}
/*
*/





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

using namespace std;
int noOfpath(vector<vector<char>> grid,int i,int j)
{
	int mm= 1e9+7;
   int h=grid.size();
   int w=grid[0].size();
   vector<vector<int>>dp(h+1,vector<int>(w+1,0));
   dp[1][1]=1;
   for(int  i=0;i<=h;i++)
   	  {
   	  	
   	  	for(int j=0;j<=w;j++)
   	  	{
             if(i==0||j==0||grid[i-1][j-1]!='.')
             	dp[i][j]=0;
             else dp[i][j]=max((dp[i-1][j]+dp[i][j-1]) %mm ,dp[i][j]); 
   	  	}
   	  
   	  }
      return dp[h][w];
}
int main()
{
	int h,w;
	cin>>h>>w;
	vector<vector<char>> grid(h,vector<char>(w));
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			cin>>grid[i][j];
	
	cout<<noOfpath(grid,0,0);		
	return 0;	
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define Lower(a,t) lower_bound(All(a),t)
using namespace std;
void Debug(auto a);


signed main(){
    int n;
    cin >> n;
    int wa = n+1;
    if(n%2==0){
        cout << ((n-2) * n)/2 << endl;
        REP(i,n){
            REP(j,n){
                if(i>=j || i + j + 2 == wa){
                    continue;
                }
                cout << i+1 << " " << j+1 << endl;
            }
        }
    }
    else{
        int honsuu = ((n-3)*(n-1))/2 + (n-1);
        cout << honsuu << endl;
        REP(i,n){
            REP(j,n){
                if(i>=j || i + j + 2 == n){
                    continue;
                }
                cout << i+1 << " " << j+1 << endl;
            }
        }
    }
    



    return 0;
}



void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int dp[(1<<21)+5];
int com[22];

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n; cin>>n;
	For(i,0,n-1){
		int t=0,u;
		For(j,0,n-1){
			cin>>u;
			t=t*2+u;
		}
		com[i]=t;
	}
	memset(dp,0,sizeof(dp));
	dp[0]=1;
	For(i,1,(1<<n)-1){
		int cnt,t;
		for(cnt=-1,t=i;t;) { cnt+=t%2; t/=2; }
		For(j,0,n-1){
			if(i&(1ll<<j) && com[cnt]&(1ll<<j)){
				dp[i]=(dp[i]+dp[i^(1ll<<j)])%MOD;
			}
		}
	}
	cout<<dp[(1<<n)-1]<<"\n";
	return 0;
}


Measured memory_bytes: 16640
'use strict';

function main(input) {
  const args = input.split('\n');
  var results = new Map();
  var numberOfAccepted = 0;
  var numberOfPenalty = 0;
  for (let i = 1; i < args.length; ++i) {
    var argsSplit = args[i].split(' ');
    var numberOfProblem = argsSplit[0];
    var resultOfProblem = argsSplit[1];
    if (!results.has(numberOfProblem)) {
      results.set(numberOfProblem, [resultOfProblem, 0]);
      if (resultOfProblem === 'AC') {
        ++numberOfAccepted;
      }
    }
    if (results.get(numberOfProblem)[0] === 'WA') {
      var tmp = results.get(numberOfProblem)[1];
      if (resultOfProblem === 'WA') {
        results.set(numberOfProblem, ['WA', tmp + 1]);
      } else {
        ++numberOfAccepted;
        numberOfPenalty += tmp;
        results.set(numberOfProblem, ['AC', tmp]);
      }
    }
  }
  console.log(numberOfAccepted + ' ' + numberOfPenalty);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 50364
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		new Main().run();
	}
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int sTime = scan.nextInt();
			Process[] schedule = new Process[n];
			int count = n;
			int j = 0;
			int sumTime = 0;
			for(int i = 0;i < n;i++){
				schedule[i] = new Process(scan.next(),scan.nextInt());
			}
			int a = 0;
			int len = schedule.length;
			while(count > 1){
				if(count < 2*len/3 && j == len && count > 100){
					Process[] newSchedule = new Process[count];
					int k = 0;
					for(int i = 0;i < len;i++){
						if(schedule[i].getTime() == 0){
							continue;
						}
						newSchedule[k] = new Process(schedule[i].getName(),schedule[i].getTime());
						k++;
					}
					schedule = newSchedule;
					len = schedule.length;
					j = 0;
				}
				if(j >= len){
					j %= len;
				}
				a = schedule[j].getTime();
				if(a == 0){
					j++;
					continue;
				}else if(a <= sTime){
					sumTime += a;
					System.out.println(schedule[j].getName() + " " + sumTime);
					schedule[j++].setTime(0);
					count--;
					continue;
				}
				sumTime += sTime;
				schedule[j++].minusTime(sTime);
			}
			for(int i = 0;i < len;i++){
				if(schedule[i].getTime() == 0){
					continue;
				}
				System.out.println(schedule[i].getName() + " " +(sumTime+schedule[i].getTime()));
				break;
			}
		}
	}
	class Process{
		String name;
		int time;
		public Process(){
		}
		public Process(String name,int time){
			this.name = name;
			this.time = time;
		}
		public int getTime(){
			return this.time;
		}
		public void setTime(int time){
			this.time = time;
		}
		public String getName(){
			return this.name;
		}
		public void minusTime(int time){
			this.time -= time;
		}
		public void setName(String name){
			this.name = name;
		}
	}
}

Measured memory_bytes: 67924
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    ll N,A,B,val,val1,ans;
    cin >> N >> A >> B;

    val = N / (A + B);
    val1 = N % (A + B);

    ans = val * A + min(A, val1);
    cout << ans << endl;
}

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

int main(){
  int a,b;
  float t;
  cin>>a>>b>>t;
  t+=0.5;
  int ans=t/a;
  cout<<ans*b<<endl;
  
  return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];

    for(int i = 0; i < N; i++){
      A[i] = sc.nextInt();
    }

    Arrays.sort(A);
    System.out.println(A[N-1] - A[0]);
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define for(i,a,b) for(int i=a;i<=b;i++)
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
_inline void read(int &x){
	int res=0,f=1;
	char c=getchar();
	if(c=='-') f=-1;
	while(c>'9'||c<'0') c=getchar();
	while(c>='0'&&c<='9'){
		res=res*10+c-'0';
		c=getchar();
	}
	x=res*f;
}
inline void print(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
int main(){
	string s;
	cin>>s;
	int x[4];
	for(i,0,3) x[i]=s[i]-'0';
	int a=x[0],b=x[1],c=x[2],d=x[3];
	for(i,0,1){
		for(j,0,1){
			for(k,0,1){
				int sum=a;
				char ch[3];
				switch(i){
					case 0:sum+=b,ch[0]='+';break;
					case 1:sum-=b,ch[0]='-';break; 
				}
				switch(j){
					case 0:sum+=c,ch[1]='+';break;
					case 1:sum-=c,ch[1]='-';break; 
				}
				switch(k){
					case 0:sum+=d,ch[2]='+';break;
					case 1:sum-=d,ch[2]='-';break;
				}
				if(sum==7){
					printf("%d%c%d%c%d%c%d=7",a,ch[0],b,ch[1],c,ch[2],d);
					exit(0);
				}
			}
		}
	}
	exit(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

bool in(pair<int,int> v){
    return 0<=v.first&&v.first<=5000&&0<=v.second&&v.second<=5000;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n,n){
        vector<pair<int,int>> v(n);
        vector<vector<bool>> used(5050,vector<bool>(5050));
        for(int i=0;i<n;i++){
            cin >> v[i].first >> v[i].second;
            used[v[i].first][v[i].second]=true;
        }
        int res=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                int difx=v[j].first-v[i].first;
                int dify=v[j].second-v[i].second;
                pair<int,int> a,b;
                a=make_pair(v[i].first+dify,v[i].second-difx);
                b=make_pair(v[j].first+dify,v[j].second-difx);
                if(in(a)&&used[a.first][a.second]&&in(b)&&used[b.first][b.second]){
                    res=max(res,difx*difx+dify*dify);
                }
                a=make_pair(v[i].first-dify,v[i].second+difx);
                b=make_pair(v[j].first-dify,v[j].second+difx);
                if(in(a)&&used[a.first][a.second]&&in(b)&&used[b.first][b.second]){
                    res=max(res,difx*difx+dify*dify);
                }
            }
        }
        printf("%d\n",res);
    }
}


Measured memory_bytes: 6248
<?php
  $s = trim(fgets(STDIN));
  $t = trim(fgets(STDIN));
  $ans = false;
  for($i=0; $i<strlen($s); $i++){
    if($s == $t){
      $ans = true;
      break;
    }
    $t = $t[strlen($t)-1].substr($t,0,strlen($t)-1);
  }
  if($ans){
    echo "Yes\n";
  }else{
    echo "No\n";
  }

Measured memory_bytes: 4604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x,y=0;
		while(true) {
			x=sc.nextInt();
			y=sc.nextInt();
			if(x==0&&y==0)break;
			else if(x>y)System.out.println(y+" "+x);
			else if(y>x)System.out.println(x+" "+y);
			else if(x==y)System.out.println(x+" "+y);
		}
	}
}


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

int main() {
  int N;
  unsigned int diff = 0;
  unsigned long long sum = 0;
  cin >> N;
  vector<unsigned int> A(N);
  rep(i, N) cin >> A[i];

  rep(i, N) {
    if(i > 1){
      if(A[i-1] > A[i]) {
        diff = A[i-1] - A[i];
        A[i] += diff;
        sum += diff;
        diff = 0;
      } 
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3996
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 
 

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;


    ll n;
    cin>>n;

    rep(i,n){
        rep2(j,i+1,n){
            rep(bit,9){
                if( (i&(1<<bit)) != (j&(1<<bit)) ){
                    cout<<bit+1<<" ";
                    break;
                }
            }
        }
        cout<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  Cin(int, n);
  Cins(int, n, s);

  int sum = 0;
  rep(i, n) sum += s[i];

  if (sum % 10 != 0) {
    cout << sum << endl;
    return;
  }

  sort(rng(s));
  bool f = false;
  rep(i, n) {
    if (s[i] % 10 != 0) {
      f = true;
      sum -= s[i];
      break;
    }
  }
  cout << (f ? sum : 0) << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args){
        String S = in.s();
        int len = S.length();
        int[] a = new int[2019];
        a[0] = 1;
        int x = 0;
        int d = 1;
        for (int i = len - 1; i >= 0; i--) {
            int j = S.charAt(i) - '0';
            x = (j * d + x) % 2019;
            a[x]++;
            d = 10 * d % 2019;
        }
        long ans = 0;
        for (int i = 0; i < 2019; i++) {
            ans += (long)a[i] * (a[i] - 1) / 2;
        }
        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = read(cbuf, 0, cbuf.length);
            } catch (IOException e) {}
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (c != ' ' && c != '\n' && c != '\r') {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (true) {
            char c = next();
            if (c != ' ' && c != '\n' && c != '\r') {
                back();
                break;
            }
        }
    }

    char[] s(final int N) {
        skip();
        char[] s = new char[N];
        for (int i = 0; i < s.length; i++) {
            s[i] = next();
        }
        return s;
    }

    String s() {
        try {
            return readLine();
        } catch (IOException e) {
            return "";
        }
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n, q;
  string s;
  cin >> n >> q >> s;
  vi cnt(n);
  REP(i,n) {
    cnt[i] = cnt[i-1] + (s[i] == 'C' && s[i-1] == 'A');
  }
  rep(i,q) {
    int l, r;
    cin >> l >> r;
    l--; r--; 
    int ans = cnt[r] - cnt[l];
    cout << ans << endl;
  }
}

Measured memory_bytes: 1488
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[3] = {1,0,-1};
int dy[3] = {1,0,-1};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  string S;
  int s,e;
  cin >> S;
  REP(i,S.size()){
    if(S[i] == 'A'){
      s = i;
      break;
    }
  }
  REP(i,S.size()){
    if(S[S.size()-i-1] == 'Z'){
      e = S.size()-i-1;
      break;
    }
  }
  cout << (e-s+1) << endl;
  return 0;  
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<=8&&b<=8) cout<<"Yay!"<<endl;
    else cout<<":("<<endl;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
edges = Array.new(n) { Array.new }
m.times do
  a, b = gets.split.map(&:to_i).map(&:pred)
  edges[a] << b
  edges[b] << a
end
ans = 0
queue = [[0, [0]]]
until queue.empty?
  start, visited = queue.shift
  if visited.size == n
    ans += 1
    next
  end
  edges[start].each do |dest|
    if !visited.include?(dest)
      queue << [dest, [*visited, dest]]
    end
  end
end
puts ans


Measured memory_bytes: 5244
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通り実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			Path[] paths = new Path[m];
			@SuppressWarnings("unchecked")
			List<Path>[] pathLists = new List[n];
			IntStream.range(0, n).forEach(i -> pathLists[i] = new ArrayList<>());
			IntStream.range(0, m).forEach(i -> {
				paths[i] = new Path(scanner.nextInt() - 1, scanner.nextInt() - 1, scanner.nextInt());
				pathLists[paths[i].from].add(paths[i]);
				pathLists[paths[i].to].add(new Path(paths[i].to, paths[i].from, paths[i].cost));
			});
			int[][] dist = new int[n][];
			IntStream.range(0, n).forEach(i -> dist[i] = dijkstra(pathLists, i, n));
			int answer = m;
			for (Path path : paths) {
				boolean shortest = false;
				for (int j = 0; j < n; j++) {
					if (dist[j][path.from] + path.cost == dist[j][path.to]) {
						shortest = true;
					}
				}
				if (shortest) {
					answer--;
				}
			}
			System.out.println(answer);
		}
	}

	/**
	 * @param pathLists ノード間の連結パス一覧の配列
	 * @param src       開始ノード
	 * @param n         ノードの数
	 * @return 開始ノードからの距離の配列
	 */
	private static int[] dijkstra(List<Path>[] pathLists, int src, int n) {
		int[] distances = new int[n];
		Arrays.fill(distances, Integer.MAX_VALUE);
		// 最短距離が確定したかどうか
		boolean[] fixed = new boolean[n];
		Arrays.fill(fixed, false);
		// 出発地点までの距離を0とする
		distances[src] = 0;
		Queue<Path> queue = new PriorityQueue<>();
		queue.add(new Path(src, src, 0));
		while (!queue.isEmpty()) {
			int now = queue.poll().to;
			if (!fixed[now]) {
				fixed[now] = true;
				for (Path path : pathLists[now]) {
					if (!fixed[path.to] && distances[path.to] > distances[now] + path.cost) {
						distances[path.to] = distances[now] + path.cost;
						queue.add(new Path(path.to, path.to, distances[path.to]));
					}
				}
			}
		}
		return distances;
	}

	/**
	 * ノード間の一つのパスを表すクラス
	 */
	private static class Path implements Comparable<Path> {
		/** 開始ノード */
		int from;
		/** 終了ノード */
		int to;
		/** 移動コスト */
		int cost;

		Path(int from, int to, int cost) {
			super();
			this.from = from;
			this.to = to;
			this.cost = cost;
		}

		@Override
		public int compareTo(Path path) {
			return this.cost - path.cost;
		}
	}
}


Measured memory_bytes: 30940
N = int(input())
S = [int(input()) for _ in range(N)]

S.sort()
ans = sum(S)
if ans%10 != 0:
  print(ans)
else:
  for i in range(N):
    if S[i]%10 != 0:
      ans -= S[i]
      break
  if ans == sum(S):
    ans = 0
  print(ans)

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
constexpr int MOD = 1e9 + 7;
//} END

signed main() {
  ios_base::sync_with_stdio(false);

  int n;
  cin>>n;

  vector<int> a(n+1,INF);
  rep(i,1,n+1) cin>>a[i];
  sort(all(a),greater<int>());
  int ans = 0;

  rep(i,2,n+1){
    ans += a[(i+1)/2];
    //cout<<ans<<'\n';
  }
  //cout<<'\n';

  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 4816
# include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
# define forn(i, n) for (ll i = 0; i < int(n); i++)
# define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
# define all(V) V.begin(), V.end()
# define rall(V) V.rbegin(), V.rend()
# define len(V) (int)V.size()
# define ll long long
# define ld long double
# define ff first
# define ss second
# define pb push_back
# define mp make_pair
# define endl '\n'
# define M_PI 3.14159265358979323846
 
void solve()
{
        string s; cin >> s;
        int n = s.length();
        ll cnt = 0, res = 0;
        for(int i = 0; i < n; ++i)
        {
                if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C')
                {
                        cnt++;
                }
                else
                {
                        cnt = 0;
                }
                res = max(res, cnt);
        }
        cout << res;
}
 
int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        solve();
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf

#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)

#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()

#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))

#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >

#define endl "\n";
#define line puts("-------");
#define dbb(x) cout<<#x<<" : "<<x<<"\n";

const int N = 100005;
const int MOD = 1000000007;

void __print(int x) {cerr << x;} void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;} void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V> void __print(const pair<T, V> &x)
{cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T> void __print(const queue<T> &x)
{queue<T>temp=x;cerr<<"\n-----\n";while(!temp.empty())
{cerr << temp.front() << endl;temp.pop();}cerr<<"-----\n";}
template<typename T> void __print(const stack<T> &x)
{stack<T>temp=x;cerr<<"\n-----\n";while(!temp.empty())
{cerr << temp.top() << endl;temp.pop();}cerr<<"-----\n";}
template<typename T> void __print(const T &x)
{int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v)
{__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
    #define db(x...) cerr << "[" << #x << "] = [", _print(x)
#endif
using ll = long long;

int main()
{
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt","w",stdout);
    #endif
    ll a,b;
    string s;
    cin>>a>>s;
    ll x=s[0]-'0';
    ll y=s[2]-'0';
    ll z=s[3]-'0';
    b=100*x+10*y+z;
    //db(x,y,z,b);
    cout<<(a*b)/100;
}


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

int main(){

ll ans=0;
int n;
cin >> n;
vector<ll> a(200100);
rep(i,n) cin >> a[i];

ll sum=0, b=0, diag=0, c=0;
for(int i=0; i<n; i++) b = (b+a[i])%1000000007;
for(int i=0; i<n; i++) diag = (diag+(a[i]*a[i])%1000000007)%1000000007;
sum = (b*b)%1000000007;
c=(sum-diag+1000000007)%1000000007;
if(c%2==0) ans=c/2;
else ans = (c+1000000007)/2;

cout << ans << endl;


/*
for(int j=0; j<n; j++){
    for(int i=0; i<j; i++){
        ans = (ans + (a[i]*a[j])%1000000007)%1000000007;
    }
}
*/

}

Measured memory_bytes: 4828
import math
MOD = 1000000007
def combination(n,m):
    return math.factorial(n)// math.factorial(n-m)// math.factorial(m)

def get_n_into_m(n,m):
    if n < m :
        return 0
    elif m <= 1:
        return 1
    else:
        return combination(n-m + m -1 , m -1 ) % MOD
        
n,k = map(int,input().split())
for i in range(1,k+1):
    if i == 1:
        print(n-k+1)
    else:
        print( get_n_into_m(k,i) * get_n_into_m(n-k+2, i +1) % MOD)


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

void solve(int N, int M, std::vector<int> s, std::vector<int> c)
{
    string res(N, '#');
    if (M == 0)
    {
        if (N == 1)
        {
            res[0] = '0';
            cout << res << endl;
            return;
        }
        else
        {

            res[0] = '1';
            for (int i = 1; i < N; i++)
            {
                res[i] = '0';
            }

            cout << res << endl;
            return;
        }
    }

    for (int i = 0; i < M; i++)
    {
        string sa = to_string(c[i]);
        if (N >= 2 && s[i] == 1 && sa[0] == '0')
        {
            cout << -1 << endl;
            return;
        }

        if (res[s[i] - 1] != '#' && sa[0] != res[s[i] - 1])
        {
            cout << -1 << endl;
            return;
        }

        {
            // cout << "res[" << s[i] - 1 << "] <= " << c[i] << endl;
            res[s[i] - 1] = sa[0];
            // cout << "res[" << s[i] - 1 << "] = " << res[s[i] - 1] << endl;
        }
    }

    if (N == 1)
    {
        if (res[0] == '#')
        {
            res[0] = '0';
        }

        cout << res << endl;
    }
    else
    {
        if (res[0] == '#')
        {
            res[0] = '1';
        }

        for (int i = 1; i < N; i++)
        {
            if (res[i] == '#')
            {
                res[i] = '0';
            }
        }
        cout << res << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    int N;
    cin >> N;
    int M;
    cin >> M;

    std::vector<int> s(M);
    std::vector<int> c(M);
    for (int i = 0; i < M; i++)
    {
        cin >> s[i] >> c[i];
    }
    solve(N, M, std::move(s), std::move(c));
    return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.functional;

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);

    if (n == 2) {
        writeln("Yes");
        return;
    }

    a.sort();

    if (a[$ - 1] - a[0] > 1) {
        writeln("No");
        return;
    }

    if (a[0] == 1) {
        if (a[$ - 1] == a[0] || a[0] < a[1]) {
            writeln("Yes");
        }
        else {
            writeln("No");
        }
    }
    else {
        int k = a[0];
        int l = a.count(k).to!int - 1;

        if (a[$ - 1] == a[0]) {
            if (2*k - 1 <= n - 1 || k == n - 1) {
                writeln("Yes");
            }
            else {
                writeln("No");
            }
        }
        else {
            if (l <= k - 1 && 2*(k - l) <= n - 1 - l) {
                writeln("Yes");
            }
            else {
                writeln("No");
            }
        }
    }


}

void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg ; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

Measured memory_bytes: 4528
#include <iostream>
#include <array>
#include <vector>

static const int MAX_N = 8 + 1;
using Connections = std::array<std::vector<int>, MAX_N>;

size_t traverse(const Connections& c, const int N, int depth, int now_node, std::array<bool, MAX_N>& traversed);

int main() {
	int N, M;
	std::cin >> N >> M;
	Connections a = {};
	for (int i = 0; i < M; ++i) {
		int f, t;
		std::cin >> f >> t;
		a[f].emplace_back(t);
		a[t].emplace_back(f);
	}

	std::array<bool, MAX_N> traversed = {};
	traversed[1] = true;
	std::cout << traverse(a, N, 1, 1, traversed) << std::endl;
}

size_t traverse(const Connections& c, const int N, int depth, int now_node, std::array<bool, MAX_N>& traversed) {
	if (depth == N) {
		return 1;
	}
	size_t sum = 0;
	for (int candidate : c[now_node]) {
		if (!traversed[candidate]) {
			traversed[candidate] = true;
			sum += traverse(c, N, depth + 1, candidate, traversed);
			traversed[candidate] = false;
		}
	}
	return sum;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
#include <vector>
#include <cctype>
#include <set>
#include "iostream"
using namespace std;
const int INF = 2147483640;
const double eps = 1e-7;
typedef long long ll;
const int MAXN = 500000 + 100;
ll dis[MAXN];
struct edge
{
    int c,t;
    edge(int cc,int tt ):c(cc),t(tt){}
};
std::vector<edge> ed[MAXN];
struct status
{
    long long dis;
    int p;
};
bool vis[MAXN];
    int k,q;
void bfs()
{
    queue<status> que;
    memset(vis,0,sizeof(vis));
    status s={0LL,k};
    que.push(s);
    vis[k]=1;
    while(!que.empty())
    {
        status cur=que.front(); que.pop();
        int u=cur.p;
        vis[u]=1;
        dis[u]=cur.dis;
        int si=ed[u].size();
        for(int i=0;i<si;++i)
        {
            int v=ed[u][i].t,c=ed[u][i].c;
            if(vis[v]) continue;
            status next={cur.dis+c,v};
            que.push(next);
        }
    }
}
int main()
{
    int n;
    cin>>n;
    int a,b,c;
    for(int i=0;i<n-1;++i)
    {
        scanf("%d %d %d",&a,&b,&c);
        ed[a].push_back(edge(c,b));
        ed[b].push_back(edge(c,a));
    }

    cin>>q>>k;
       bfs();
    while(q--)
    {
        int x1,x2;
        scanf("%d %d",&x1,&x2);
        printf("%lld\n",dis[x1]+dis[x2] );
    }
    return 0;
}


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

int main(){
    ll k;
    cin >> k;
    vector<ll> num(50);
    for(int i =0; i < 50; i++) num[i] = i;

    for(int i = 0; i < 50; i++) num[i] += k/50;
    for(ll i = 0; i < k%50; i++){
        for(int j = 0; j < 50; j++){
            if(i == j) num[i] += 50;
            else num[j]--;
        }
    }
    
    cout << 50 << ' ';
    for(int i = 0; i < 50; i++){
        cout << num[i] << ' ';
    }
}

Measured memory_bytes: 256
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=500000+10;

int n,L,t[N],v[N];
struct node { ll v; double t; } q[N];
int qh=1,qt=0;

int main() {
	n=read(),L=read();
	for (int i=1;i<=n;++i) t[i]=read(),v[i]=read();
	int V=0; double Q=0;
	for (int i=1;i<=n;++i) {
		while (V+v[i]>L) {
			int pv=min(0ll+V+v[i]-L,q[qh].v);
			V-=pv,q[qh].v-=pv,Q-=1ll*pv*q[qh].t;
			if (!q[qh].v) ++qh;
		}
		q[++qt]=(node){v[i],t[i]};
		V+=v[i],Q+=1ll*v[i]*t[i];
		while (qh<qt&&q[qt].t<q[qt-1].t) {
			q[qt-1].t=(q[qt-1].t*q[qt-1].v+q[qt].t*q[qt].v)/(q[qt-1].v+q[qt].v);
			q[qt-1].v+=q[qt].v;
			--qt;
		}
		printf("%.7lf\n",Q/L);
	}
	return 0;
}

Measured memory_bytes: 21228
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x,y;
  int turt;
  cin>>x>>y;
  if(y&1)
  {
    cout<<"No"<<endl;
  }
  else
  {
    y=y/2;
    turt=y-x;
    if(turt>=0 && turt<=x)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int n,d;
    int sum=0;
    double dis=0;
    double a[11][11]={0};
    scanf("%d %d",&n,&d);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<d;j++)
        {
            scanf("%lf",&a[i][j]);
        }
    }
    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=0;k<d;k++)
            {
                dis=dis+fabs(a[i][k]-a[j][k])*fabs(a[i][k]-a[j][k]);
            }
            dis=sqrt(dis);
            if(dis-(int)dis<0.000001)
                sum+=1;
            dis=0;
        }
    }
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#define MAX 100

int main()
{
  int N;
  int A[MAX];
  int temp,i,j,flag=1,count=0;

  scanf("%d",&N);  
if( N < 1 || MAX < N ) exit(2); 

  for( i = 0 ; i < N ; i++ )
    {
      scanf("%d",&A[i]);
      if( A[i] < 0 || MAX < A[i] ) exit(3);
    }

  i = 0;
  while( flag != 0 )
    {
      flag = 0;
      for( j = N-1 ; j >= i+1 ; j-- )
	{
	  if( A[j] < A[j-1] )
	    {	
	      temp = A[j];
	      A[j] = A[j-1];
	      A[j-1] = temp;
	      flag = 1;
	      count++;
	    } 
	}
      i++;
    }
    
      for( i = 0 ; i < N-1 ; i++ )  printf("%d ",A[i]);
      
      printf("%d\n%d\n",A[i],count);

      return 0;
    }

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

void push(deque<pil> &dq, pil p){
    while(!dq.empty() && dq.back().se <= p.se) dq.pop_back();
    dq.push_back(p);
}

void pop(deque<pil> &dq, int j, int m){
    while(!dq.empty() && dq.front().fi < j-m) dq.pop_front();
}

lint getval(deque<pil> &dq){
    return dq.front().se;
}

int main(){
    int n, m, K;
    scanf("%d%d%d", &n, &m, &K);
    lint a[n+1];
    rep(i, n) scanf("%lld", &a[i+1]);
    lint dp[K+1][n+1];
    rep(i, K+1)rep(j, n+1) dp[i][j] = -1;
    For(j, 1, n+1) dp[1][j] = a[j];
    For(i, 2, K+1){
        deque<pil> dq;
        For(j, max(1, i-m), i) push(dq, {j, dp[i-1][j]});
        For(j, i, n+1){
            pop(dq, j, m);
            dp[i][j] = a[j]*i + getval(dq);
            push(dq, {j, dp[i-1][j]});
        }
    }
    lint ans = 0;
    rep(j, n+1) chmax(ans, dp[K][j]);
    printf("%lld\n", ans);
}

Measured memory_bytes: 236160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int P = scan.nextInt();

		int Anum = A * 3;

		System.out.println((Anum + P) / 2);
	}
}

Measured memory_bytes: 23764
#include <stdio.h>
int main(){
	
	int K;
	int X;
	int Yen=500;
	
	scanf("%d %d",&K,&X);
	getchar();
	
	if(K*Yen>=X){
		printf("Yes");
	}
	else{
		printf("No");
	}
	return 0;
}

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

typedef long long ll;

int main(){
	const double PI = acos(-1);
	
	double a,b,x;
	cin >> a >> b >> x;
	x = x/a;

	double ans;
	if(x>=a*b/2){
		double h = (a*b-x)*2 / a;
		ans = atan2(h,a);
	}else{
		double w = 2*x / b;
		ans = atan2(b,w);
	}
	ans = ans/(2*PI) * 360;
	printf("%.8lf\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
using namespace std;

typedef ostringstream oss;
typedef istringstream iss;

typedef vector<int> vi;
typedef vector< vi > vvi;

const int MIN_TIME = 540;
const int MAX_TIME = 1260;

bool isNotZero(int x) { return x; };

int main(void) {
	int pcNum, stuNum;
	while (cin >> pcNum >> stuNum, pcNum) {
		vvi recs(stuNum, vi(MAX_TIME - MIN_TIME + 1, 0));

		int recNum, queNum;
		cin >> recNum;
		for (int ri = 0; ri < recNum; ri++) {
			int time, pc, stu, type;
			cin >> time >> pc >> stu >> type;
			pc--; stu--;
			time -= MIN_TIME;
			if (type) {
				for (int i = time; i < recs[stu].size(); i++) {
					recs[stu][i] = recs[stu][i] + 1;
				}
			}else {
				for (int i = time; i < recs[stu].size(); i++) {
					recs[stu][i] = recs[stu][i] - 1;
				}

			}
		}

		cin >> queNum;
		for (int qi = 0; qi < queNum; qi++) {
			int start, end, stu;
			cin >> start >> end >> stu;
			stu--;
			start -= MIN_TIME; end -= MIN_TIME;

			int time = 0;
			time = count_if(recs[stu].begin() + start, recs[stu].begin() + end, isNotZero);

			cout << time << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 28788
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    A = string_to_int(inputs[0])
    b = collections.deque([])

    for i, a in enumerate(A):
        if i % 2 == 0:
            b.append(str(a))
        else:
            b.appendleft(str(a))
    if len(b) % 2 != 0:
        b.reverse()
    return ' '.join(b)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)

Measured memory_bytes: 117964
#include<bits/stdc++.h>
using namespace std;
int main() {
    int a,b;
    char op;
    cin>> a >> op >> b;
    while(op != '?') {
        switch(op) {
            case '+':
            cout << a + b << endl;
            break;
            case '-':
            cout << a - b << endl;
            break;
            case '*':
            cout << a * b << endl;
            break;
            case '/':
            cout << a / b << endl;
            break;
        }
        cin >> a >> op >> b;
    }
    return 0;
}


Measured memory_bytes: 3100
from collections import deque
n, q = map(int, input().split())
Q = [deque() for _ in range(n)]
for _ in range(q):
    query = list(map(int, input().split()))
    if query[0] == 0:
        Q[query[1]].append(query[2])
    elif len(Q[query[1]]) > 0:
        if query[0] == 1:
            print(Q[query[1]][0])
        elif query[0] == 2:
            Q[query[1]].popleft()


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

using namespace std;

string st;

int const nmax = 50;
int barby[1 + nmax];

int main() {

  long long n, bees, ans = 0, ogn;
  long long popo = 1;
  cin >> n;
  ogn = n;
  ans = 0;
  bees = 0;
  while(n > 0){
    bees++;
    if(bees % 2 == 1){
      if(ogn >= popo * 10){
        ans += popo * 9;
      }else{
        ans += ogn - popo + 1;
      }
    }
    n /= 10;
    popo *= 10;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3600