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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, w;

    cin>>n>>w;
    int w_i, n_i;
    if(n==1) {
        cin>>w_i>>n_i;
        cout<<n_i<<endl;
        return 0;
    }

    vector<int> val;
    vector<int> wt;

    val.reserve(n);
    wt.reserve(n);
    

    for(int i = 0; i < n; ++i) {
        cin>>w_i>>n_i;
        wt.push_back(w_i);
        val.push_back(n_i);
    }

    vector<vector<long long>> dp(n+1, vector<long long>(w+1, 0));

    for(int item = 1; item <= n; ++item) { // item
        for(int weight = 1; weight <= w; ++weight) { // weight

            long long lastMax = dp[item-1][weight];
            long long currMax = 0;

            if(wt[item-1] <= weight) {
                currMax = val[item-1] + dp[item-1][weight-wt[item-1]];
            }
            dp[item][weight] = max(lastMax, currMax);
        }
    }

    cout<<dp[n][w]<<endl;

    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    int A,B;cin>>A>>B;
    if(1<=A&&A<=9&&1<=B&&B<=9) cout<<A*B<<endl;
    else cout<<-1<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES  // M_PI等のフラグ
#define MOD 1000000007
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;


void solve(){
    /* WA */
    int R, C, K;
    cin >> R >> C >> K;
    vector<vector<int>> grid(R, vector<int>(C, 0));
    for (int i=0; i<K; i++) {
        int r, c, v;
        cin >> r >> c >> v;
        grid.at(--r).at(--c) = v;
    }

    // dp[i][j][x] := i行j列目で、このマスの行でx個のアイテムを取ったときの価値の最大値
    // dpはlong longじゃないとダメ
    vector<vector<vector<ll>>> dp(R, vector<vector<ll>>(C, vector<ll>(4, 0)));
    dp[0][0][1] = grid[0][0];

    for (int i=0; i<R; i++) {
        for (int j=0; j<C; j++) {
            // grid[i-1][j]からgrid[i][j]へ移動する場合
            for (int x=0; x<4; x++) {
                if (i-1>=0) {
                // 拾わない場合
                    dp[i][j][0] = max(dp[i][j][0], dp[i-1][j][x]);
                // 拾う場合
                    dp[i][j][1] = max(dp[i][j][1], dp[i-1][j][x] + grid[i][j]);
                }
            }
            // grid[i][j-1]からgrid[i][j]へ移動する場合
            for (int x=0; x<4; x++) {
                if (j-1>=0) {
                    // 拾わない場合
                    dp[i][j][x] = max(dp[i][j][x], dp[i][j-1][x]);
                    // 拾う場合
                    if (x-1>=0) {
                        dp[i][j][x] = max(dp[i][j][x], dp[i][j-1][x-1] + grid[i][j]);
                    }
                }
            }
        }
    }

    // 答え
    ll ans = 0;
    for (int x=0; x<4; x++) {
        ans = max(ans, dp[R-1][C-1][x]);
    }
    cout << ans << endl;
}


void solve2() {
    /* 解説AC */
    int R, C, N;
    cin >> R >> C >> N;

    int d[3005][3005];
    rep(i, N) {
        int r, c, v;
        cin >> r >> c >> v;
        d[r-1][c-1] = v;
    }
    /* dpは long long じゃないとだめ*/
    ll dp[3005][3005];

}

int main(int argc, char const *argv[]){
    solve();
    return 0;
}

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

int main()
{
  string s;

  cin >> s;

  long long ans = 0;

  rep(i,s.length()){
    ans += (int)s.at(i)-48;
    // cout << s.at(i) << endl;
  }

  // cout << ans << endl;

  // if(s == "0" ){
  //   cout << "Yes";
  //   return 0;
  // }

  if(ans % 9 == 0 || ans == 0){
    cout << "Yes";
    return 0;
  }

  else
  {
    cout << "No";
  }
  


}


Measured memory_bytes: 3716
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

typedef long long int ll;

int main(){
    int k;
    cin >> k;
    ll ans;
    queue<ll> Q;
    for(int i = 1; i <= 9; i++){
        Q.push(i);
    }
    for(int i = 1; i < k; i++){
        ll nq = Q.front();
        Q.pop();
        if (nq % 10 != 0)Q.push(nq * 10 + (nq % 10) -1);
        Q.push(nq * 10 + (nq % 10));
        if (nq % 10 != 9)Q.push(nq * 10 + (nq % 10) +1);
    }
    cout << Q.front() << endl;
}

