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

typedef long long ll;
typedef long double ld;

int mat[505][505];

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n, m, q;
    cin >> n >> m >> q;
    for(int i=1; i<=m; i++){
        int l, r;
        cin >> l >> r;
        mat[l][r]++;
    }
    int tren = 0;
    for(int i=n; i>=1; i--){
        for(int j=1; j<=n; j++){
            //tren += mat[i][j];
            mat[i][j] = mat[i][j] + mat[i+1][j] + mat[i][j-1] - mat[i+1][j-1];
        }
    }
    while(q--){
        int l, r;
        cin >> l >> r;
        cout << mat[l][r] << "\n";
    }
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>

int main(void) {
    int h, w;
    
    std::cin >> h >> w;
    
    std::vector< std::vector <int> > a(h, std::vector<int>(w, 0));
    
    for(int i = 0; i < h; i++) {
        std::string line;
        std::cin >> line;
        for(int j = 0; j < w; j++) {
            if(line[j] == '.') a[i][j] = 0;
            else a[i][j] = 1;
        }
    }
    
    
    std::vector <bool> col(w, false);
    std::vector <bool> row(h, false);
    
    
    for(int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if(a[i][j] == 1){
                row[i] = true;
                col[j] = true;
            }
        }
    }
    
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++) {
            if(row[i] && col[j]){
                if(a[i][j] == 1) std::cout << '#';
                else std::cout << '.';
            }
        }
        std::cout << std::endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    vector<ll> v(n+1,0);
    for(ll i=2;i<=n;i++){
        ll a;
        cin>>a;
        v[a]+=1;
    }
    for(ll i=1;i<=n;i++){
        cout<<v[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=998244353;
const ll inf=1e16;
const ll ms=(1e5) +5;


char ar[1000];



int main()
{
    idfc;

    ld n;
    cin>>n;
    n/=3;
    n=(n*n*n);
    cout<<fixed;
    cout<<setprecision(10);
    cout<<n;

    return 0;
}

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

using namespace std;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

using LL = long long;
using LD = long double;

const LL MOD = 1e9+7;
const LL INF = LLONG_MAX;
const LL N = 1e6+1;

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

	vector<LL> a(n);

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

	LL cnt = 0;
	for (LL i = 0; i < n; ++i) {
		for (LL j = i+1; j < n; ++j) {
			for (LL k = j+1; k < n; ++k) {
				LL sum = a[i]+a[j]+a[k];
				LL mx = max({a[i], a[j], a[k]});
				if (sum - mx > mx && (a[i] != a[j] && a[j] != a[k] && a[k] != a[i])) {
					cnt++;
				}
			}
		}
	}
	cout << cnt << "\n";



}

Measured memory_bytes: 3656
// https://atcoder.jp/contests/abc137/submissions/6816229
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n, m;
  cin >> n >> m;

  vector<pii> a(n);
  rep(i, n) {
    cin >> a[i].first >> a[i].second;
  }

  sort(all(a));

  priority_queue<int> p;

  int ans = 0;

  int j = 0;
  rep(i, m) {
    while (j < n && a[j].first == i+1) {
      p.push(a[j++].second);
    }

    if (p.size()) {
      ans += p.top();
      p.pop();
    }
  }

  cout << ans << endl;
}



Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 5, mod = 1e9 + 7;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    int ls = s.size(), lm = 0;
    ll ans = 0;
    for (int i = 0; i < ls - 1; ++i){
        if (s[i] == 'B' && s[i + 1] == 'C'){
            ans += i - lm;
            ++lm, ++lm, ++i;
        }else if (s[i] != 'A') lm = i + 1;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i += 2) {
    int cnt = 0;
    repe(j, 1, i) if (i % j == 0) cnt++;
    if (cnt == 8) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
using namespace std;
using lli = long long int;
lli power[50] = {};

lli calc(lli x){
  lli res = 0, digit = 0;
  x++;
  while(x >= power[digit]){
    // std::cout << "x:" << x << std::endl;
    lli one = 0, zero = 0;
    one = zero = (x/power[digit + 1])*power[digit];
    zero += min((x%power[digit + 1]), power[digit]);
    one  += max(0LL, x%power[digit + 1] - power[digit]);
    // std::cout << one << std::endl;
    if(one%2){
      res |= (1LL<<digit);
    }
    // x /= 2;
    digit++;
  }
  // std::cout << res << std::endl;
  // std::cout << std::endl;
  return res;
}

int main(){
  lli a, b;
  power[0] = 1;
  for (int i = 1; i < 50; i++) power[i] = 2*power[i - 1];
  std::cin >> a >> b;
  std::cout << (calc(b)^calc(a - 1)) << std::endl;    
  return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  ll a[N];
  for(int i=0;i<N;i++) cin >> a[i];
  ll sum[N+1];
  sum[0] = 0;
  for(int i=1;i<=N;i++) sum[i] = sum[i-1] + a[i-1];

  ll dp[N][N+1];
  fill(dp[0],dp[N],0LL);

  for(int len = 2; len <= N; len++){
    for(int l = 0; l <= N - len; l++){
      int r = l + len;
      dp[l][r] = 1000000000000000LL;
      for(int p = l + 1; p < r; p++){
        ll tmp = sum[r] - sum[l];
        tmp += dp[l][p] + dp[p][r];
        dp[l][r] = min(dp[l][r], tmp);
      }
    }
  }

  cout << dp[0][N] << endl;
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> B(N-1);
    rep(i,N-1){
        cin >> B[i];
    }
    vector<int> A(N);
    A[N-1] =B[N-2];
    int ans = A[N-1];
    for(int i = N-2;i>0;i--){
        A[i] = min(B[i-1],B[i]);
        ans += A[i];
    }
    ans += B[0];
    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
		long[][] a = new long[n][m];
		long[][] b = new long[m][l];
		//aの配列を格納する
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				a[i][j] = scan.nextInt();
			}
		}
		//bの配列を格納する
		for(int i = 0; i < m; i++){
			for(int j = 0; j < l; j++){
				b[i][j] = scan.nextInt();
			}
		}
		//cを出力するためにa[i][k]*b[k][j]を計算して出力をする
		for(int i = 0; i < n; i++){
			for(int j = 0; j < l; j++){
				long c = 0;
				for(int k = 0; k < m; k++){
					c += a[i][k] * b[k][j];
				}
				if(j != 0) System.out.print(" ");
				System.out.print(c);
			}
			if(i != n) System.out.println();
		}
	}
}

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

