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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll a,b,ans=0; cin>>a>>b;
    for(int i=a;i<=b;i++){
        string s=to_string(i),t;
        t=s;
        reverse(all(s));
        if(s==t) ++ans;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    string S; cin >>S;
    long long int p[4][S.length()];
    for (int i=0;i<S.length();i++){
        if (i==0) p[0][i]=0;
        else {
            if (S[i-1]=='B'||S[i-1]=='C') p[0][i]=p[0][i-1];
            else p[0][i]=p[0][i-1]+1;
        }
    }
    for (int i=0;i<S.length();i++){
        if (i==0) p[1][i]=0;
        else {
            if (S[i-1]=='A') p[1][i]=p[1][i-1]+1;
            else p[1][i]=p[1][i-1];
        }
    }
    for (int j=S.length()-1;j>=0;j--){
        if (j==S.length()-1) p[2][j]=0;
        else {
            if (S[j+1]=='C'||S[j+1]=='?') p[2][j]=p[2][j+1]+1;
            else p[2][j]=p[2][j+1];
        }
    }
    for (int j=S.length()-1;j>=0;j--){
        if (j==S.length()-1) p[3][j]=0;
        else {
            if (S[j+1]=='C') p[3][j]=p[3][j+1]+1;
            else p[3][j]=p[3][j+1];
        }
    }
    int count=0;
    for (int i=0;i<S.length();i++){
        if (S[i]=='?') count++;
    }
    
    long long int a=1, b=1,c=1,d=1;
    if (count==2) {
        c=3; d=9;
    }
    else if (count==3){
        b=3; c=9; d=27;
    }
    else if(count>=4){
        for (int i=1;i<=count-3;i++){
            a=a*3%1000000007;
        }
        b=a*3%1000000007; c=b*3%1000000007; d=c*3%1000000007;
    }
    long long int ans=0;
    for (int i=0;i<S.length();i++){
        if (S[i]=='B') {
            long long int e,f,g;
            e=p[1][i]*p[3][i]*d%1000000007;
            f=(p[1][i]*(p[2][i]-p[3][i])+(p[0][i]-p[1][i])*p[3][i])*c%1000000007;
            g=(p[2][i]-p[3][i])*(p[0][i]-p[1][i])*b%1000000007;
            ans += (e+f+g)%1000000007;
        }
        else if (S[i]=='?'){
            long long int e,f,g;
            e=p[1][i]*p[3][i]*c%1000000007;
            f=(p[1][i]*(p[2][i]-p[3][i])+(p[0][i]-p[1][i])*p[3][i])*b%1000000007;
            g=(p[2][i]-p[3][i])*(p[0][i]-p[1][i])*a%1000000007;
            ans += (e+f+g)%1000000007;
        }
        ans%=1000000007;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 3584
<?php
list( $x, $y, $z, $k ) = explode( " ", trim(fgets(STDIN)) );

$a = explode( " ", trim(fgets(STDIN)));
$b = explode( " ", trim(fgets(STDIN)));
$c = explode( " ", trim(fgets(STDIN)));
rsort( $a );
rsort( $b );
rsort( $c );

$ab =[];
for( $i=0; $i<$x; $i++ )
{
	for( $j=0; $j<$y; $j++ )
	{
		$ab[] = $a[$i]+$b[$j];
	}
}
unset($a);
unset($b);
rsort( $ab );

$max = min(3000,count($ab));
for( $i=0; $i<$max; $i++ )
{
	for( $j=0; $j<$z; $j++ )
	{
		$abc[] = $ab[$i]+$c[$j];
	}
}

unset($c);
unset($ab);
rsort($abc);
$result = [];
for( $i=0; $i<$k; $i++ )
{ $result[] = $abc[$i]; }


echo implode( "\n",  $result );

Measured memory_bytes: 170460
using System;
public class ITP1_9_A
{
	public static void Main()
	{
	int n = int.Parse(System.Console.ReadLine());
	int a = 0;
	int b = 0;
	for (int i = 0; i < n; i++)
	{
		string[] data = System.Console.ReadLine().Split(' ');
		int c = data[0].CompareTo(data[1]);
		if (c == -1)
		{
			b += 3;
		}
		else if (c == 1)
		{
			a += 3;
		}
		else
		{
			a++;
			b++;
		}
	}
	System.Console.WriteLine("{0} {1}", a, b);
	}
}

Measured memory_bytes: 9932
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
 
typedef long long LL;
const int MAXN = 1234567;
int n,K;
struct D{
	int a,b;
}num[MAXN];
LL ans;
 
int main(){
	scanf("%d%d",&n,&K);
	K++;
	int i,opt;
	for(i=1;i<=n;i++){
		scanf("%d%d",&num[i].a,&num[i].b);
	}
	int Same=0;
	for(opt=30;opt>=0;opt--){
		LL tmp=0;
		if(K&(1<<opt)){
			Same^=(1<<opt);
			for(i=1;i<=n;i++){
				if((num[i].a & Same)==0){
					tmp+=num[i].b;
				}
			}
			Same^=(1<<opt);
		}
		else
			Same^=(1<<opt);
		ans=max(ans,tmp);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 896
#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 <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#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 <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;

int gcd(int a, int b) {
	if (a > b) {
		int c = a;
		a = b;
		b = c;
	}
	if (a == 0) {
		return b;
	}

	return gcd(b % a, a);
}

int lcm(int a, int b) {
	int GCD = gcd(a, b);
	return a * b / GCD;
}

bool isValid(int sugar,int Ls,int c,int d) {
	for (int cc = 0; cc <= Ls / c; cc++) {
		for (int dd = 0; dd <= Ls / d; dd++) {
			int k = (sugar - c * cc - d * dd);
			if (k%Ls==0 && k>= 0) return true;
		}
	}

	return false;
}

int main() {
	long double a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
	int Ls = lcm(c, d);
	int L = lcm(a, b);
	long double g = 0;
	vi ans(2);
	for (long double sugar = 0; sugar <= e * f / 100; sugar++) {
		if (!isValid(sugar, Ls, c, d)) continue;

		long double low = sugar / e, high = (f - sugar) / 100;
		int l = int(low), h = int(high);
		l =  l / L;
		h = (h+L-1) / L;
	
		
		for (int t = l; t <= h; t++) {
			bool flag = false;
			for (int aa = 0; aa <= L / a; aa++) {
				for (int bb = 0; bb <= L / b; bb++) {
					long double water = 100 * (t * L + aa * a + bb * b);
					if (water + sugar <= f && water > 0) {
						if (g <= sugar / water && sugar / water <= e/100) {
							//cout << aa << "x" << bb << "x" << t << "s" << sugar << "g" << g << endl;			
							//cout << "water:" << water << endl;
							g = sugar / water;
							ans[0] = water;
							ans[1] = sugar;
							flag = true;
						}
					}
				}
			}
			if (flag) break;
		}
	}
	cout << ans[0] + ans[1] << " " << ans[1] << endl;
}


Measured memory_bytes: 3720
N,Q = map(int,input().split())
S = input()

cnt = [0]*(N+1)
for i in range(N):
    if S[i:i+2] == 'AC':
        cnt[i+1] = cnt[i]+1
    else:
        cnt[i+1] = cnt[i]
    
#print(cnt)

for q in range(Q):
    l,r = map(int,input().split())
    print(cnt[r-1]-cnt[l-1])

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

int main() {
  int N, x, S=0, c=1;
  cin >> N;
  
  vector<int> A(N);

  for (int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  x = A.at(0);
  
  for (int i = 1; i < N; i++){
    if (A.at(i) == x){
      c += 1;
    }
    else{
      S += c / 2;
      c = 1;
    }
    x = A.at(i);
  }

  S += c / 2;
  
 cout << S << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;
 
const int MAXN = 5e5 + 10;
const int MAXM = 1e6 + 10;
int N, K;
int P[MAXN], A[MAXN];
int cnt = 1, Head[MAXN], Next[MAXM], To[MAXM];
int deg[MAXN];
int tr[MAXN << 2];
 
inline void add_edge(int x, int y) {
	Next[++cnt] = Head[x], To[cnt] = y, Head[x] = cnt; ++deg[y];
}
 
inline void build(int rt, int l, int r) {
	tr[rt] = N + 1;
	if(l == r)
		return;
	int mid = (l + r) >> 1;
	build(rt << 1, l, mid), build(rt << 1 | 1, mid + 1, r);
}
 
inline void upd(int rt, int l, int r, int x, int d) {
	if(l == r)
		return tr[rt] = d, void();
	int mid = (l + r) >> 1;
	if(x <= mid) upd(rt << 1, l, mid, x, d);
	else upd(rt << 1 | 1, mid + 1, r, x, d);
	tr[rt] = min(tr[rt << 1], tr[rt << 1 | 1]);
}
 
inline int qry(int rt, int l, int r, int x, int y) {
	if(x <= l && r <= y)
		return tr[rt];
	if(y < l || r < x)
		return N + 1;
	int mid = (l + r) >> 1, res = N + 1;
	if(x <= mid) res = min(res, qry(rt << 1, l, mid, x, y));
	if(mid < y) res = min(res, qry(rt << 1 | 1, mid + 1, r, x, y));
	return res;
}
 
int main() {
	register int i;
	scanf("%d%d", &N, &K);
	for(i = 1; i <= N; ++i)
		scanf("%d", P + i), A[P[i]] = i;
	build(1, 1, N);
	for(i = N; i; --i) {
		int tp1 = qry(1, 1, N, max(A[i] - K + 1, 1), A[i]);
		int tp2 = qry(1, 1, N, A[i], min(A[i] + K - 1, N));
		if(tp1 <= N) add_edge(A[i], A[tp1]);
		if(tp2 <= N) add_edge(A[i], A[tp2]);
		upd(1, 1, N, A[i], i);
	}
	priority_queue<int> q;
	for(i = 1; i <= N; ++i)
		if(!deg[i])
			q.push(-i);
	int t = 0;
	while(!q.empty()) {
		int x = -q.top(); q.pop();
		P[x] = ++t;
		for(i = Head[x]; i; i = Next[i])
			if(!(--deg[To[i]]))
				q.push(-To[i]);
	}
	for(i = 1; i <= N; ++i)
		printf("%d\n", P[i]);
	return 0;
}

Measured memory_bytes: 27764
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

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

  vector<long long int> l(n+1);
  l[0] = 2;
  l[1] = 1;

  for(int i = 2; i <= n; i++){
    l[i] = l[i - 1] + l[i - 2];
  }
  cout << l[n] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
using namespace std;

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

int main(){
    int n,m,q; cin>>n>>m>>q;
    int a[501][501]={};
    FOR(i,0,m){
        int l,r; cin>>l>>r;
        a[l][r]++;
    }
    ROF(i,0,501){
        FOR(j,1,501){
            a[i][j]+=a[i][j-1];   
        }
    }
    FOR(j,0,501){
        ROF(i,0,500){
            a[i][j]+=a[i+1][j];   
        }
    }
    FOR(i,0,q){
        int p,qq; cin>>p>>qq;
        co(a[p][qq]);
    }
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main() {
	int N, M; cin >> N >> M;
	vector<pair<int, int>> vec(N);

	int A, B;
	for (int i = 0; i < N; i++) {
		cin >> A >> B;
		vec[i] = make_pair(A, B);
	}

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

	int count = 0, shop = 0;
	long long money = 0;
	while(true){
		if (M - count > vec[shop].second) {
			money += (long)vec[shop].first * vec[shop].second;
			count += vec[shop].second;
			shop++;
		}
		else {
			money += (long)vec[shop].first * (M - count);
			break;
		}
	}
	cout << money;
	
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
t,a = map(int,input().split())
l = list(map(int,input().split()))
def opt():
  tmp = abs(t-l[0]*0.006-a)
  ans = 1
  for i in range(1,n):
    if abs(t-l[i]*0.006-a) < tmp:
      tmp = abs(t-l[i]*0.006-a)
      ans = i+1
  return ans
print(opt())

Measured memory_bytes: 3060
// 連立方程式
import 'dart:io';

void main() {
  bool yes;
  yes = false;
  List ny = stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();
  for (int a = 0; a <= ny[0]; a++) {
    for (int b = 0; b <= (ny[0] - a); b++) {
      if (10000 * a + 5000 * b + 1000 * (ny[0] - b - a) == ny[1]) {
        // cを予め変換してfor文を一個減らす
        print("$a $b ${ny[0] - b - a}");
        yes = true;
        break;
      }
    }
    if (yes == true) break;
  }
  if (yes == false) print("-1 -1 -1");
}


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

struct Edge {
    int from, to, cost;
    Edge () {}
    Edge (int from, int to, int cost ) : from(from), to(to), cost(cost) {}
};

vector < int > BellmanFord(int V, vector < Edge > &edges, int s, int t)
{
    constexpr int INF = (1 << 30) - 1;
    vector < int > d(V, INF);
    d[s] = 0;
    for ( int i = 0; i < 2 * V; i++ ) {
        for ( auto &e : edges ) {
            if ( d[e.from] != INF && d[e.to] > d[e.from] + e.cost ) {
                d[e.to] = d[e.from] + e.cost;
                if ( i >= V - 1 ) {
                    if ( i == V - 1 ) d[e.to] = -INF;
                    if ( e.to == t ) return ( vector < int > () );
                }
            }
        }
    }
    return ( d );
}

int main()
{
    int N, M, P;
    vector < Edge > edges;
    vector < int > ans;
    
    cin >> N >> M >> P;
    for ( int i = 0; i < M; i++ ) {
        int from, to, cost;
        cin >> from >> to >> cost;
        edges.emplace_back(from - 1, to - 1, -cost + P);
    }
    
    ans = BellmanFord(N, edges, 0, N - 1);

    if ( ans.size() == 0 ) {
        cout << -1 << endl;
    } else {
        cout << max(0, -ans[N - 1]) << endl;
    }

    return ( 0 );
}


Measured memory_bytes: 384
def deg(x):
    return t - x * 0.006


n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

tmp = 1001001001
ans = 1
for i in range(len(h)):
    d = deg(h[i])
    if abs(a - d) < tmp:
        ans = i + 1
        tmp = abs(a - d)
print(ans)


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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N, K;
	
	cin>>N>>K;
	
	cout<<min(N%K, K-N%K)<<endl;
	
	return 0;
}

Measured memory_bytes: 256
# coding:utf-8

def bellman_ford(V, E, s):
    """ 始点sから残りのノードへの最短経路を求めるベルマンフォード法
    :param V: 頂点数
    :param E: (ノード1, ノード2, コスト)のタプルのリスト
    :param s: 始点とするノード
    :return : (距離リスト, 最短経路, 負の辺によるループが存在するか)a
    """
    ##### 前処理 #####
    from collections import defaultdict
    # INFの定義
    INF = 2**63 - 1
    INF = -INF
    # 最短経路情報を格納する辞書
    dist = defaultdict(lambda: INF) # 始点から始点への移動コスト
    dist[s] = 0
    # 移動経路の履歴
    pre = {}

    ##### 最短経路算出 #####
    # 高々|V|-1回の探索でいい(|V|回以上更新がある場合は負の閉路が存在)
    for i in range(V-1):
        for n1, n2, w in E:
            # 始点からi回の探索でたどり着けない頂点は考慮しない
            # 始点 -> n2 までの最短距離 > 始点 -> n1 までの最短距離 + n1 -> n2 への移動コスト
            # の場合より短い経路が発見できたと言うことなので情報を更新
            if dist[n1] != INF and dist[n2] < dist[n1] + w:
                dist[n2] = dist[n1] + w
                pre[n2] = n1

    ##### 負の閉路検出 #####
    is_cycle = False
    for n1, n2, w in E:
        # 正しい最短距離が求まったと仮定(重要)
        # 始点 -> n1 までの最短距離 + n1 -> n2 への移動コスト < 始点 -> n2 までの最短経路
        if dist[n1] + w > dist[n2]:
            is_cycle = True

    is_cycle = checkpath(pre, V, s)
            
    return (dist, pre, is_cycle)


def checkpath(pre, N, s):
    if s in pre and pre[N] == s and pre[s] == N:
        return True
    count = 0
    p = pre[N]
    while p != s:
        p = pre[p]
        #print(p, pre)
        if p == s and s in pre:
            return True
        count += 1
        if count >= N-1:
            return True
    return False

def main():
    # 頂点，辺の数
    N, M = map(int, input().split(' '))
    # 辺の情報
    E = []
    for _ in range(M):
        a, b, c = map(int, input().split(' '))
        E.append((a, b, c))
    # 始点
    s = 1

    # ベルマンフォードる
    dist, pre, is_cycle = bellman_ford(N, E, s)

    #print(dist)
    #print(pre)
    #print(is_cycle)
    
    if is_cycle:
        print("inf")
    else:
        print(dist[N])



if __name__ == '__main__':
    main()

Measured memory_bytes: 3820
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <iomanip>
#include<queue>
#include<algorithm>
#include <functional>
#include<vector>
#include <math.h>
#include <numeric>
#include <stack>
#include <map>
using namespace std;

const int N_MAX = 101;
int N, X;
int L;
int P = 0;

int main() {
	cin >> N >> X;
	int i = 0;
	while (i <= N) {
		cin >> L;
		i++;
		P += L;
		if (P > X) break;
	}
	cout << i << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();

		if (a > x){
			System.out.println("NO");
		} else if (a + b < x){
			System.out.println("NO");
		} else {
			System.out.println("YES");
		}
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin >> a >> b >> c;
  cout << a+b+c-max(a,(max(b,c))) << endl;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int W, H;
char B[30][30];

int dfs(int y, int x) {
   int ret = 1;
   B[y][x] = '#';
   rep (i, 4) {
      int nx = x + dx[i], ny = y + dy[i];
      if (nx < 0 || nx >= W || ny < 0 || ny >= H || B[ny][nx] == '#') continue;
      ret += dfs(ny, nx);
   }
   return ret;
}

void solve() {
   rep (i, H) {
      cin >> B[i];
   }
   rep (i, H) {
      rep (j, W) {
         if (B[i][j] == '@') {
            cout << dfs(i, j) << endl;
            return;
         }
      }
   }
}

int main() {
   while (1) {
      cin >> W >> H;
      if (H*W == 0) break;
      solve();
   }

   return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j) vector<vector<ll>> name(i,vector<ll>(j))
#define vec2f(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k)))
#define vec3f(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define vec4(name,i,j,k,l) vector<vector<vector<vector<ll>>>> name(i,vector<vector<vector<ll>>>(j,vector<vector<ll>>(k,vector<ll>(l))))
#define vec4f(name,i,j,k,l,m) vector<vector<vector<vector<ll>>>> name(i,vector<vector<vector<ll>>>(j,vector<vector<ll>>(k,vector<ll>(l,m))))
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000 //14
#define N 101010
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

int main(){
    ll n, m, x, y; cin >> n >> m;
    vector<vector<ll>> a(N);
    REP(i,n){
        cin >> x >> y;
        if (m-x>=0) a[m-x].pb(y);
    }
    priority_queue<ll, vector<ll>, less<ll>> q;
    ll ans = 0;
    FORD(i,m,0){
        REP(j,a[i].size())q.push(a[i][j]);
        if (q.size()) {
            ans+=q.top();
            q.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

struct Edge {
	int to;
	int cost;
	int coin_cost;
	
	Edge(int to, int cost, int coin_cost) : to(to), cost(cost), coin_cost(coin_cost) {}
};

using ppi = pair <ll, pii>;

const int MAX = 55;
vector <Edge> adj[MAX];
int C[MAX], D[MAX];

int main()
{
	boost;
	int n, m, s, i;
	cin >> n >> m >> s;
	
	s = min(s, n * 50);
	fo(i, 0, m) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		adj[a].eb(b, d, c);
		adj[b].eb(a, d, c);
	}
	
	foe(i, 1, n)
	cin >> C[i] >> D[i];
	
	vector <vector <ll> > dp(n + 1, vector <ll> (n * 50, inf64));
	dp[1][s] = 0;
	
	priority_queue <ppi, vector <ppi>, greater <ppi> > pq;
	pq.emplace(0, mk(1, s));
	
	while(!pq.empty()) {
		ll curr_cost = pq.top().f;
	    auto [node, coins] = pq.top().s;
		pq.pop();
		
		if(dp[node][coins] < curr_cost) continue;
		
		if(coins + C[node] < n * 50 && dp[node][coins + C[node]] > curr_cost + D[node]) {
			dp[node][coins + C[node]] = curr_cost + D[node];
			pq.emplace(curr_cost + D[node], mk(node, coins + C[node]));
		}
		
		for(auto &[to, cost, coin_cost] : adj[node]) {
			if(coins < coin_cost) continue;
			if(dp[to][coins - coin_cost] > curr_cost + cost) {
				dp[to][coins - coin_cost] = curr_cost + cost;
				pq.emplace(curr_cost + cost, mk(to, coins - coin_cost));
			}
		}
	}
	for(int i = 2; i <= n; i++)
	cout << *min_element(dp[i].begin(), dp[i].end()) << '\n';
}


Measured memory_bytes: 6340
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;

int N,M;
int B[30];
int A[30][30];
int C;

int main()
{
  cin >> N >> M >> C;
  REP(j,0,M) cin >> B[j];
  REP(i,0,N) REP(j,0,M) cin >> A[i][j];

  int res = 0;
  REP(i,0,N) {
    int x = 0;
    REP(j,0,M) x += A[i][j] * B[j];
    x += C;
    if (x > 0) ++res;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
const LL LINF = 0x3f3f3f3f3f3f3f3f; 
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1e9+7;
const ULL P = 131;
const int N = 2e5+7;


int main()
{
		int n,x,t;
		cin>>n>>x>>t;
		cout<<t*(int)ceil((double)n/x)<<"\n";
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll N;
vector<P> A;
vector<vector<ll>> dp;

ll dfs(ll l, ll r) {
    if (dp[l][r] != INF) {
        return dp[l][r];
    }
    if (abs(l - r) == 1) {
        return dp[l][r] = 0;
    } else if (abs(l - r) == 2) {
        P f = A[l];
        P s = A[l + 1];
        return dp[l][r] = f.first * f.second * s.second;
    }

    ll res = INF;
    for (ll k = l + 1; k < r; k++) {
        res = min(res, dfs(l, k) + dfs(k, r) + A[l].first * A[r - 1].second * A[k - 1].second);
    }
    return dp[l][r] = res;
}

void solve() {
    cin >> N;
    A.resize(N);
    dp.resize(N + 1, vector<ll>(N + 1, INF));
    rep(i, N) cin >> A[i].first >> A[i].second;
    cout << dfs(0, N) << '\n';
}

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



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


int main() {

	int n;
	int *w;
	int dp[301][301];
	int i,j,k;

	for(;;) {
		scanf("%d",&n);
		if(n==0)
			break;
		w = malloc((n+1) * sizeof(int));
		//dp = malloc((n+1) * sizeof(int));
		//for(i=0;i<=n;i++)
			//dp[i]=malloc((n+1) * sizeof(int));

		for(i=0;i<n;i++)
			scanf("%d",&w[i]);

		for(i=0;i<n+1;i++)
			for(j=0;j<n+1;j++)
				dp[i][j]=0;;

		//??????DP
		for(i=n-1;i>=0;i--) {
			dp[i][i]=0;
			dp[i][i+1]=0;
			for(j=i+1;j<=n;j++) {
				if(i+1<j&&abs(w[i]-w[j-1])<=1&&dp[i+1][j-1]==j-i-2)
					dp[i][j]=j-i;
				for(k=j+1;k<=n;k++) {
					if(dp[i][k]<(dp[i][j]+dp[j][k]))
							dp[i][k]=dp[i][j]+dp[j][k];
				}
			}
		}
		printf("%d\n",dp[0][n]);
		free(w);
	}

	return 0;
}

Measured memory_bytes: 2092
all_num = int(input())
nums = []
for i in range(all_num):
    nums.append( int(input()) )
	
nums = sorted(nums)

sort_nums = []
loop_num = int(all_num/2)
for i in range( loop_num ):
    if i % 2 == 0:
        sort_nums.append(nums[i])
        sort_nums.insert(0,nums[-(i+1)])
    else:
        sort_nums.insert(0,nums[i])
        sort_nums.append(nums[-(i+1)])
    
if len( nums ) % 2 == 1:
    center_index = int(len(nums)/2)
    center_num = nums[center_index]
    if abs(center_num - sort_nums[0]) > abs(center_num - sort_nums[-1]):
        sort_nums.insert(0,center_num)
    else :
        sort_nums.append(center_num)


total = 0
for i in range( len(sort_nums)-1 ):
    total = total + abs(sort_nums[i] - sort_nums[i+1])

print(total)

Measured memory_bytes: 8284
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<int> r;
  vector<int> g;
  vector<int> b;
  set<int> rs;
  set<int> gs;
  set<int> bs;
  for(int i=0; i<n; i++){
    if(s[i]=='R'){
      r.push_back(i);
      rs.insert(i);
    }else if(s[i]=='G'){
      g.push_back(i);
      gs.insert(i);
    }else if(s[i]=='B'){
      b.push_back(i);
      bs.insert(i);
    }
  }
  long long int ans=0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      if(s[i]!=s[j]){
        if(s[i]!='R'&&s[j]!='R'){
          auto itr=upper_bound(r.begin(),r.end(),j);
          int pre=itr-r.begin();
          pre=r.size()-pre;
          if(rs.count(2*j-i)){
            pre--;
          }
          ans+=pre;
        }else if(s[i]!='G'&&s[j]!='G'){
          auto itr=upper_bound(g.begin(),g.end(),j);
          int pre=itr-g.begin();
          pre=g.size()-pre;
          if(gs.count(2*j-i)){
            pre--;
          }
          ans+=pre;
        }else if(s[i]!='B'&&s[j]!='B'){
          auto itr=upper_bound(b.begin(),b.end(),j);
          int pre=itr-b.begin();
          pre=b.size()-pre;
          if(bs.count(2*j-i)){
            pre--;
          }
          ans+=pre;
        }
      }
    }
  }
  cout<<ans<<endl;
}

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

int main(){
	int a,b;
	cin>>a>>b;

	if(a < b) cout<<"a < b"<<endl;
	if(a > b) cout<<"a > b"<<endl;
	if(a == b) cout<<"a == b"<<endl;

	return 0;
}


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

int main() {
  int x,y;
  int i=1;
  cin >> x >> y;
  while(x!=0 || y!=0) {
      if (x>y) {
          cout << y << " " << x << endl;
      }
      else {
          cout << x << " " << y << endl;
      }
      i++;
      cin >> x >> y;
  }
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  ll m;
  cin >> m;
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    reverse(v.begin()+a, v.begin()+b);
  }
  rep(i, n) {
    if (i) {
      cout << ' ' << v.at(i);
    } else {
      cout << v.at(i);
    }
  }
  cout << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, long long L)
{
    ll sum = 0;
    ll ans = INT_MAX;
    for (int i = 1; i <= N; i++)
    {
        sum += (L + i - 1);
    }

    for (int i = 1; i <= N; i++)
    {
        ll tmp = sum - L - i + 1;
        if (abs(sum - tmp) < abs(sum - ans))
        {
            ans = tmp;
        }
    }

    cout << ans << endl;
    return;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long L;
    scanf("%lld", &L);
    solve(N, L);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
#define all(x) x.begin(),x.end()
const int inf=0x3f3f3f3f;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int N; cin>>N;
    bool flag=0;
    while(N){
    	flag|=(N%10==7);
    	N/=10;
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
   return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, m, qu, ans = MINF;
ll q[100][4];
vector<ll> s;
void dfs(ll a, ll b) {
	if (b != -1)s.push_back(b);
	if (a == n) {
		ll now = 0;
		REP(i, qu) {
			if (s[q[i][1]] - s[q[i][0]] == q[i][2]) now += q[i][3];
		}
		ans = max(ans, now);
	}
	else {
		FOR(i, max(1ll, b), m + 1) {
			dfs(a + 1, i);
		}
	}
	if (b != -1)s.pop_back();
}
int main() {
	
	cin >> n >> m >> qu;
	REP(i, qu) {
		REP(j, 4) {
			cin >> q[i][j];
		}
		q[i][0]--;
		q[i][1]--;
	}
	dfs(0, -1);
	cout << ans << endl;
}
 

Measured memory_bytes: 3636
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#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__) << "] "
typedef long long ll;
int n ; 
vector<ll> v ; 
vector<ll> dp ; 
int dfs(int x){
	if ( x == n-1 ) return 0 ; 
	if ( dp[x] != 1e9 ) return dp[x] ; 
	int first = 1e9 ; 
	if ( x < n-2 )
		first = abs(v[x]-v[x+2]) + dfs(x+2) ; 
	int second = 1e9 ; 
	if ( x < n-1 )
		second = abs(v[x]-v[x+1]) + dfs(x+1) ; 
	dp[x] = min(second,first) ; 
	return dp[x] ; 
}
int main(){
	cin >> n ; 
	v.resize(n) ; 
	dp.resize(n+2,1e9) ; 
	for(int i=0;i<n;i++){
		cin >> v[i] ; 
	}
	cout << dfs(0) << endl;
    return 0 ;
}


Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int x = scanner.nextInt();
		int[] a = new int[m];
		int count = 0;
		
		for(int b = 0; b < m; b++) {
			a[b] = scanner.nextInt(); 
		}
		for(int r = 0; r < m; r++) {
			if(a[r] < x) {
				count++;
			}else {
				break;
			}
		}
		int ans = a[0] > x ? 0 : Math.min(a.length - count , count);
		System.out.println(ans);
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	int i;
	for(i=0;i<n;i++)
	cin>>a[i];
	int b[n];
	memset(b,0,sizeof(b));
	b[1]=abs(a[1]-a[0]);
	for(i=2;i<n;i++)
		b[i]=min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]));
	cout<<b[n-1];
}

Measured memory_bytes: 4392
#include<bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define mp make_pair
#define PI acos(-1)
using namespace std;
const int mod = 1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll i,j,k,x,y,z,m,t,n,b,c,d,a,l,r;
    cin >> n;
    vector<ll>v(n);
    for (ll i = 0; i < n; i++)
        cin >> v[i];
    vector<ll> cum(n);
    cum[0] = v[0];
    for (int i = 1; i < n; i++)
        cum[i] = cum[i - 1] + v[i];
    ll ans = 0;
    for (ll i = 0; i < n - 1; i++)
    {
        ll temp=(v[i] % mod)*((cum[n - 1] - cum[i])%mod);
        temp%= mod;
        ans=(ans+temp)%mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6376
<?php
while( fscanf( STDIN, "%d", $n ) ){
  $cnt=0;
  for($a=0;$a<10;$a++){
    for($b=0;$b<10;$b++){
      $t=$a+$b;
      for($c=0;$c<10;$c++){
        $u=$t+$c;
        $d=$n-$u;
        if($d<0) continue;
        if($d>9) continue;
        ++$cnt;
      }
    }
  }
  printf("%d\n",$cnt);
}

Measured memory_bytes: 15328
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main(void)
{
  string str;
  cin >>str;
  int num;
  cin >> num;
  string str2;
  for(unsigned int i=0;i<ceil((double)str.size()/num) ;i++)
  {
    str2+= str[i*num];
  }
  cout << str2;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }


        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var ABCD = Sarray();
            var A = ABCD[0];
            var B = ABCD[1];
            var C = ABCD[2];
            var D = ABCD[3];
            var koubai = lcm(C, D);
            var bnum = B - (B / C + B / D - B / koubai);
            var amnum = A - 1 - ((A - 1) / C+(A - 1) / D - (A - 1) / koubai);
            WriteLine(bnum - amnum);
            //Out.Flush();
        }
        static long gcd(long x, long y) => y == 0 ? x : gcd(y, x % y);
        static long lcm(long x, long y) => x * y / gcd(x, y);
    }
}

Measured memory_bytes: 13396
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String S = sc.next();
		List<Integer> list = new ArrayList<Integer>();
		list.add(0);
		for (int i = 0; i < S.length(); i++) {
			char t = S.charAt(i);
			if (t != 'A' && t !='C' && t != 'G' && t != 'T') {
				list.add(i+1);
			}
		}
		list.add(S.length()+1);
		int ans = 0;
		for (int i = 0; i < list.size() -1; i++) {
			int t = list.get(i+1) - list.get(i) - 1;
			if (t > ans) {
				ans = t;
			}
		}
		System.out.println(ans);
	}
}

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

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

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

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

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

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

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

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

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

Measured memory_bytes: 21332
import sys

input = sys.stdin.readline


def main():
    K, S = map(int, input().split())

    ans = 0
    X_max = min(S, K)
    for X in range(X_max + 1):
        Y_max = min(S - X, K)
        for Y in range(Y_max + 1):
            Z = S - (X + Y)
            if 0 <= Z <= K:
                ans += 1
            else:
                continue
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>

using namespace std;

int main()
{
	int a,b,c;

	cin >> a >> b >> c;

	if(a < b && b < c){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <stdlib.h>
#pragma GCC optimize ("O3")

inline static int gl(void){
    int x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

inline static void pl(unsigned int s){
    char str[9];
    int pos=9;
    if(s==0){
        putchar_unlocked('0');
        return;
    }
    do{
        pos--;
        str[pos]=s%10+48;
        s/=10;
    }while(s!=0);
    for(; pos<9; pos++){
        putchar_unlocked(str[pos]);
    }
}

inline static int sp(char* str, unsigned short i){
    if(i>99){
        char c0 = i%10; i/=10;
        char c1 = i%10; i/=10;
        str[0] = i+48;
        str[1] = c1+48;
        str[2] = c0+48;
        return 3;
    }else if(i>9){
        char c0 = i%10; i/=10;
        str[0] = i+48;
        str[1] = c0+48;
        return 2;
    }else{
        str[0] = i+48;
        return 1;
    }
}

char a[1001];
char buffer[8*1024*1024];

int main(void){
    const int h=gl(), w=gl();
    int p = 0;
    int pos=0;
    {
        char haveCoin = 0;
        short old_y, old_x;
        for(int i=1; i<=h; i++){
            //fgets_unlocked(a, 1001, stdin);
            fread(a, 1, 2*w, stdin);
            if(i%2==1){
                for(int j=1; j<=w; j++){
                    if(haveCoin){
                        pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin ^= a[(j-1)*2]&1;
                    old_y = i;
                    old_x = j;
                }
            }else{
                for(int j=w; j>0; j--){
                    if(haveCoin){
                        pos++;
                        p += sp(buffer+p, old_y)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, old_x)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, i)+1; buffer[p-1] = ' '; 
                        p += sp(buffer+p, j)+1; buffer[p-1] = '\n';
                    }
                    haveCoin ^= a[(j-1)*2]&1;
                    old_y = i;
                    old_x = j;
                }
            }
        }
    }
    pl(pos); putchar_unlocked('\n');
    fwrite(buffer, 1, p, stdout);
    return 0;
}


Measured memory_bytes: 3840
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int N = in.nextInt();
		int num = 0;
		int tmp = N;
		while(N>=10) {
			num += N%10;
			N = N/10;
		}
		num += N;
		if(tmp%num==0) {
			System.out.print("Yes");
		}else {
			System.out.print("No");
		}
		in.close();
		
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, K;
  cin >> N >> K;

  if(N < K / 2){
    cout << 0 << "\n";
    return 0;
  }
  
  ll n1 = N / K;
  ll ans = n1 * n1 * n1;

  if(K % 2 == 0){
    n1 = (N - K / 2) / K + 1;
    ll tmp = n1 * n1 * n1;
    ans += tmp;
  }

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


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int h,w;
  cin>>h>>w;
  char a[h][w];
  int b[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
      if(a[i][j]=='#') b[i][j]=1;
      else b[i][j]=-1;
    }
  }
  bool flg=1;
  for(int i=0;i<h;i++){
    flg=1;
    for(int j=0;j<w;j++){
      if(b[i][j]==1) flg=0;
    }
    if(flg){
      for(int j=0;j<w;j++){
        b[i][j]=0;
      }
    }
  }
  
  for(int j=0;j<w;j++){
    flg=1;
    for(int i=0;i<h;i++){
      if(b[i][j]==1) flg=0;
    }
    if(flg){
      for(int i=0;i<h;i++){
        b[i][j]=0;
      }
    }
  }
  
  bool flg2=0;
  for(int i=0;i<h;i++){
    flg2=0;
    for(int j=0;j<w;j++){
      if(b[i][j]!=0){
        cout<<a[i][j];
        flg2=1;
      }
    }
    if(flg2) cout<<endl;
  }
  
}

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

using namespace std;

int dp[3010][3010];
string result;
int lcs(string str1, string str2, int s1, int s2)
{
	for (int i = 0 ; i <= s1 ; i++)
	{
		for (int j = 0 ; j <= s2 ; j++)
		{
			if (i == 0 || j == 0) dp[i][j] = 0;
			else if (str1[i-1] == str2[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
			else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
		}
	}
	return dp[s1][s2];		
} 
string print(string str1, string str2, int s1, int s2)
{
	int i = s1;
	int j = s2;
	int l_lcs = lcs(str1,str2,s1,s2);
	string result;
	result.resize(l_lcs);
	while (i > 0 && j > 0)
	{
		if (str1[i-1] == str2[j-1])
		{
			result[l_lcs - 1] = str1[i-1];
			i--;
			j--;
			l_lcs--;
		}
		else
		{
			if (dp[i-1][j] > dp[i][j-1]) i--;
			else j--;
		}
	}
	return result;	
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string str1, str2;
	cin >> str1 >> str2;
	int s1 = str1.size(), s2 = str2.size();
	if (lcs(str1,str2,s1,s2) == 0)
	{
		cout << " \n";
		return 0; 
	}
	else
	{
		cout << print(str1,str2,s1,s2) << "\n";	
		return 0;
	}
	return 0;
}                           

Measured memory_bytes: 35584