Measured memory_bytes: 5076
S = list(input())
bool = "true"

for i in range(0, len(S), 2):
    if S[i] == "L":
        bool = "false"

for i in range(1, len(S), 2):
    if S[i] == "R":
        bool = "false"

if bool == "true":
    print("Yes")

else:
    print("No")


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Math;

public class Main{
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            
            while((line = stdReader.readLine()) != null) {
                String[] input = line.split(" ", 0);
                
                // ????????¢????¨????
                int width  = Integer.parseInt(input[0]);
                // ????????¢?????????
                int height = Integer.parseInt(input[1]);
                
                // ????????????x??§?¨?
                int x = Integer.parseInt(input[2]);
                // ????????????y??§?¨?
                int y = Integer.parseInt(input[3]);
                // ????????????r
                int r = Integer.parseInt(input[4]);
                
                // ????????????????????????????????????????????§?¨?
                ////////////////////////////////////////
                // ?????????????????§?¨?
                int top = y + r;
                
                // ?????????????????§?¨?
                int bottom = y - r;
                
                // ?????????????????§?¨?
                int right = x + r;
                
                // ?????????????????§?¨?
                int left = x - r;
                
                String ans = "Yes";
                
                // ???????????????height????¶?????????¨??????????????????
                if(top > height) {
                    ans = "No";
                }
                
                // ???????????????0?????????????????¨??????????????????
                if(bottom < 0) {
                    ans = "No";
                }
                
                // ???????????????width????¶?????????¨??????????????????
                if(right > width) {
                    ans = "No";
                }
                
                // ???????????????????????????????????¨??????????????????
                if(left < 0) {
                    ans = "No";
                }
                System.out.println(ans);
            }
            stdReader.close();
        } catch(Exception e) {
            e.getStackTrace();
            System.exit(-1);
        }
    }
}

Measured memory_bytes: 24460
n = int(input())
xy = []
for _ in range(n):
    a = int(input())
    xy.append([])
    for _ in range(a):
        xy[-1].append([int(i) for i in input().split()])
        xy[-1][-1][0] -= 1

ans = 0
for i in range(2 ** n):
    ok = True
    l = 0
    for j in range(n):
        if i & (2 ** j) == 0:
            continue
        l += 1
        for k in xy[j]:
            if (1 if i & (2 ** k[0]) != 0 else 0) != k[1]:
                ok = False
    
    if ok:
        ans = max(ans, l)
print(ans)

Measured memory_bytes: 43984
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main (){
  ll n;
  cin>>n;
  vector<ll>c(n,0);
  for(ll i=0;i<n;i++){
    cin>>c[i];
    c[i]--;
  }
  if(n==1){
    ll k=c[0]>=0?1:0;
    cout<<k<<endl;
    return 0;
  }
  vector<ll>dp(n,0);
  vector<ll>v(n,0);
  vector<ll>vv(n,-1);
  dp[n-1]=1;
  v[c[n-1]]=1;
  vv[c[n-1]]=n-1;
  for(ll i=n-2;i>=0;i--){
    if(v[c[i]]==0||vv[c[i]]-i==1){
      dp[i]=dp[i+1];
      v[c[i]]=dp[i];
    }
    else{
      dp[i]=dp[i+1]+v[c[i]];
      v[c[i]]=dp[i];
    }
    vv[c[i]]=i;
    dp[i]%=MOD;
    v[c[i]]%=MOD;
  }
  cout<<dp[0]<<endl;
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        int W = sc.nextInt();

        if(S <= W) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }

    }
}


Measured memory_bytes: 35540
class LazySegmentTree():
    def __init__(self,n,init,merge_func=min,ide_ele=10**18):
        self.n=(n-1).bit_length()
        self.merge_func=merge_func
        self.ide_ele=ide_ele
        self.data=[0 for i in range(1<<(self.n+1))]
        self.lazy=[0 for i in range(1<<(self.n+1))]
        for i in range(n):
            self.data[2**self.n+i]=init[i]
        for i in range(2**self.n-1,0,-1):
            self.data[i]=self.merge_func(self.data[2*i],self.data[2*i+1])

    def propagate_above(self,i):
        m=i.bit_length()-1
        for bit in range(m,0,-1):
            v=i>>bit
            add=self.lazy[v]
            self.lazy[v]=0
            self.data[2*v]+=add
            self.data[2*v+1]+=add
            self.lazy[2*v]+=add
            self.lazy[2*v+1]+=add

    def remerge_above(self,i):
        while i:
            i>>=1
            self.data[i]=self.merge_func(self.data[2*i],self.data[2*i+1])+self.lazy[i]

    def update(self,l,r,x):
        l+=1<<self.n
        r+=1<<self.n
        l0=l//(l&-l)
        r0=r//(r&-r)-1
        while l<r:
            self.data[l]+=x*(l&1)
            self.lazy[l]+=x*(l&1)
            l+=(l&1)
            self.data[r-1]+=x*(r&1)
            self.lazy[r-1]+=x*(r&1)
            l>>=1
            r>>=1
        self.remerge_above(l0)
        self.remerge_above(r0)

    def query(self,l,r):
        l+=1<<self.n
        r+=1<<self.n
        l0=l//(l&-l)
        r0=r//(r&-r)-1
        self.propagate_above(l0)
        self.propagate_above(r0)
        res=self.ide_ele
        while l<r:
            if l&1:
                res=self.merge_func(res,self.data[l])
                l+=1
            if r&1:
                res=self.merge_func(res,self.data[r-1])
            l>>=1
            r>>=1
        return res