using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pback pop_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vis vector<string>
#define vii vector<vector<int>>
#define mii map<int, int>
#define umii unordered_map<int,int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi,greater<int>>
#define setbits(x) __buitin_popcountll(x)
#define zrobits(x) __buitln_ctzll(x)
#define mod 1000000007 //1e9+7
#define inf 1e18
#define ps(x,y) fixed<<setpresicion(y)<<x
#define mk(arr,n,type) type *arr=new type[n]
#define w(x) int x;cin>>x; while(x--)
#define rg 1000005
#define deg(v) cout<<"Value is: "<<v<<endl
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(a,b) for(int i=a;i<b;i++)
#define frev(a,b) for(int i=(int)a;i>(int)b;--i)
//mt19937  ring(chrono: stready_clock::now().time_since_epoch().count)


void IO() {


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


int dp[100005][3];
int vacationMaxCost(int **a, int n) {

	dp[n][0] = a[n][0];
	dp[n][1] = a[n][1];
	dp[n][2] = a[n][2];

	for (int i = n - 1; i >= 1; --i) {

		for (int j = 0; j < 3; j++) {

			if (j == 0) {
				dp[i][j] = max(dp[i + 1][j + 1], dp[i + 1][j + 2]) + a[i][j];
			}
			if (j == 1) {
				dp[i][j] = max(dp[i + 1][j - 1], dp[i + 1][j + 1]) + a[i][j];
			}
			if (j == 2) {
				dp[i][j] = max(dp[i + 1][j - 2], dp[i + 1][j - 1]) + a[i][j];
			}
		}
	}

	int MX = INT_MIN;
	for (int i = 0; i < 3; i++) {
		MX = max(MX, dp[1][i]);
	}
	return MX;
}


int32_t main() {

	FASTIO;
	//IO();

	int n; cin >> n;

	int **a = new int*[n + 1];

	for (int i = 0; i <= n; i++) {
		a[i] = new int[3];
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}

	cout << vacationMaxCost(a, n) << endl;

	return 0;
}


Measured memory_bytes: 9740
from itertools import product

# print('input >>')
N = int(input())
G = []
for i in range(N):
    A_i = int(input())
    edges = {}
    for n in range(A_i):
        edge = tuple(map(int, (input().split())))
        edges[edge[0]] = edge[1]
    G.append(edges)

prods = product([0,1], repeat=N)
ans = 0

for prod in prods:
    flg = True
    for i, h in enumerate(prod):
        if h == 1:  # 正直者ならその人の言うことを調べる
            shougens = G[i]
            for hito, docchi in shougens.items():
                if (docchi == 1 and prod[hito-1] == 0) or (docchi == 0 and prod[hito-1] == 1):
                    flg = False
    if flg:
        ans = max(ans, sum(prod)) # ここまで来れたら矛盾が生じなかった

# print('----------output----------')
print(ans)

Measured memory_bytes: 3064
n = int(input())

a = [False]*107

a[4-1] = True
a[7-1] = True

for i in range (100) :
   if a[i] == True :
      a[i+4] = True
      a[i+7] = True

if a[n-1] == True :
   print('Yes')
else :
   print('No')

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){
	long long ll;

	cin >> ll;
	int count = 0;
	while(true){
		count++;
		if(ll/3 == 0 || ll == 3){
			break;
		}
		int buf=0;
		if(ll%3 != 0){
			buf++;
		}
		ll /= 3;
		ll += buf;
	}
	cout << count << endl;
}