import sys

input=sys.stdin.buffer.readline

ide_ele=10**18

N,M=map(int,input().split())

init=[0 for i in range(M+2)]
for i in range(1,M+1):
    init[0]+=1
    init[i+1]-=1
for i in range(1,M+1):
    init[i]+=init[i-1]
init[-1]=0

LST=LazySegmentTree(M+2,init)

hito=[tuple(map(int,input().split())) for i in range(N)]
hito.sort()

add=M-N
for l,r in hito:
    LST.update(0,r+1,-1)
    m=LST.query(l+1,M+2)+l
    add=min(m,add)

print(max(-add,0))

Measured memory_bytes: 159920
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b){
		cout<<c<<endl;
	}
	else if(a==c){
		cout<<b<<endl;
	}
	else{
		cout<<a<<endl;
		
	}
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
    int mon[13][31];
    int sum=0;
    for(int i=1;i<=12;i++)
        for(int j=1;j<=31;j++)
        {
            if((i<=7&&i%2==0)&&j==31)
                break;
            if(i==2&&j==29)
                break;
            if(i>=8&&i%2==1&&j==31)
                break;
            if(i==j)
                sum++;
            mon[i][j]=sum;
        }
    int a,b;
    scanf("%d%d",&a,&b);
    {
        printf("%d\n",mon[a][b]);
    }
    return 0;
}


Measured memory_bytes: 888
//==========================================
// ABC139a
//
// 2019/09/01
//==========================================

#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int main(int argc, char* argv[])
{
  string s, t;
  cin >> s >> t;
  int cnt=0;
  for(int i=0; i<3; ++i)
  {
    if(s[i]==t[i]) cnt++;
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
import scala.io.{StdIn => in}

object Main extends App {

  val n = in.readLine.toInt
  val seq = in.readLine.split(" ").map(_.toInt)

  val p = seq(0)
  val ans = seq.tail./:(1, p, 0) { (acc, i) =>
    acc match {
      case (cnt, pre, sign) if (pre == i && 0 == sign) => (cnt, i, 0)
      case (cnt, pre, sign) if (pre < i && 0 == sign) => (cnt, i, 1)
      case (cnt, pre, sign) if (pre > i && 0 == sign) => (cnt, i, -1)
      case (cnt, pre, sign) if (pre == i && 0 < sign) => (cnt, i, 1)
      case (cnt, pre, sign) if (pre == i && 0 > sign) => (cnt, i, -1)
      case (cnt, pre, sign) if (pre < i && 0 < sign) => (cnt, i, 1)
      case (cnt, pre, sign) if (pre > i && 0 > sign) => (cnt, i, -1)
      case (cnt, pre, sign) => (cnt + 1, i, 0)
    }
  }._1

  println(ans)
}

Measured memory_bytes: 42560
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
const int mod = 1e9 + 7;
int main()
{
	SPEED
	int s, w;
	cin >> s >> w;
	if (w>=s)
	{
		cout << "unsafe";
	}
	else
	{
		cout << "safe";
	}
	return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    int i;
    int cnt=0;
    int flag=0;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
        if(i>0) {
            if(a[i-1]<a[i]) {
                if(flag<0) {
                    cnt++;
                    flag=0;
                }
                else {
                    flag = 1;
                }
            }
            else if(a[i-1]>a[i]) {
                if(flag>0) {
                    cnt++;
                    flag=0;
                }
                else {
                    flag = -1;
                }
            }
        }
    }
    printf("%d\n", cnt+1);

    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
using namespace std;

const int N_MAX = 1E+05;

int main(){
  int A[N_MAX];
  int x[N_MAX];

  int n;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }

  int sum = 0;

  for(int i = 0; i < n; i++){
    if (i % 2 == 1) sum -= A[i];
    else if (i % 2 == 0) sum += A[i];
  }

  int ans = sum;

  printf("%d", ans);

  for(int i = 0; i < n - 1; i++){
    ans = 2 * (A[i] - ans / 2);
    printf(" %d", ans);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 1664
<?php
$input = '';
while ($line = fgets(STDIN)) {
  $input = implode(' ', [$input, trim($line)]);
}

$input = explode(' ', trim($input));

$input = array_map(function($i){ return (int)$i;}, $input);

$total = 0;

for ($i = 2; $i < count($input); $i++) {
  $total += $input[$i];
}

echo $total >= $input[0] ? 'Yes' : 'No';

Measured memory_bytes: 45060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

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; }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  char c;
  cin >> c;

  if ('a' <= c && c <= 'z') {
    puts("a");
  } else {
    puts("A");
  }

  return 0;
}


Measured memory_bytes: 3640
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }

    bool b[n];
    for(int i = 0; i < n; i++){
        b[i] = true;
    }
    int count = 0;
    for(int i = 0;;){
        if(i == 1){
            printf("%d\n",count);
            break;
        }
        if(b[i] == true){
            b[i] = false;
            count++;
            i = a[i] - 1;
        }else{
            printf("-1\n");
            break;
        }
    }

    return 0;
}

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

int main(int argc, char const *argv[])
{
	int n; ll m; cin >> n >> m;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	map<ll, int> ma;
	ll ans = 0;
	ll d = 0;
	ma[0]++;
	rep(i, n) {
		d += a[i]; d %= m;
		ma[d]++;
	}

	for (auto u : ma) {
		ll k = u.second;
		ans += k * (k - 1) / 2;
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<ll> enum_div(ll n){
	vector<ll> ret;
	for(ll i=1;i*i<=n;++i){
		if(n%i==0){
			ret.push_back(i);
			if(i*i!=n){
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

ll gcd(ll a,ll b){
	if(a<b){
		swap(a,b);
	}

	while(ll r=(a%b)){
		a = b;
		b = r;
	}
	return b;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll A=in<ll>(),B=in<ll>();
	auto DA = enum_div(A);
	sort(ALL(DA));
	auto DB = enum_div(B);
	sort(ALL(DB));

	vector<ll> result;
	set_intersection(DA.begin(), DA.end(),
		DB.begin(), DB.end(),
		std::inserter(result, result.end()));

	vector<int> flag(result.size(),0);
	for(int i=0;i<result.size();i++){
		for(int j=i+1;j<result.size();j++){
			if(!flag[j]){
				if(gcd(result[i],result[j])!=1){
					flag[j] = 1;
				}
			}
		}
	}

	out(count(ALL(flag),0));
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

struct person {
	int card;
	int point;
};

int main()
{
	int i;
	int n;
	struct person A, B;
	
	while(1) {
		scanf("%d", &n);
		if( n == 0 ) break;
		
		A.point = 0;  B.point = 0;
		for(i=0; i<n; i++)
		{
			scanf("%d %d", &A.card, &B.card);
			
			if(A.card > B.card) {
				A.point += A.card + B.card;
			}
			else if(B.card > A.card) {
				B.point += A.card + B.card;
			}
			else {
				A.point += A.card;
				B.point += B.card;
			}
		}
		printf("%d %d\n", A.point, B.point);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
typedef pair<int,int> pp;
int blood,ans=0,n;
char ch;
int cnt[10007];
string s;
int num;
int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    memset(cnt,0,sizeof(cnt));
    for(int i=0;i<n;i++)
    {
        cin>>ch;
        s+=ch;
    }
    for(int i=0;i<n;i++)
    {
        num=atoi((s.substr(i,1)).c_str());
        cnt[num]++;
    }
    for(int i=0;i<n-1;i++)
    {
        num=atoi((s.substr(i,2)).c_str());
        //cout<<num<<endl;
        cnt[num]++;
    }
    for(int i=0;i<n-2;i++)
    {
        num=atoi((s.substr(i,3)).c_str());
        cnt[num]++;
    }
    for(int i=0;i<n-3;i++)
    {
        num=atoi((s.substr(i,4)).c_str());
        cnt[num]++;
    }

    for(int i=0;i<10000;i++)
    {
        if(cnt[i]==0)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

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

int main(void)
{
  int a;
  int b;
  cin >> a >> b;
  int cnt = 0;
  int p = 1;
  while(p < b)
  {
    p = p + a - 1;
    cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int s,ar[4],n,i;
  string ans;
  cin >> s;
  
  ans = "Good";
  n=1000;
  for(i=0;i<4;i++){
    ar[i] = (s-s%n)/n;
    s = s-ar[i]*n;
    n /= 10;
  }
  for(i=1;i<4;i++){
    if(ar[i] == ar[i-1]) ans ="Bad";
  }
  cout << ans;
  return 0; 
}

Measured memory_bytes: 256
#N,Q=8,3
#S="ACACTACG"
#L = [3,2,1]
#R = [7,3,8]

N, Q = map(int, input().split(" "))
S = input()
L = []
R = []
for _ in range(Q):
    l, r = map(int, input().split(" "))
    L.append(l)
    R.append(r)

sh = [0]
n = 0
for i in range(1, N):
    if S[i - 1] == "A" and S[i] == "C":
        n += 1
    sh.append(n)
for (l, r) in zip(L, R):
    print(sh[r - 1] - sh[l - 1])


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

int main(){
	int k[500];
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		 cin >> k[i];
	}
    for(int i = 1; i <= n; i++){
        cout << "node " << i;
        cout << ": key = " << k[i];
        if(i > 1){
            cout << ", parent key = " << k[i/2];
        }
        if(2*i <= n){
            cout << ", left key = " << k[2*i];
        }
        if(2*i+1 <= n){
            cout << ", right key = " << k[2*i+1];
        }
        cout << ", " << endl;
    }
}

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

int main(){
    int H,W;
    cin >> H >> W;

    vector <string> S(H);
    vector <vector <string> > table(H, vector <string> (W));
    for(int i=0; i<H; i++){
        cin >> S[i];
    }

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            table[i][j] = S[i][j];
        }
    }

    vector <int> oki(H,0);
    vector <int> okj(W,0);
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(table[i][j] == "#"){
                oki[i]++;
                okj[j]++;
            }
        }
    }

    for(int i=0; i<H; i++){
        if(oki[i] != 0){
            for(int j=0; j<W; j++){
                if(okj[j] != 0){
                    cout << table[i][j];
                }
            }
            cout << endl;
        }            
    }
}

Measured memory_bytes: 768
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {

    vector<vector<ll>> dp(1000100, vector<ll>(2, LINF));

    string N;
    cin >> N;

    reverse(All(N));
    N.push_back('0');
    reverse(All(N));
    dp[0][0] = 0;
    // dp[i][j]:=i文字目まで見て状態がjのときの最小
    int cnt = 0;
    rep(i, N.size()) {
        // j==0 今までぴったり
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][0] + (N[i] - '0'));
        if(N[i] != '9')
            dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + (N[i] - '0') + 1);

        // j==1 1余分に払ってる
        dp[i + 1][0] = min(dp[i + 1][0], dp[i][1] + (10 - (N[i] - '0')));
        dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + (9 - (N[i] - '0')));
        cnt++;
    }

    cout << dp[N.size()][0] << endl;
    return 0;
}

Measured memory_bytes: 60016
def relax(u, v, w):
    if D[u] + w < D[v]:
        D[v] = D[u] + w
        P[v] = u

INF = float('inf')
N = int(input())
D = [INF for i in range(N)]
P = [None for i in range(N)]
C = ['w' for i in range(N)]
D[0] = 0

G = [[INF for j in range(N)] for i in range(N)]
for i in range(N):
    x = list(map(int, input().split()))
    g = x[2:]
    for j, n in enumerate(g):
        if j % 2 == 0:
            G[i][n] = g[j + 1]


while True:
    mincost = INF
    u = -1
    for i in range(N):
        if C[i] != 'b' and D[i] < mincost:
            mincost = D[i]
            u = i
    if u == -1:
        break
    C[u] = 'b'
    for v, w in enumerate(G[u]):
        if w != INF and C[v] != 'b':
            relax(u, v, w)
            C[v] = 'g'

for i, d in enumerate(D):
    print('{0} {1}'.format(i, d))

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

int main() {
  int n;
  string s;
  cin >> s;
  n = s.size();
  vector<int> ans(n);
  rep(ri,2) {
    { // solve R
      int cnt = 0;
      rep(i,n) {
        if (s[i] == 'R') cnt++;
        else {
          ans[i] += cnt/2;
          ans[i-1] += (cnt+1)/2;
          cnt = 0;
        }
      }
    }

    reverse(ans.begin(), ans.end());
    reverse(s.begin(), s.end());
    rep(i,n) {
      if (s[i] == 'L') s[i] = 'R';
      else s[i] = 'L';
    }
  }

  rep(i,n) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
using namespace std;

int main(){
    int n;
    cin >> n;
    if(n==1) cout << "Hello World" << endl;
    else{
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for (ll i = K; i < N + 2; i++) {
        ll minsum = i * (i - 1) / 2;
        ll maxsum = N * (N + 1) / 2 - (N - i) * (N - i + 1) / 2;
        ans += maxsum - minsum + 1;
        ans %= 1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
using ll = long long;
#define pi 3.1415926

int x[3];

int main(){
    int r;
    cin >> r;
    if(r < 1200)
        cout << "ABC";
    else if(r < 2800)
        cout << "ARC";
    else
        cout << "AGC";
    
}
	


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

int n,m,M;
int t[100001];
int main(){
	scanf("%d",&n);
	while (n--){
		scanf("%d",&m);t[m]++;if (t[m]>2) t[m]-=2;
	}
	m=M=0;
	for (register int i=1;i<=100000;i++){
		if (t[i]) m++;
		if (t[i]==2) M^=1;
	}
	m-=M;
	printf("%d\n",m);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    vll sum(n);
    sum[0] = a[0];
    rep(i, n-1) sum[i+1] = sum[i] + a[i+1]; 

    int ans = 0;
    rep(i, n-1) {
        if (sum[i]*2 >= a[i+1]) ans++;
        else ans = 0;
    }
    ans++;

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

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
 
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a,b,c,d, ans =0;
	cin >>a >>b >>c >>d;
	if(a+b > c+d) puts("Left");
	else if(a+b < c+d) puts("Right");
	else puts("Balanced");
	return 0;
}

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

int main(){
    int n;
    cin >> n;
  	int s = n;
    int sum = 0;
    while(s > 0){
        sum += s%10;
        s = s/10; 
    }
    if(n%sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	
	public void decisionmain (int n, int game[][], int result[][]) {
		for (int j = 0; j < 3; j++) {
			for (int i = 0; i < n; i++) {
				for (int k = 0; k < n; k++) {
					decisionsub(i, j, k, game, result);
				}
			}
		}	
	}
	
	public void decisionsub (int i, int j, int k, int game[][], int result[][]) {
		if (k != i) {
			if (game[i][j] == game[k][j]) {
				result[i][j] = 0;
			}
		}
	}
	
	public void scoresum (int n, int result[][]) {
		for (int i = 0; i < n; i++) {
			int sum = 0;
			for (int j = 0; j < 3; j++) {
				sum += result[i][j];
			}
			System.out.println(sum);
		}
	}
	
	void doIt () {
		
		Scanner sc = new Scanner (System.in);

		int n = sc.nextInt();

		int [][] game = new int [n][3];
		int [][] result = new int [n][3];

		int i, j;
		
		for (i = 0; i < n; i++) {
			for (j = 0; j < 3; j++) {
				game[i][j] = sc.nextInt();
				result[i][j] = game[i][j];
			}
		}
		
		decisionmain(n, game, result);
		scoresum(n, result);
		
	}
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		new Main(). doIt();
		
	}

}

Measured memory_bytes: 20828
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    cout << (N * (N - 1) + M * (M - 1)) / 2 << endl;
}

Measured memory_bytes: 3632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        x: usize
    }
    let mut n = 1;
    while n * (n+1) < x * 2 {
        n += 1;
    }
    println!("{}",n);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
using namespace std;

int find_root(int i, vector<int>& node){
    if (node[i] == i) return i;
    return node[i] = find_root(node[i], node);
}

void unite(int r1, int r2, vector<int>& node, vector<int>& hight){
    int big   = r1;
    int small = r2;
    if (hight[big] < hight[small]) swap(big, small);
    if (hight[big] == hight[small]) hight[big]++;
    node[small] = big;
}

int main(){
    int V, E;
    cin >> V >> E;
    priority_queue<pair<int, pair<int, int> > > Q;
    for (int i = 0; i < E; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        Q.push(make_pair(w * -1, make_pair(s, t)));
    }
    vector<int> node(V);
    vector<int> hight(V, 0);
    for (int i = 0; i < V; i++) {
        node[i] = i;
    }
    int sum = 0;
    for (int i = 0; i < V - 1; i++) {
        int r1, r2;
        while (1) {
            r1 = find_root(Q.top().second.first , node);
            r2 = find_root(Q.top().second.second, node);
            if (r1 != r2) break;
            Q.pop();
        }
        sum += Q.top().first * -1;
        unite(r1, r2, node, hight);
        Q.pop();
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 4488
using System;
public class Test{
  public static void Main(){
    var num = Console.ReadLine().Split(' ');
    int A = int.Parse(num[0]);
    int B = int.Parse(num[1]);
    double H = double.Parse(num[2]);
    double M = double.Parse(num[3]);
    double X=0; 
    double Hrad = (H*60+M)/720;
    double Mrad = M/60;
    if(Hrad >= Mrad){
      if(Hrad-Mrad >= 1-Hrad+Mrad){
        X = A*A + B*B - 2*A*B*Math.Cos((Hrad-Mrad)*2*Math.PI);
      }else{
        X = A*A + B*B - 2*A*B*Math.Cos((1-Hrad+Mrad)*2*Math.PI);
      }
    }else{
      if(Mrad-Hrad >= 1-Mrad+Hrad){
        X = A*A + B*B - 2*A*B*Math.Cos((Mrad-Hrad)*2*Math.PI);
      }else{
        X = A*A + B*B - 2*A*B*Math.Cos((1-Mrad+Hrad)*2*Math.PI);
      }
    }
    Console.Write(Math.Sqrt(X));
  }
}

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

using namespace std;

int main()
{
	int n,k;
	cin >> n >> k;
	if(k==0)
	{
		cout << 1LL*n*n << endl;
		return 0;
	}
	long long cur=0;
	for(int i=k+1;i<=n;i++)
	{
		// k , i+k , 2*i+k
		long long mx=n/i*i;
		cur+=mx/i*(i-k);
		cur+=max(0LL,n-(mx+k)+1);
	}	
	cout << cur << endl;
}

Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::vector<int> T;
	int M;
	std::vector<int> P, X;
	std::cin >> N;
	T.resize(N);
	for (auto& t : T)
		std::cin >> t;
	std::cin >> M;
	P.resize(M);
	X.resize(M);
	for (int i = 0; i < M; ++i)
		std::cin >> P[i] >> X[i];

	int total = 0;
	for (auto t : T)
		total += t;

	for (int i = 0; i < M; ++i)
		std::cout << (total - T[P[i]-1] + X[i]) << "\n";
}


Measured memory_bytes: 256
N = int(input())
Ws = list(map(int, input().split()))


prev_s = abs(Ws[0]-sum(Ws[1:]))
for i in range(N-1):
    now_s = abs(sum(Ws[:i+2]) -sum(Ws[i+2:]))
    if now_s>prev_s:
        print(prev_s)
        break
    else:
        prev_s = now_s

    

Measured memory_bytes: 2940
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c;
    scanf("%d %d %d",&a, &b, &c);
    if(a==5){
        if(b==5 && c==7) printf("YES");
        else if(b==7 & c==5) printf("YES");
        else printf("NO");
    }else if(a==7){
        if(b==5 && c==5) printf("YES");
        else printf("NO");
    }else printf("NO");
}


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

int A[100], N;

void insertionSort();
void trace();

int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) { cin >> A[i]; }
  
  trace();
  insertionSort();
  
  return 0;
}

// sort
void insertionSort() {
  for (int i = 1; i < N; ++i) {
    int v = A[i];
    int j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace();
  }
}

// print
void trace() {
  for (int i = 0; i < N; ++i) {
    if (i) { cout << " "; }
    cout << A[i];
  }
  cout << "\n";
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
using namespace std;
#define ll long long
//{{{ read()
inline int read() {
    register int x = 0, f = 1;
    register char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        x = x * 10 + (ch ^ 48), ch = getchar();
    return x * f;
}
//}}}
const int N = 1005;
int k;
char s[N];
int main() {
    // freopen(".in","r",stdin);
    // freopen(".out","w",stdout);
    k = read(), scanf("%s", s + 1);
    int len = strlen(s + 1);
    if (len <= k)
        printf("%s", s + 1);
    else {
        for (int i = 1; i <= k; i++)
            printf("%c", s[i]);
        puts("...");
    }
    return 0;
}

Measured memory_bytes: 3748
N, M = map(int, input().split())

if N <= M:
    N, M = M, N

if N - M > 1:
    print(0)
    exit()

num = 10**9 + 7


def bikkuri(n):
    rt = 1
    for i in range(n, 0, -1):
        rt *= i
        rt = rt % num
    return rt


ans = (bikkuri(M)**2) % num

if N == M:
    ans *= 2
else:
    ans *= (M + 1)

ans %= num
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
long long a,b,c,d,e,f,i,j;
cin >> a >> b;
if(abs(a-b)>=2019)
    f=2019;
else
    f=abs(a-b);
long long l=2045;
for(i=a;i<=a+f;i++)
{
    for(j=i+1;j<=a+f;j++)
    {
        l=min(l,(j*i)%2019);

    }
}
cout << l << endl;

}


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

int main(){
  int h,a;
  cin >> h >> a;
  if(h%a == 0) cout << h/a << endl;
  else cout << h/a + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
program main
  implicit none
  integer :: i, n, k
  character(10) :: s
  character(1) :: tar

  read *, n
  read *, s
  read *, k
  tar = s(k:k)

  do i = 1, n
    if (s(i:i) /= tar) then
      s(i:i) = '*'
    end if
  end do

  print '(a)', s

end program

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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

char S[50];
char T[50];
bool use[26];

bool rec(int len) {
    REP (c, 26) if (!use[c]) {
	use[c] = true;
	T[len] = c + 'a';

	if (S[len] < T[len]) {
	    puts(T);
	    return true;
	} else if (S[len] == T[len]) {
	    if (rec(len+1)) {
		return true;
	    }
	}
	T[len] = 0;
	use[c] = false;
    }

    return false;
}

void MAIN() {
    scanf("%s", S);

    if (rec(0)) {
    } else {
	puts("-1");
    }

    
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 764
let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let bfs vs n =
  let d = Array.make (n + 1) (-1) in
  d.(1) <- 0;
  let que = Queue.create () in
  Queue.add 1 que;
  while not (Queue.is_empty que) do
    let i = Queue.take que in
    List.iter (fun e ->
      if d.(e) <> (-1) then ()
      else begin
        d.(e) <- d.(i) + 1;
        Queue.add e que;
      end) vs.(i);
  done;
  d

let () =
  let n = read_int () in
  let vs = Array.make (n + 1) [] in
  for _ = 0 to n - 1 do
    match read_line () |> split_on_char ' ' |> List.map int_of_string with
    | u :: _ :: l -> vs.(u) <- l
    | _ -> assert false
  done;
  let d = bfs vs n in
  for i = 1 to n do
    Printf.printf "%d %d\n" i d.(i)
  done

Measured memory_bytes: 2348
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

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

vector<int> G[100];
bool visited[100];
int memo[100];

int visit(int v){
	int res = 0;
	rep(i, (int)G[v].size()){
		if(!visited[G[v][i]] && memo[G[v][i]] >= res){
			visited[G[v][i]] = true;
			res = max(res, 1 + visit(G[v][i]));
			visited[G[v][i]] = false;
		}
	}
	return res;
}

int main(){
	int n;
	int a, b;
	while(cin >> n && n){
	
		rep(i, 100) G[i].clear();
		memset(visited, false, sizeof(visited));
		fill(memo, memo + 100, INF);

		rep(i, n){
			cin >> a >> b;
			a--, b--;
			G[a].push_back(b);
			G[b].push_back(a);
		}

		int res = 0;
		
		rep(i, 100){
			visited[i] = true;
			memo[i] = visit(i);
			res = max(res, memo[i]);
			visited[i] = false;
		}
		cout << res + 1<< endl;
	}
	return 0;
}

Measured memory_bytes: 912
import itertools
H,W,N=[int(s) for s in input().split()]
hls=[0 for _ in range(H+1)]
wls=[0 for _ in range(W+1)]
bombs=[set() for _ in range(H+1)]
for _ in range(N):
  h,w=[int(s) for s in input().split()]
  hls[h]+=1
  wls[w]+=1
  bombs[h].add(w)
hmax=max(hls)
wmax=max(wls)
hmaxls=[i for i in range(H+1) if hls[i]==hmax]
wmaxls=[i for i in range(W+1) if wls[i]==wmax]
for h,w in itertools.product(hmaxls,wmaxls):
  if not(w in bombs[h]):
    print(hmax+wmax)
    exit()
else:
  print(hmax+wmax-1)

Measured memory_bytes: 120516
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <math.h>

using namespace std;

int main()
{
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    while (x % 2 == 0) {
      x /= 2;
      ++cnt;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int64_t> L(87);
  L.at(0) = 2;
  L.at(1) = 1;

  for (int i=2;i<N+1;i++) {
    L.at(i) = L.at(i-2) + L.at(i-1);
  }
  cout << L.at(N) << endl;
}

Measured memory_bytes: 256