Measured memory_bytes: 0
use std::io::stdin;

#[allow(dead_code)]
fn input_strs() -> Vec<char> {
    let mut s = String::new();
    match stdin().read_line(&mut s) {
        Ok(_) => s.chars().collect(),
        Err(_) => panic!("err"),
    }
}

#[allow(dead_code)]
fn input_ints() -> Vec<u64> {
    let mut st = String::new();
    match stdin().read_line(&mut st) {
        Ok(_) => st.split_whitespace().map(|s| s.parse().unwrap()).collect(),
        Err(_) => panic!("err"),
    }
}

#[allow(unused_variables)]
fn solve() {
    let l = input_ints();
    let n = l[0] as usize;
    let t = l[1];
    let ts = input_ints();

    let mut total_time = t;

    for i in 1..n {
        let sub = ts[i] - ts[i - 1];
        total_time += if sub < t { sub } else { t }
    }

    println!("{}", total_time);

}

fn main() {
    solve();
}



Measured memory_bytes: 10492
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(n); i++)
using namespace std;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;
	sort(S.begin(), S.end());
	bool flag = true;
	REP(i,(int)S.size() )
	{
		int count{};
		REP(j,(int)S.size() ){
			if( S[i] == S[j] ){
				count++;
			}
		}
		if( count % 2 != 0 )
		{
			flag = false;
			break;
		}
	}
	cout << (flag?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

int N, a[200000],x;

int main()
{
    int i,j;
    cin >> N;
    rep0(i,N){cin>>j; x^=j; a[i]=j;}

    rep0(i,N)
    {
       cout << (x^a[i]) << " ";
    }

    cout << endl;
    return 0;
}

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

int main(){
    int N; cin >> N;
    string s;
    int kai = 0;
    for(int i=0;i<N;i++){
        cin >> s[i];
    }
    for(int i=0;i<N;i++){
        if(s[i] == 'Y') kai += 1;
    }
    if(kai == 0){
        cout << "Three" << endl;
    }
    else{
        cout << "Four" << endl;
    }
    return 0;
}

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

void predict (string text) {
    if (text == "Sunny") {
        cout << "Cloudy" << endl;
    }

    else if (text == "Cloudy") {
        cout << "Rainy" << endl;
    }

    else if (text == "Rainy") {
        cout << "Sunny" << endl;
    }

    return;
}

int main() {
    string S;
    cin >> S;
    predict(S);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define v(x) vector<int> x;
#define all(x) x.begin(),x.end()
#define s(x,n) memset(x,n,sizeof(x));
#define pb(x) push_back(x)

using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll x;
    ll j=1,ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        if(x==j)
        {    j++;
            ans++;
        }
    }
    if(ans==0)
        cout<<"-1\n";
    else
        cout<<n-ans<<"\n";
    
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define eachdo(e,array) for(const auto& e : array)
#define upper_index(v,a) (int)distance(v.begin(), upper_bound((v).begin(),(v).end(),a))
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
typedef long long ll;
const ll INF=1LL<<63-1;
const ll MOD=1e9+7;

struct SegmentTree{
private:
    ll unit=0;
    ll op(ll a,ll b){return a+b;}
    int n;
    vector<ll> node;

public:
    SegmentTree(vector<ll> v){
        int sz=v.size();
        n=1;while(n<sz) n*=2;
        node.resize(2*n-1,unit);
        for(int i=0;i<sz;i++) node[i+n-1]=v[i];
        for(int i=n-2;i>=0;i--) node[i]=op(node[2*i+1],node[2*i+2]);
    }

    void update(int x,int val){
        x+=n-1;
        node[x]+=val;
        while(x>0){
            x=(x-1)/2;
            node[x]=op(node[2*x+1],node[2*x+2]);
        }
    }

    int query(int a,int b,int k=0,int l=0,int r=-1){
        if (r<0) r=n;
        if (r<=a || b<=l) return unit;
        if (a<=l && r<=b) return node[k];
        int vl = query(a,b,2*k+1,l,(l+r)/2);
        int vr = query(a,b,2*k+2,(l+r)/2,r);
        return op(vl,vr);
    }
};
int main(){
    int N,Q;cin>>N>>Q;
    SegmentTree BIT(vector<ll>(N,0));
    rep(i,Q){
        int com;cin>>com;
        if(com==0){
            int x,y;cin>>x>>y;--x;
            BIT.update(x,y);
        }else{
            int x,y;cin>>x>>y;--x;
            cout<<BIT.query(x,y)<<'\n';
        }
    }
    return 0;
}


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

int main(){
	int L;
	cin >> L;
	int num = 0;
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a % c == 0) num = max(num, a / c);
	else num = max(num, a / c + 1);
	if(b % d == 0) num = max(num, b / d);
	else num = max(num, b / d + 1);
	cout << L - num << endl;
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,n;cin>>a>>b>>n;
  if(n >= b-1){
    cout<<a*(b-1)/b<<endl;
  }else{
    cout<<a*n/b-a*(n/b)<<endl;
  }
  return 0;
}


Measured memory_bytes: 3652
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

vector<pair<int, int>> v;
//0:siro,1:kuro,2:sirokuro,3:kurosiro
int a[101010];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	v.emplace_back(a[0], 1);
	for (int i = 1; i < n; i++) {
		if (v[v.size() - 1].first != a[i]) {
			v[v.size() - 1].first = a[i];
			v[v.size() - 1].second++;
		}
		else v.emplace_back(a[i], 1);
	}
	int ans = 0;
	if (v.size() == 1)ans = v[0].second;
	else if (v.size() == 2)ans = v[0].second + v[1].second;
	else for (int i = 0; i < v.size() - 2; i++) {
		ans = max(ans, v[i].second + v[i + 1].second + v[i + 2].second);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3744
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#define ll long long
#define ii pair<ll,ll>
#define X first
#define Y second
using namespace std;
const ll maxn = 50;
const ll oo = (ll) 1e9;
ll n,a[maxn+1];
ll maxi,mini,vtmax,vtmin;
ll dem[maxn+1];
vector<ii> V;
int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("input.txt","r",stdin);
	cin >> n;
	mini=oo;
	maxi=-oo;
	vtmax=0;
	vtmin=0;
	for (ll i=1; i<=n; i++)
	{
		cin >> a[i];
		mini=min(mini,a[i]);
		if (a[i]==mini) vtmin=i;
		maxi=max(maxi,a[i]);
		if (a[i]==maxi) vtmax=i;
	}
	//cout << mini << '\n';
	V.clear();
	if (abs(mini)>=abs(maxi) and mini<0)
	{
		for (ll i=n-1; i>=1; i--)
		{
			while (a[i]>a[i+1]) 
			{
				V.push_back(ii(vtmin,i));
				a[i]+=mini;
				if (i==vtmin) mini=a[i];
				mini=min(a[i],mini);
				if (a[i]==mini) vtmin=i;
			}
		}
	}
	else
	{
		for (ll i=2; i<=n; i++)
		{
			while (a[i]<a[i-1])
			{
				V.push_back(ii(vtmax,i));
				a[i]+=maxi;
				if (i==vtmax) maxi=a[i];
				maxi=max(maxi,a[i]);
				if (a[i]==maxi) vtmax=i;
			}
		}
	}
	cout << V.size() << '\n';
	for (auto it=V.begin(); it!=V.end(); it++)
	cout << (*it).X << ' ' << (*it).Y << '\n';
	return 0;
}

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

int solve(vector<int> values)
{
    auto min_cost = numeric_limits<int>::max();
    auto lower_bound = *min_element(begin(values), end(values));
    auto upper_bound = *max_element(begin(values), end(values));
    for (auto x = lower_bound; x <= upper_bound; x++)
    {
        auto option = 0;
        for (auto v : values)
        {
            auto d = x - v;
            option += d*d;
        }
        min_cost = min(min_cost, option);
    }
    return min_cost;
}

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

    auto values = vector<int>(N);
    for (auto& x : values) cin >> x;

    cout << solve(values) << endl;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 1e5 + 5;
int n, m, v, p;
int a[maxn];

bool read() {
  if (scanf("%d%d%d%d", &n, &m, &v, &p) < 4) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  return true;
}

bool check(int k) {
  long long cut = a[k - 1] + m;
  if (cut < a[p - 1]) {
    return false;
  }
  if (v <= p) {
    return true;
  }
  long long x = (long long) m * (v - p);
  for (int i = p - 1; i < n; i++) {
    if (i == k - 1) {
      continue;
    }
    long long can = min((long long) m, cut - a[i]);
    x -= can;
  }
  return x <= 0;
}

void solve() {
  sort(a, a + n, greater<int>());
  int l = p, r = n + 1;
  while (l < r - 1) {
    int mid = (l + r) / 2;
    if (check(mid)) {
      l = mid;
    } else {
      r = mid;
    }
  }
  printf("%d\n", l);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 640
n,p=map(int,input().split())
s=list(map(int,input()))[::-1]
sum=0
cnt=[0]*p
cnt[0]=1
for i in range(n):#左から●桁めまでの整数を(mod p)でもっておく
    d=s[i]*pow(10,i,p)
    sum=(sum+d)%p
    cnt[sum]+=1
ans=0
if p in [2,5]:
    if p==2:
        ok_list=[0,2,4,6,8]
    if p==5:
        ok_list=[0,5]
    for i in range(n):
        d=s[i]
        if d in ok_list:
            ans+=n-i #dで終わる整数はすべてpで割り切れる
else:
    for i in range(p):
        ans+=cnt[i]*(cnt[i]-1)//2
print(ans)

Measured memory_bytes: 6560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
#define mod 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
int main(){
  int N; cin>>N;
  vvi F(N,vi(10)),P(N,vi(11));
  rep(i,N) rep(j,10) cin>>F[i][j];
  rep(i,N) rep(j,11) cin>>P[i][j];
  ll ans = -1e9;
  for(int i=1;i<(1<<10);i++){
    ll bene = 0;
    rep(j,N){
      int cnt = 0;
      rep(k,10) if(i & (1<<k) && F[j][k]) cnt++;
      bene += P[j][cnt];
    }
    ans = max(ans,bene);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
package main
 
import "fmt"
 
func main() {
  var a,b,c,k int
  fmt.Scan(&a,&b,&c,&k)
  switch {
    case a >= k:
    fmt.Println(k)
    case a+b >= k && a < k:
    fmt.Println(a)
    case k > a+b:
    fmt.Println(a-(k-a-b))
  }
}

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

void trace(int A[], int n){
    for (int i = 0; i < n-1; i++) cout << A[i] << " ";
    cout << A[n-1] << "\n";
}

int main() {
    int N, flag = 1, temp, count = 0;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];

    while (flag){
        flag = 0;
        for (int i = N-1; i > 0; i--){
            if (A[i] < A[i-1]){
                temp = A[i];
                A[i] = A[i-1];
                A[i-1] = temp;
                count++;
                flag = 1;
            }
        }
    }
    trace(A,N);
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3080
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if((a+b)%2==0){
        cout<<(a+b)/2<<endl;
    }else if ((a+b)%2){
        cout<<(a+b)/2+(a+b)%2<<endl;
    }
    
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<int> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse...greater<ll>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17

int main(){
    string S;cin>>S;
    ll sum=0;
    rep(i,S.size()){
        sum+=S[i]-'0';
    }
    cout<<(sum%9==0?"Yes":"No")<<endl;
}

Measured memory_bytes: 3748
#!/usr/bin/env python3

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	x, y = map(int, sys.stdin.readline().split())
	for i in range(x+1):
		ashi = 2 * i + 4 * (x-i)
		if ashi == y:
			print("Yes")
			exit()
	print("No")
	


main()

Measured memory_bytes: 9956
b = input()
out = ""
for i in range(len(b)):
    if b[i] == "A":
        out += "T"
    elif b[i] == "T":
        out += "A"
    elif b[i] == "C":
        out += "G"
    elif b[i] == "G":
        out += "C"
print(out)

Measured memory_bytes: 2940
def f(x, y):
	if '##' in S[x - 1:y]:
		return 0
	else:
		return 1

def g(x, y):
	if '...' in S[x - 2:y + 1]:
		return 1
	else:
		return 0

N, A, B, C, D = map(int, input().split())
S = input()
if C < D:
	x = f(A, C) * f(B, D)
	if x == 1:
		print('Yes')
	else:
		print('No')
else:
	x = f(A, C) * f(B, D) * g(B, D)
	if x == 1:
		print('Yes')
	else:
		print('No')

Measured memory_bytes: 3572
#include<stdio.h>
#define N 2000000
#define M 10000

void CountingSort(int*,int*,int);
int A[N+1],B[N+1],C[M+1],n;

int main(){
  int i;

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

  CountingSort(A,B,M);

  for(i = 0; i < n; i++){
    if(i >= 1) printf(" ");
    printf("%d",B[i+1]);
  }
  printf("\n");
  return 0;

}

void CountingSort(int A[],int B[],int k){
  int i,j;

  for(i = 0; i <= k; i++)
    C[i] = 0;

  for(j = 1; j <= n; j++)
    C[A[j]]++;

  for(i = 1; i <= k; i++)
    C[i] = C[i] + C[i-1];

  for(j = n; j >= 1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}

Measured memory_bytes: 16268
cup = {'A':1,'B':0,'C':0}
while True:
    try:
        d = list(input().split(','))
        tmp = cup[d[0]]
        cup[d[0]] = cup[d[1]]
        cup[d[1]] = tmp
    except EOFError:
        break
for c in 'ABC':
    if cup[c] == 1:
        print(c)

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

int hugou[3];

int dfs(vector<int> vec_s, int i){
    i += 1;
    // return 条件
    if (i > 3) {
        //cout << "i=3" << endl;
        int sum = 0;
        sum += vec_s[0];
        rep (j, 3) {
            if (hugou[j] == 0) {
                sum -= vec_s[j+1];
            } else {
                sum += vec_s[j+1];
            }
        }
        if (sum == 7) { 
            //rep(i, 4) cout << vec_s[i];
            char plmi[3];
            rep(j, 3) {
                if (hugou[j] == 0) {
                    plmi[j] = '-';
                } else {
                    plmi[j] = '+';
                }
            }
            rep(j, 3) {
                cout << vec_s[j] << plmi[j];
            }
            cout << vec_s[3] << "=7" << endl;
            exit(0);
        } else {
            return 0;
        }
    }
    // +をいれるとき
    hugou[i-1] = 1;
    dfs(vec_s, i);

    // -をいれるとき
    hugou[i-1] = 0;
    dfs(vec_s, i);

    return 0;
}

int main() {
    const int s_size=4;
    string s;
    cin >> s;
    vector<int> vec_s(s_size, 0);
    rep(i, s_size) {
        vec_s[i] = s[i] -'0';
    }
    // rep(i, 4) cout << vec_s[i];
    // cout << endl;
    dfs(vec_s, 0);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void swap (int &a, int &b) {
    int c = a;
    a = b;
    b = c;
}
int main() {
    int n;
    cin >> n;
    vector<int> num(n);
    for (int i = 0; i < n; i++) {
        cin >> num.at(i);
    }
    for (int j = 0; j < n/2; j++) {
        swap (num.at(j),num.at(n-1-j));
    }
    for (int i = 0; i < n; i++) {
        cout << num.at(i);
        if(i != n-1) cout << " ";
        else cout << endl;
    }
}


Measured memory_bytes: 3084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

/**
 * @author fangda.wang
 */
public class Main {

	private final static int MOD = 1_000_000_000 +7;
	private final static BigDecimal B_MOD = BigDecimal.valueOf(MOD);

	public static void main (String... args) throws IOException {

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

		String[] vals = reader.readLine().split(" ");
		final int N = Integer.parseInt(vals[0]);
		final int M = Integer.parseInt(vals[1]);

		if (Math.abs(N-M) > 1) {
			System.out.print(0);
			return;
		}

		BigDecimal result;

		if (N == M) {
			result = BigDecimal.valueOf(2).multiply(getPermutation(N)).multiply(getPermutation(N));
		} else {
			result = getPermutation(N).multiply(getPermutation(M));
		}

		System.out.print(result.remainder(B_MOD));

	}

	private static BigDecimal getPermutation(final int n) {
		BigDecimal result = BigDecimal.ONE;
		for (int i = 1; i <= n; i++) {
			result = result.multiply(BigDecimal.valueOf(i));
			if (result.compareTo(B_MOD) == 1) result = result.remainder(B_MOD);
		}
		return result;
	}


}


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

using namespace std;
int main()
{
 int n;
  
  cin>>n;
  
  int c500,r500,c5;
  
  c500 = n/500;
  r500 = n%500;
  c5 = r500/5;

  cout<<(c500*1000+c5*5)<<endl
;  
  
}


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

int main(){
  int N;
  int h[10000000];
  cin >> N;
 
  for(int i=0;i<N;i++){
      cin >> h[i];
  }
  
  int dp[N];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
 for(int i=2;i<N;i++){
   dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));

 }
  cout <<dp[N-1] <<endl;
}

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

int main(){
	int n, k;
  	cin >> n >> k;
  	vector<int> p(n), s(n+1);
  	rep(i, n){
		cin >> p[i];
      	p[i]++; //期待値(p+1)/2なのでp+1で持っておく。最後で割る
    }

  	s[0] = 0;
  	for(int i = 1; i < n+1; i++){
    	s[i] = s[i-1]+p[i-1];
    }
  	
  	int x = 0;
  	rep(i, n+1-k){  	
    	x = max(x, s[i+k]-s[i]);
    }
  
  	double ans = x / 2.0;
  	printf("%.10f", ans);
}

Measured memory_bytes: 4820
import sys
import  math
from statistics import *
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

x, y = ns().split()
if x < y:
    print('<')
elif x == y:
    print("=")
else:
    print(">")

Measured memory_bytes: 5148
N, M = map(int, input().split())
stu = []
for _ in range(N):
  stu.append(tuple(map(int, input().split())))
che = []
for _ in range(M):
  che.append(tuple(map(int, input().split())))

for i in range(N):
  ans = 0
  min_l = pow(10, 10)
  for j in range(M):
    l = abs(stu[i][0] - che[j][0]) + abs(stu[i][1] - che[j][1])
    if l < min_l:
      min_l = l
      ans = j+1
  print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<iomanip>
#include<string>
#include<algorithm>
#include<numeric>
#include<utility>
#define ll long long
#define endl "\n"
#define ss string
using namespace std;
/*ll  mod(ll  a,ll  b)
{
  if(a>b)
    return (a-b);
  else
    return (b-a);
}
double distance(ll  x1, ll  y1, ll  x2, ll  y2)
{

    return sqrt(pow(x2 - x1, 2) +
                pow(y2 - y1, 2) * 1.0);
}*/

int main()
{
  /*ll t;
  cin>>t;
  while(t--)
  {
    ll n,q;
    cin>>n>>q;
    ss s;
    cin>>s;
    ss s2=s;
    ss s3=s;
    ll arr[q];
    for(int i=0;i<q;i++)
    {
      cin>>arr[i];
    }
    for(ll i=0;i<q;i++)
    {

      ss s1;
      for(ll j=0;j<s.size();)
      {
        if(count(s1.begin(),s1.end(),s[j])<=arr[i])
       {
         s1.push_back(s[j]);
         s.erase(s.begin()+j);
       }
       cout<<s1<<" "<<s<<endl;

      }
      cout<<s1<<endl;
      cout<<s.size()<<endl;
        s1.clear();
       s2=s3;
       s=s3;
    }*/
    int k,n,m;
    cin>>k>>n>>m;
    if(m%k<=m-n)
      cout<<"OK"<<endl;
    else
      cout<<"NG"<<endl;



  return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <cstring>
#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 MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    rep(i, tx - sx) cout << "R";
    rep(i, ty - sy) cout << "U";
    rep(i, tx - sx) cout << "L";
    rep(i, ty - sy) cout << "D";
    cout << "L";
    rep(i, ty - sy + 1) cout << "U";
    rep(i, tx - sx + 1) cout << "R";
    cout << "D";
    cout << "R";
    rep(i, ty - sy + 1) cout << "D";
    rep(i, tx - sx + 1) cout << "L";
    cout << "U";
    cout << endl;
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int N;
	cin>>N;
	int m=0;
	for(int n=N; n; n/=10) m+=n%10;

	vector<int> D(N, m+1);
	priority_queue<int, vector<int>, greater<>> q;
	D[0]=m;
	rep(i, 1, min(10, m)) q.push(i*131072+i), D[i]=i;
	while(!q.empty()) {
		int i=q.top()%131072, x=q.top()/131072; q.pop();
		if(D[i]!=x) continue;
		if(!i) break;
		rep(k, 0, 10) {
			int j=(i*10+k)%N, y=x+k;
			if(y<D[j]) q.push(y*131072+j), D[j]=y;
		}
	}
	cout<<D[0]<<endl;
}

Measured memory_bytes: 1784
def abc127c():
    n, m = map(int, input().split())
    ls = []
    rs = []
    for _ in range(m):
        l, r = map(int, input().split())
        ls.append(l)
        rs.append(r)
    ans = max(min(rs)-max(ls)+1, 0)
    print(ans)
abc127c()

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

#define SIZE 20010
const int inf = 1e9;

int n,m;
vector<int> c,x;
int dp[SIZE][256];
bool vis[SIZE][256];

int solve(int p, int y){
    if(p == n)return 0;
    if(vis[p][y])return dp[p][y];
    vis[p][y] = true;
    int res = inf;
    rep(i,m){
        int nxt = y + c[i];
        nxt = min(nxt, 255);
        nxt = max(nxt, 0);
        res = min(res, solve(p+1, nxt) + (nxt-x[p])*(nxt-x[p]));
    }
    return dp[p][y] = res;
}

int main(){
    while(cin >> n >> m, n){
        rep(i,SIZE)rep(j,256)vis[i][j]=false;
        c.resize(m);
        rep(i,m)cin>>c[i];
        x.resize(n);
        rep(i,n)cin>>x[i];
        cout << solve(0, 128) << endl;
    }
}


Measured memory_bytes: 29632
// Created by ...Lusifer
#include<bits/stdc++.h>
using namespace std;
 
#define pb 		push_back
#define mp 		make_pair
#define prior   priority_queue
#define MOD 	1000000007
#define INF64 	(long long)1e18
#define INF 	(int)1e9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long
#define ld		long double
#define ret     return
#define NUM 	1000001
const int SIZE = 2e5+4;
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void solveTest(){
	int n,m;
	cin>>n>>m;
	int a[n+1]={0};
	int correct=0;
	int penalty=0;
	for(int i=0;i<m;i++){
		int p;
		string s;
		cin>>p>>s;
		if(s=="AC"&&a[p]!=-1){
			penalty+=a[p];
			a[p]=-1;
			correct++;
		}
		else if(s=="WA"&&a[p]!=-1){
			a[p]++;
		}
	}
	cout<<correct<<" "<<penalty<<endl;
	return ;
}
 
int main(){
	fastio();

	int t=1;
	//cin>>t;
	while(t--){
		solveTest();
 
	}
	return 0;
}

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

int main(){
  /*処理系*/
  int a, b;
  int ret = 0;
  int tmp;
  int num = 0;
  cin >> a >> b;
  tmp = a;
  while(tmp != 0){
    tmp /= b;
    num++;
  }
  cout << num;
  return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def main():
    H, W = map(int, input().split())
    N = int(input())
    A = list(map(int, input().split()))
    ans = [0] * (H * W)
    idx = 0
    for i in range(N):
        cnt = 0
        while cnt < A[i]:
            ans[idx] = i + 1
            cnt += 1
            idx += 1
    for i in range(H):
        if i % 2 == 0:
            print(" ".join(map(str, ans[W * i: W * (i + 1)])))
        else:
            a = ans[W * i: W * (i + 1)]
            a.reverse()
            print(" ".join(map(str, a)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 69896
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
    int n;
    scanf("%d", &n);

    int *a = (int *) malloc(sizeof(int)*n + 1);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
    }

    int i = 1;
    for (int step = 1; step <= n; ++step) {
        if (a[i] == 2) {
            printf("%d\n", step);
            return 0;
        }
        i = a[i];
    }
    puts("-1");
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#define SIZE 100
using namespace std;

int main()
{
	int n, k, map[SIZE];
	bool flg;
	
	while(cin >> n >> k, n | k)
	{
		flg = true;
		int* map = new int[k];
		for(int i=0; i < k; i++) cin >> map[i];
		for(int i=0; i < n; i++) {
			for(int j=0; j < k; j++) {
				int b; cin >> b;
				map[j] -= b;
				if(map[j] < 0) flg = false;
			}
		}
		if( flg ) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

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

const int N=106;
int a[N];
int b[N];
int n;

bool judge(int x){
    for(int i=x;i<=x+2;++i)
    if(a[i]!=b[i])return false;
    return true;
}
int main(){
    std::cin>>n;
    for(int i=1;i<=n;++i){
        std::cin>>a[i]>>b[i];
    }
    bool flag=false;
    if(n>=3){
        for(int i=1;i<=n-2;++i)
        if(judge(i)){
            flag=true;
            break;
        }
    }
    std::cout<<(flag?"Yes":"No")<<'\n';
    return 0;
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(void){
    string s;
    cin >> s;
    vector<lli> v(s.size());
    for(int i = 0; i < s.size()-1; i++){
        if(s.at(i) == 'R' && s.at(i+1) == 'L'){
            int l = 0, r = 0;
            for(int k = i; k>=0 && s.at(k)=='R'; k--){
                if((i-k)%2==0) l++;
                else r++;
            }
            for(int k = i+1; k<s.size() && s.at(k) == 'L'; k++){
                if((k-i)%2 == 0) l++;
                else r++;
            }
            v.at(i) = l;
            v.at(i+1) = r;
        }
    }
    for(auto i : v) cout << i << endl;
    return 0;
}


Measured memory_bytes: 1408
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : August 15, 2020 6:00 PM
 *    Problem Name  : C - Walking Takahashi
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc175/tasks/abc175_c
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
#define ll long long int 
using namespace std;

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

    ll x , k ,d;
    cin >> x >> k >> d;

    x = abs(x);
    ll temp = x/d;
    if(x>0 && temp >= k){
        cout << abs(x - k*d) <<endl;
        return 0;
    }

    x -= temp*d;
    k -= temp;

    if(k%2!=0){
        cout << min(abs(x+d) , abs(x-d)) << endl;
    }
    else cout << abs(x) << endl;

    return 0 ;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//#define int long long    ←保留
#define rep(i, n) for (int i = 0; i < n; i++)
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
//C++(GCC9.2.1)

/*signed*/int main() {
    //宣言
    int n;
    cin >> n;
    vector<long long> a(n + 2);
    for (int i = 1; i <= n; ++i) cin >> a[i];
    long long sum = 0;
    for (int i = 0; i <= n; ++i) {
        sum += abs(a[i] - a[i + 1]);
    }
    for (int i = 1; i <= n; ++i) {
        cout << sum - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]) << "\n";
    }
    return 0;
}


Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int N;
    cin >> N;
    set<lint> x;
    for(int i = 0; i < N; i++){
        lint A;
        cin >> A;
        x.insert(A);
    }
    cout << x.size() << endl;
}



Measured memory_bytes: 7664
#include <stdio.h>

int main (void)

{

   int n,m,x,i;
   int a[101]={};
   
   
   scanf("%d%d%d",&n,&m,&x);

   for(i=1;i<=m;i++)
      scanf("%d",&a[i]);

   i=1;
   while(x>a[i])   i++;

   if((i-1)>=(m-i+1))   printf("%d\n",m-i+1);
   else                 printf("%d\n",i-1);

   return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split(' '))
S = input()
queries = tuple(tuple(map(int, input().split(' '))) for _ in range(Q))

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

for left, right in queries:
    print(cumsum[right - 1] - cumsum[left - 1])


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m, l;

int main(){
	cin >> n >> m >> l;
	if((m*10+l)%4==0){
		cout << "YES" << endl;
	}else if((m*10+l)%4!=0){
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    if ((n + 1) / 2 >= k) {
        cout << "YES";
    } else {
        cout << "NO";
    }   
}


Measured memory_bytes: 384
let () =
  let r, c = Scanf.scanf "%d %d\n" (fun x y -> x,y) in
  let d = Array.make_matrix (r+1) (c+1) 0 in
  for i = 0 to (r-1) do
    for j = 0 to (c-1) do
      d.(i).(j) <- Scanf.scanf "%d " (fun x -> x);
      d.(i).(c) <- d.(i).(c) + d.(i).(j);
      d.(r).(j) <- d.(r).(j) + d.(i).(j);
      Printf.printf "%d " d.(i).(j)
    done;
    Printf.printf "%d\n" d.(i).(c);
    d.(r).(c) <- d.(r).(c) + d.(i).(c)
  done;
  for j = 0 to (c-1) do
    Printf.printf "%d " d.(r).(j)
  done;
    Printf.printf "%d\n" d.(r).(c);;


Measured memory_bytes: 4504