akhauriyash/Code-Regression huggingface dataset:
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;
typedef long long ll;
const int MAXN = 55;
int nowarn;

int n;
ll a[MAXN];

ll check( ll x ) {
	ll ans = 0;
	for( int i = 0; i < n; ++i ) {
		if( a[i] <= x ) continue;
		ans += (a[i]-x-1) / (n+1) + 1;
	}
	return ans;
}
ll solve1() {
	ll ans = -n*n + n;
	for( int i = 0; i < n; ++i ) ans += a[i];
	if( ans <= 0 ) return 0;
	ll rtn = ans;
	for( int i = 0; i < n; ++i ) a[i] += ans;
	ll low = 0, high = *max_element(a, a+n);
	while( low < high ) {
		ll mid = (low + high) / 2;
		if( check(mid) > ans ) low = mid + 1;
		else high = mid;
	}
	for( int i = 0; i < n; ++i ) {
		if( a[i] <= low ) continue;
		ll t = (a[i]-low-1) / (n+1) + 1;
		ans -= t, a[i] -= t*(n+1);
	}
	while( ans-- ) {
		int p = int(max_element(a, a+n) - a);
		a[p] -= n+1;
	}
	return rtn;
}

ll solve2() {
	ll ans = 0;
	while(1) {
		int p = int(max_element(a, a+n) - a);
		if( a[p] <= n-1 ) return ans;
		for( int i = 0; i < n; ++i )
			a[i] += (i == p ? -n : 1);
		++ans;
	}
	return -1;
}

int main() {
	nowarn = scanf( "%d", &n );
	for( int i = 0; i < n; ++i ) nowarn = scanf( "%lld", a+i );
	ll ans = solve1() + solve2();
	printf( "%lld\n", ans );
	return 0;
}


Measured memory_bytes: 128
let n = stdin.ReadLine() |> int
let ds = stdin.ReadLine().Split() |> Array.map int

seq{
    for i in 0..n-1 do
        for j in i+1..n-1 -> (ds.[i], ds.[j])
}
|> Seq.sumBy (fun (x,y) -> x*y)
|> stdout.WriteLine

Measured memory_bytes: 13396
#
import sys
import math
import numpy as np
import itertools


# ひとつ入力
n = int(input())

# リストに入れる
a = [int(i) for i in input().split()] 

def gcd(p,q):
    if p < q:
        r = p
        p = q
        q = r
    if q == 0:
        return p
    r = p % q
    return gcd(q,r)
        

for i in range(1,n):
    a[0] = gcd(a[0],a[i])
print(a[0])



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

int main(){
	pair<pair<string,int>,int> p[110];

	int n;
	cin >> n;

	for(int i=0; i<n; i++){
		string s;
		int t;
		cin >> s >> t;
		p[i] = make_pair(make_pair(s,-t),i);
	}
	sort(p,p+n);
	for(int i=0; i<n; i++) cout << p[i].second+1 << endl;
}

Measured memory_bytes: 3636
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    a, b = input().split()
    c = int(a + b)
    for i in range(1000):
        if i * i == c:
            print(Yes)
            return
    print(No)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
#include<bits/stdc++.h>
#define ll long long
#define ss second
#define ff first
#define w(x) ll x; cin>>x; while(x--)
#define pi acos(-1)
#define all(cont) cont.begin(), cont.end()
#define countbit(x) __builtin_popcount(x)
#define mod 1000000007
#define re(i,n) for(ll i=0;i<n;i++)
#define re1(i,n) for(ll i=1;i<n+1;i++)
#define de(n) ll n;cin>>n;
#define def(a,n) ll n;cin>>n;ll a[n];re(i,n){cin>>a[i];}
#define defi(a,n,k) ll n;cin>>n; ll k;cin>>k;ll a[n];re(i,n){cin>>a[i];}
#define deb(x) cout<<#x<<"="<<x<<endl;
#define tr(it,a) for(auto it=a.begin();it!=a.end();it++)
#define nl cout<<endl;
using namespace std;
//18-1326D1 1208B 845C 912B 1009B 1350C 20C 1333C 1234D 1327C 1305B 1304B (or in matrix) 1216-C(26) 21
void cp()
{
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); 
    #ifndef ONLINE_JUDGE  
    freopen("input.txt", "r", stdin);  
    freopen("output.txt", "w", stdout);
#endif
}
int main()
{
  cp();
  //w(x)
  {
    de(a);de(b);de(c);de(d);
    cout<<max(a*c,max(a*d,max(b*c,b*d)));
  }
    
}

Measured memory_bytes: 3648
#include<stdio.h>
int main()
{
  int x,a,b;
  int sum = 0;
  
  scanf("%d",&x);
  scanf("%d",&a);
  scanf("%d",&b);
  
  sum = x - a;
  sum = sum % b;
  
  printf("%d",sum);
  
  return 0;
}

Measured memory_bytes: 128
from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N, M = map(int, input().split())
    jobs=[[] for _ in range(M)]
    for i in range(N):
        a, b = map(int, input().split())
        if a > M:
            continue
        jobs[M-a].append(b)
    
    ans=0
    q=[]
    #q=heapify([])
    for i in reversed(range(M)):
        for b in jobs[i]:
            heappush(q,-b)
        if not q: continue
        ans+= -heappop(q)
    print(ans)
    
    
    

resolve()

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h1, m1, h2, m2, k, period;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    h1 *= 60;
    h1 += m1;
    h2 *= 60;
    h2 += m2;
    period = h2 - h1;
    //cout << period << endl;
    period -= k;
    cout << period;
    return 0;
}


Measured memory_bytes: 3640
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int sum, tmp;
  foreach (i; 0..5) {
    auto o = readln.chomp.to!int;
    if (o % 10 == 0) {
      sum += o;
    } else {
      auto t = 10 - o % 10;
      tmp = max(t, tmp);
      sum += o + t;
    }
  }
  writeln(sum - tmp);
}


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

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

    long double a;

    if(L%3==0){
        a = L/3;
    }else if(L%3==1){
        a = (L/3)+0.333333333333;
    }else{
        a = (L/3)+0.666666666666;
    }

    printf("%.7Lf",a*a*a);

    cout << endl;

}

Measured memory_bytes: 256
// abc136c.cpp :
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define dw(i,s,e,d) for(int i=(s);i>(e);i-=(d))
#define in(x) cin>>(x)
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl

void p1(vi v){
  for(auto a: v){ot(a);ot(",");}
}
void p2(vvi &x){
  for(auto v: x){ot("[");p1(v);ot("]\n");}
}

int main(){
  int n;in(n);
  // ote(n);

  vi h(n);
  int a=-1;
  bool f = true;
  rp(i,n){
    in(h[i]);
    // ote(h[i]);
    if(a>h[i]){
      f=false;
      break;
    }else if(a<h[i]){
      a=h[i]-1;
    }
  }

  ote((f?"Yes":"No"));


}

Measured memory_bytes: 640
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,n,k,p[2000];
  int sum=0,temp;
  scanf("%d %d",&n,&k);
  
    for(i=0;i<n;i++)
    {
     scanf("%d",&p[i]);
    }
  
        sort(p,p+n);
    
 for(i=0;i<k;i++)
 {
  sum=sum+p[i];
 }
 printf("%d",sum);
   
return 0;
}

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

int main() {
    string s;
    cin >> s;
    int i, n=s.size(), a=-1, z=0;

    for(i=0; i<n; i++) {
        if(a==-1 && s.at(i) == 'A')
            a = i;
        if(s.at(i) == 'Z')
            z = max(z,i);
    }

    cout << z-a+1 << endl;
}

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

using namespace std;

//#define MD 10

long int exp(long int a,long int b){
	if(b==0){
		return 1;
	}else if(b==1){
		return a;
	}else{
		long int t=a;
		for(long int i=0;i<b-1;i++){
			a*=t;
		}
		return a;	
	}
}

int main(){
   int n,k;
    cin>>n>>k;
    long int ans=k;
    if(n!=1){
        ans*=exp(k-1,n-1);
    }
    cout<<ans<<endl;
   return 0;
}

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

int main() {
  string s;
  cin >> s;
  string t = s;
  reverse(t.begin(), t.end());
  for (int i = 0; i < t.size(); i++) {
    if (t[i] == 'b') {
      t[i] = 'd';
    }
    else if (t[i] == 'd') {
      t[i] = 'b';
    }
    else if (t[i] == 'p') {
      t[i] = 'q';
    }
    else {
      t[i] = 'p';
    }
  }
  if (s == t) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<vector>
#define inf 1000000
#define ll unsigned long long 
#define boostUP ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fsr(i,n) for(ll i=0;i<n;i++)
#define fcr(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define sz(arr) sizeof(arr)/sizeof(arr[0])

using namespace std;

int main(){
    ll n ,a ,b, count = 0;
    cin >> n >> a >> b;
    ll sum = 0, ans = 0, rem = 0;
    cout << (n / (a+b)) * a + min(n%(a+b),a) << endl;
}




Measured memory_bytes: 3604
import sys
sys.setrecursionlimit(1000000)

N = int(input())
P = [[int(x) for x in input().split()] for _ in range(N)]

sumAll = 0
def func(src, nxt, visited, sum):
    global sumAll
    visited |= 1<<nxt
    d = ((P[src][0]-P[nxt][0])**2 + (P[src][1]-P[nxt][1])**2)**0.5
    if visited == (1<<N) - 1:
        sumAll += sum + d
        return
    for i in range(N):
        if not visited>>i&1:
            func(nxt, i, visited, sum+d)

for i in range(N):
    func(i, i, 0, 0)

while N > 1:
    sumAll /= N
    N -= 1

print(sumAll)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll dp[66], ep[3333];

int main(void) {
  ll i, j, k, l;
  
  
  ll A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  
  dp[0]=1;
  for(i=0; i<33; i++) {
    chmax(dp[i+A], dp[i]);
    chmax(dp[i+B], dp[i]);
  }
  
  ep[0]=1;
  for(i=0; i<3030; i++) {
    chmax(ep[i+C], ep[i]);
    chmax(ep[i+D], ep[i]);
  }
  
  
  P res=P(A*100, 0);
  for(i=1; i<33; i++) {
    for(j=1; j<3030; j++) {
      if(i*100+j>F) continue;
      if(i*E<j) continue;
      if(!dp[i]||!ep[j]) continue;
      
      if(res.second*(i*100+j)<=(res.first+res.second)*j) {
        res=P(i*100, j);
      }
        
    }
  }
  
  pt(res.first+res.second<<" "<<res.second);
  
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;


signed main(){
	int N,A,B;cin>>N>>A>>B;
	int ans=0;
	ans+=(N/(A+B))*A;
	ans+=min(A,N%(A+B));
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int D;

LL Count(vector<int> &ds) {
  int m = ds.size();
  
  LL ret = 0;
  int lim = 1 << (m-1);
  rep(st, lim) {
    vector<int> ss;
    int tmp = st;
    rep(i, m-1) {
      ss.eb(tmp >> i & 1);
    }
    ss.eb(0);

    LL tot = 1;
    rep(i, m/2) {
      if ((ds[i]+ds[m-1-i]+ss[i]+ss[m-1-i])%10) tot = 0;
    }

    rep(i, m/2) {
      int cnt = 0;
      rep(ai, 10) {
        rep(ami, 10) {
          if (i == 0 && ami == 0) continue;

          if ((ai+10-ami+10-ss[i])%10 != ds[i]) continue;
          if ((ami+10-ai+10-ss[m-1-i])%10 != ds[m-1-i]) continue;
          
          bool fail = 0;
          rep(k, 3) {
            if (ai-ami-ss[i] + k*10 >= 0) {
              assert(k != 2);
              if (i > 0 && k != ss[i-1]) fail = 1;
              if (i == 0 && k != 0) fail = 1;
              break;
            }
          }

          rep(k, 3) {
            if (ami-ai-ss[m-1-i] + k*10 >= 0) {
              assert(k != 2);
              if (k != ss[m-2-i]) fail = 1;
              break;
            }
          }

          if (!fail) {
            cnt++;
          }
        }
      }
      assert(0 <= cnt && cnt <= 10);
      tot *= cnt;
    }

    if (m%2 == 1) {
      if ((ds[m/2]+ss[m/2])%10) tot = 0;
      if (ss[m/2-1] != (ss[m/2] != 0)) tot = 0; 
      tot *= 10;
    }

    ret += tot;
  }
  return ret;
}


signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> D;
  vector<int> ds;
  while (D > 0) {
    ds.eb(D%10);
    D /= 10;
  }

  LL ans = 0;
  rep(i, 10) {
    auto es = ds;
    reverse(all(es));
    ans += Count(es);
    ds.eb(0);
  }
  
  cout << ans << endl;
}


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

using namespace std;

int base = 100;

int main() {
    int year = 0;
    long long int x, money = base;
    cin >> x;
    while(money < x) {
        money = money*1.01;
        year++;
    }
    cout << year << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>

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

	if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)std::cout << "Possible" << std::endl;
	else std::cout << "Impossible" << std::endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
#define FAST std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M 1000000007
#define mp make_pair
#define pb push_back
#define PB pop_back
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define lcase(a) (char)tolower(a)
#define ucase(a) (char)toupper(a)
#define precise(a) fixed<<setprecision(a)<<
#define F first
#define S second
#define I insert
#define pii pair<int,int>
#define trav(a, x) for(auto& a : x)
#define fl(i,n) for(int i = 0;i<n;i++)
#define rfl(n) for(int i = n-1;i>=0;i--)
#define time cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define display(x) trav(a,x) cout<<a<<" "; cout<<endl;
#define ingrid(data,n,commands) for(int i = 0; i<n; i++){cin>>data[i];commands}
#define section(a,b,w) set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w) set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define copy(a,w) copy(a.begin(), a.end(),back_inserter(w));
#define all(data) data.begin(), data.end()
#define PI 3.14159265358979323844
#define endl '\n'
#define last(a) a[sz(a)-1]
#define mp make_pair
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
 
// Graph DFS
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};
 
//primes for hashing 937,991,1013,1409,1741
 
//Returns index of first element not less than key and more than key respectively
#define lb(data,key) lower_bound(all(data),key) - data.begin();
#define up(data,key) upper_bound(all(data),key) - data.begin();
#define fnd(data,key) find(all(data),key) - data.begin();
//Long Long Int
#define int long long int

void solve()
{
    int n,w;
    cin>>n>>w;
    std::vector<std::vector<int> > v(n,vector<int> (2,0));
    fl(i,n)
    {
        fl(j,2)
            cin>>v[i][j];
    }
    
    std::vector<std::vector<int> > dp(n,std::vector<int> (w+1,0));
    fl(i,n)
    {
        fl(j,w+1)
        {
            if(i==0)
            {
                if(v[i][0]<=j)
                    dp[i][j]=v[i][1];
                else
                    dp[i][j]=0;
            }
            else
            {
                dp[i][j]=dp[i-1][j];
                if(v[i][0]<=j)
                    dp[i][j]=max(dp[i][j],dp[i-1][j-v[i][0]]+v[i][1]);
            }
        }
    }
    
    cout<<dp[n-1][w]<<endl;
}
 
signed main()
{
    
    FAST
    int t = 1;
    //cin>>t;
    while(t--)
    solve();
    
 
return 0;
}
 
/*6
30 10 60 10 60 50*/

Measured memory_bytes: 79488
#include <stdio.h>
#include <vector>
#include <math.h>
#include <iostream>
int main(){

    using namespace std;

    int a, b, ans1, ans2, ans3, ans4;
    int ans = 0;

    int c, d;

    cin >> a >> b;


         for(int i=0;i<=1250 ; i++)
         {
             if(i * 8 / 100 == a && i / 10 == b)
             {
                 cout << i << endl;
                     return  0;
                 
             }
             
             
    
         }
    
    cout << -1 << endl;

    //cout << c << endl;


    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

char s[10][10];

int main()
{
	cio;

	int h, w, k;
	cin >> h >> w >> k;

	for (int i = 0; i < h; i++)
	{
		cin >> s[i];
		for (int j = 0; j < w; j++)
		{
			if (s[i][j] == '.')
				s[i][j] = 0;
			else
				s[i][j] = 1;
		}
	}

	int ans = 0;
	for (int row = 0; row < (1<<h); row++)
		for (int col = 0; col < (1<<w); col++)
		{
			int n = 0;
			for(int y = 0; y < h; y++)
				for (int x = 0; x < w; x++)
				{
					if (s[y][x] == 0)
						continue;

					if (row & (1 << y) && col & (1 << x))
						n++;
				}

			if (n == k)
				ans++;
		}

	cout << ans;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  int N,K,C;//no_of_days, number of work days, minimum diff
  string input;
  cin >> N >> K >> C >> input;
  vector<int> ans;
  int currmax = 0;
  vector<int> result(N,0);
  vector<int> last(N,0);
  vector<int> result2(N,0);
  int lastused = -INT_MAX;
  int currcnt = 0;
  for(int i=0;i<N;i++){
    if(i-lastused>C&&input.at(i)=='o'){
      currcnt++;
      lastused = i;
    }
    result[i] = currcnt;
    last[i] = lastused;
  }
  reverse(input.begin(),input.end());
  lastused = -INT_MAX;
  currcnt = 0;
  for(int i=0;i<N;i++){
    if(i-lastused>C&&input.at(i)=='o'){
      currcnt++;
      lastused = i;
    }
    result2[i] = currcnt;
  }
  reverse(result2.begin(),result2.end());
  reverse(input.begin(),input.end());
  for(int i=0;i<N;i++){
    result2.push_back(0);
  }
  for(int i=1;i<N-1;i++){
    if(input.at(i)=='x'){
      continue;
    }
    if(result[i-1]+result2[max(i+1,last[i-1]+C+1)]<K){
      ans.push_back(i);
    }
  }
  if(result2[1]<K){
    ans.push_back(0);
  }
  if(result[N-2]<K){
    ans.push_back(N-1);
  }
  sort(ans.begin(),ans.end());
  for(auto kk:ans){
    cout << kk+1 << "\n";
  }



}

Measured memory_bytes: 11640
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(){
	int h,w;
	scanf("%d%d", &h,&w);
	char a[100][101];
	REP(i, h) {
		scanf("%s", a[i]);
	}
	int f[100][2] = { 0 };
	REP(i, h) {
		int flag = 0;
		REP(j, w) {
			if (a[i][j] == '#') {
				flag = 1;
				break;
			}
		}
		if (!flag)f[i][0] = 1;
	}
	REP(i, w) {
		int flag = 0;
		REP(j, h) {
			if (a[j][i] == '#') {
				flag = 1;
				break;
			}
		}
		if (!flag)f[i][1] = 1;
	}
	REP(i, h) {
		if (f[i][0])continue;
		REP(j, w) {
			if (f[j][1])continue;
			printf("%c", a[i][j]);
		}
		puts("");
	}
	/*
	puts("");
	REP(i, 100) {
		printf("%d ", f[i][0]);
		printf("%d", f[i][1]);
		puts("");
	}*/
}

Measured memory_bytes: 128
use std::cmp::max;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b, x) = scan!(usize, usize, usize);
    if a == 0 {
        println!("{}", b / x + 1);
    } else {
        println!("{}", b / x - (a - 1) / x);
    }
}


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

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

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

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

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

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

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

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

//
// # Examples
//
// # integers
// input! { n: i32, m: i32, ... }
//
// # array
// input! { n: i32, v: [i32; n], }
//
// # matrix
// input! { n: i32, m: i32, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: i32,
//     w: i32,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: i32, b: i32, c: i32,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input! { x: chars, y: chars }
    let x = u8::from_str_radix(&(x[0].to_string()), 16).unwrap();
    let y = u8::from_str_radix(&(y[0].to_string()), 16).unwrap();
    if x < y {
        println!("<");
    } else if x > y {
        println!(">");
    } else {
        println!("=");
    }
}

Measured memory_bytes: 4352
#pragma comment(linker, "/STACK:640000000")
#include <bits/stdc++.h>

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)

using namespace std;

typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);

const int maxn = 111;

int n;
int a[maxn], b[maxn];
int c[maxn], d[maxn];
int mt[maxn];
bool g[maxn][maxn];
bool used[maxn];

bool go(int v) {
	if (used[v]) return false;
	used[v] = true;
	for (int i = 0; i < n; i++) if (g[v][i]) {
		if (mt[i] == -1 || go(mt[i])) {
			mt[i] = v;
			return true;
		}
	}
	return false;
}

int main() {
	#ifdef LOCAL
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
	#endif
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i] >> d[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (a[i] < c[j] && b[i] < d[j]) {
				g[i][j] = true;	
			}
		}
	}
	memset(mt, -1, sizeof(mt));
	int res = 0;
	for (int i = 0; i < n; i++) {
		memset(used, false, sizeof(used));
		if (go(i)) res++;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;

long long k;

int main()
{

   while(~scanf("%lld", &k))
   {
       if(!k)
       {
           printf("4\n3 3 3 3\n");
           continue;
       }
       if(k == 1)
       {
           printf("3\n1 0 3\n");
           continue;
       }
       long long pos = -1;
       for(long long i = 50;i >= 2;i--)
       {
           if(k == i)
           {
               pos = i;
               break;
           }
       }
       if(pos != -1)
       {
           long long pp = k / pos;
           printf("%lld\n", pos);
           for(long long i = 1;i <= pos;i++)
           {
               if(i == 1)
                    printf("%lld", pos + pp - 1);
               else
                    printf(" %lld", pos + pp - 1);
           }
           puts("");
       }
       else
       {
           pos = 50;
           long long pp = k / pos + 1;
           long long pp2 = (k / pos + 1) * pos - k;
           printf("%lld\n", pos);
           for(long long i = 1;i <= pos;i++)
           {
               if(i == 1)
               {
                   if(i > pp2)
                        printf("%lld", pos + pp - 1);
                    else
                        printf("%lld", i + pp - 2);
               }
               else
               {
                   if(i > pp2)
                        printf(" %lld", pos + pp - 1);
                    else
                        printf(" %lld", i + pp - 2);
               }
           }
           puts("");
       }
   }
    return 0;
}



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

int main()
{
	char s[17];
	cin>>s;
	char p[17] = "CODEFESTIVAL2016";
	int cnt = 0;
	for(int i=0;i<16;i++)
		if(s[i] != p[i])
			++cnt;
	cout<<cnt<<endl;
	return 0;
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int n,a,b;
  cin >> n >> a >> b;
  if((b-a) & 1){
    cout << "Borys";
  }else{
    cout << "Alice";
  }
}


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

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

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


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    vector<ll> ans(n,0);
    rep(i,n){
        if(i%2==0) ans[0]+=a[i];
        else ans[0]-=a[i];
    }

    for(int i=1;i<n;i++){
        ans[i]=2*a[i-1]-ans[i-1];
    }

    rep(i,n) cout<<ans[i]<<" ";
    cout<<endl;
}



Measured memory_bytes: 4820
#include <iostream>  
using namespace std;  
typedef long long ll;
ll gcd(ll a,ll b)  {  
    ll t;  
    if(a<b){  
        t=a;  
        a=b;  
        b=t;  
    }  
    while(t=a%b){  
        a=b;  
        b=t;  
    }  
	return b;  
}  
int main(){  
    ll a,b;
	cin>>a>>b;
    cout<< a*b /gcd(a,b)<<endl;  
    return 0;  
} 

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

const int maxn=1e5+10;
int n,ans,cnt;
vector<int> g[maxn];

void dfs(int pos,int fa,int mid,multiset<int>&root){
	multiset<int> edge;
	for(int i=0;i<g[pos].size();++i)
		if(g[pos][i]!=fa)
			dfs(g[pos][i],pos,mid,edge);
	int rest=0;
	while(!edge.empty()&&*edge.rbegin()==mid){
		multiset<int>::iterator p=edge.end();--p;
		edge.erase(p);
		++cnt;
	}
	while(edge.size()){
		multiset<int>::iterator p=edge.end(),q;--p;
		int maximum=*p;
		edge.erase(p);
		q=edge.upper_bound(mid-maximum);
		if(q==edge.begin()){
			if(rest)
				++cnt,rest=maximum;
			else
				rest=maximum;
		}
		else{
			--q;
			edge.erase(q);
			++cnt;
		}
	}
	root.insert(rest+1);
}

int main(){
	cin>>n;
	for(int i=1,u,v;i<n;++i){
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i=2;i<=n;++i)
		ans+=(g[i].size()-1)/2;
	ans+=(g[1].size()+1)/2;
	int l=1,r=n-1;
	while(l<r){
		int mid=l+r>>1;
		cnt=0;
		multiset<int> tmp;
		dfs(1,0,mid,tmp);
		if(*tmp.begin()>1)
			++cnt;
		if(cnt<=ans)
			r=mid;
		else
			l=mid+1;
	}
	cout<<ans<<' '<<l<<endl;
	return 0;
}

Measured memory_bytes: 16384
#include<cstdio>
#include<algorithm>
using namespace std;
#define MO 1000000007
#define MAXN 200005
#define LL long long
LL inv[MAXN],s[MAXN];
int n;
LL PowMod(LL a,int b)//快速幂
{
	LL ret=1;
	while(b)
	{
		if(b%2==1)
			ret=ret*a%MO;
		a=a*a%MO;
		b/=2;
	}
	return ret;
}
void Pre()//预处理：计算逆元
{
	s[0]=1;
	for(int i=1;i<=n;i++)
		s[i]=s[i-1]*i%MO;
	inv[0]=1;
	inv[n]=PowMod(s[n],MO-2);
	for(int i=n-1;i>0;i--)
		inv[i]=inv[i+1]*(i+1)%MO;
}
LL C(int a,int b)//组合C
{
	if(a<0||b<0)
		return 1;
	return s[a]*inv[b]%MO*inv[a-b]%MO;
}
int main()
{
	int h,w,A,B;
	scanf("%d%d%d%d",&h,&w,&A,&B);
	n=h+w-2;
	Pre();
	LL ans=C(h+w-2,h-1);
	for(int i=1;i<=B;i++)
	{
		ans-=C(h-A+i-2,h-A-1)*C(A-1+w-i,A-1)%MO;
		ans=(ans%MO+MO)%MO;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define rep(i,j) for (int (i)=0;(i)<(int)(j);++(i))
#define put(i) cout << (i) << endl
using namespace std;
typedef long long ll;
const int mod = 1e9+7;

string s;
ll ans;

void dfs(int idx, vector<int> p) {
    if (idx == p.size()) {
        int l = 0;
        ll sum = 0;
        for (int i=0;i<p.size();++i) {
            if (p[i]) {
                sum += atol(s.substr(l,i+1-l).c_str());
                l = i+1;
            }
        }
        sum += atol(s.substr(l, s.size()-l).c_str());
        ans += sum;
        return;
    }
    p[idx] = 1;
    dfs(idx+1, p);
    p[idx] = 0;
    dfs(idx+1, p);
}

int main() {
    cin >> s;
    vector<int> p(s.size()-1, 0);
    dfs(0,p);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e09

int main(){
    int n;
    cin >> n;
    vector<int> h(n), dp(n, INF);
    for (int i = 0; i < n; i++) cin >> h.at(i);
    dp.at(0) = 0;
    
    for (int i = 1; i < n; i++){
        dp.at(i) = min(dp.at(i), dp.at(i-1)+abs(h.at(i)-h.at(i-1)));
        if (i > 1){
            dp.at(i) = min(dp.at(i), dp.at(i-2)+abs(h.at(i)-h.at(i-2)));
        }
    }
    cout << dp.at(n-1) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sort(a+1,a+n+1);
	if(a[1]==a[n])
	{
		if(a[1]<=(n/2))
		{
			cout<<"Yes\n";
		}
		else if(a[1]==n-1)
		{
			cout<<"Yes\n";
		}
		else
		{
			cout<<"No\n";
		}
	}
	else
	{
		if(a[n]-a[1]==1)
		{
			int cnt=0;
			for(int i=1;i<=n;i++)
			{
				if(a[i]==a[1])
				{
					cnt++;
				}
			}
			int tt_min=cnt;
			int tt_max=cnt-1+((n-cnt)/2);
			if(a[1]<=tt_max&&a[1]>=tt_min)
			{
				cout<<"Yes\n";
			}
			else
			{
				cout<<"No\n";
			}
		}
		else
		{
			cout<<"No\n";
		}
	}
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, K) = Read2Longs();
            var h = ReadLongs();
            var dp = new long[N];
            for (var i = 1; i < N; i++)
            {
                var min = long.MaxValue;
                for (var k = 1; k <= K; k++)
                {
                    if (i - k < 0) break;
                    var cost = dp[i - k] + Math.Abs(h[i] - h[i - k]);
                    min = Math.Min(min, cost);
                }
                dp[i] = min;
            }

            return dp[N - 1];
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 36776
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> P;

const double inf = 1e100;
const double pi = acos(-1);
const double eps = 1e-8;
const int MAXN = 21;
const int NINJIN = 1002;

int N;
double R, T;
P ps[MAXN];
double dp[2][MAXN][MAXN]; // #ninjin, pos, pre;

bool equals(double a, double b) {
  return abs(a-b) < eps;
}

double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}

double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}

double getAngle(P a, P b) {
  return acos(dot(a, b)/(abs(a)*abs(b)));
}

bool canMove(const P &pre, const P &from, const P &to) {
  P a = from - pre;
  P b = to - from;
  double d = abs(getAngle(a,b));
  return equals(d, T) || d < T;
}

int main() {
  cin >> N;
  cin >> R >> T;
  T = T * pi / 180.0;
  for(int i = 0; i < N; ++i) {
    P &p = ps[i];
    cin >> p.real() >> p.imag();
  }
  fill(dp[0][0], dp[2][0], inf);
  dp[0][0][0] = 0.0;
  int maxi = 0;
  for(int i = 0, next = true; next; ++i) {
    int p = i % 2;
    int q = 1 - p;
    for(int j = 0; j < N; ++j) {
      for(int k = 0; k < N; ++k) {
        dp[q][j][k] = inf;
      }
    }
    next = false;
    for(int j = 0; j < N; ++j) {
      for(int k = 0; k < N; ++k) {
        if(dp[p][j][k] == inf) continue;
        for(int m = 0; m < N; ++m) {
          if(m == j) continue;
          if(j != k && !canMove(ps[k], ps[j], ps[m])) continue;
          double ndist = dp[p][j][k] + abs(ps[m] - ps[j]);
          if(equals(ndist, R) || ndist < R); else continue;
          maxi = i+1;
          next = true;
          dp[q][m][j] = min(dp[q][m][j], ndist);
        }
      }
    }
  }
  cout << maxi << endl;
  return 0;
}

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

using namespace std;

char c;
bool x[22][22], vis[22][22];
int n, m, dis[22][22], curmax, recurmax;
queue <int> qa, qb;

//void sear(int d, int p, int ac) {
//	if (x[d][p]) return;
//	if (vis[d][p]) return;
//	vis[d][p] = 1;
//	dis[d][p] = ac;
//	curmax = max(curmax, ac);
//	sear(d - 1, p, ac + 1);
//	sear(d + 1, p, ac + 1);
//	sear(d, p - 1, ac + 1);
//	sear(d, p + 1, ac + 1);
//}

void qsear(int d, int p) {
	if (!vis[d - 1][p] && !x[d - 1][p]) {
		qa.push(d - 1);
		qb.push(p);
		vis[d-1][p] = 1;
		dis[d-1][p] = dis[d][p] + 1;
	}
	if (!vis[d + 1][p] && !x[d + 1][p]) {
		qa.push(d + 1);
		qb.push(p);
		vis[d + 1][p] = 1;
		dis[d + 1][p] = dis[d][p] + 1;
	}
	if (!vis[d][p - 1] && !x[d][p - 1]) {
		qa.push(d);
		qb.push(p - 1);
		vis[d][p - 1] = 1;
		dis[d][p - 1] = dis[d][p] + 1;
	}
	if (!vis[d][p + 1] && !x[d][p + 1]) {
		qa.push(d);
		qb.push(p + 1);
		vis[d][p + 1] = 1;
		dis[d][p + 1] = dis[d][p] + 1;
	}
	curmax = max(curmax, dis[d][p]);
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			cin >> c;
			if (c == '#') x[i + 1][j + 1] = 1;
		}
	}
	for (int i=0; i<n + 2; i++) {
		x[i][0] = 1;
		x[i][m + 1] = 1;
	}
	for (int i=0; i<m + 2; i++) {
		x[0][i] = 1;
		x[n + 1][i] = 1;
	}
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=m; j++) {
			for (int k=0; k<22; k++) {
				for (int l=0; l<22; l++) {
					dis[k][l] = 0;
					vis[k][l] = 0;
				}
			}
			dis[i][j] = 0;
			if (x[i][j] != 1) {
				qa.push(i); qb.push(j);
			}
			vis[i][j] = 1;
			while (!qa.empty()) {
				qsear(qa.front(), qb.front());
				qa.pop(); qb.pop();
			}
//			if (x[i][j] != 1) sear(i,j,0);
			recurmax = max(curmax, recurmax);
			curmax = 0;
		}
	}
	cout << recurmax << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
    int  main(){
    int a,b,i,c=0,min=9999999;
    int n;
    scanf("%d",&n);
	
    for(i=0;i<n;i++)
{scanf("%d",&a); 
if(min>=a)
min=a;
if(a<=min)
c++;

}

    printf("%d",c);
    }

Measured memory_bytes: 256
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <queue>

#define MAXCHAR 255
#define ll long long

using namespace std;
const ll dividend = 1000000007;
const ll limit = pow(10, 18);
const ll bigNum = pow(10, 9);

ll funcComb(int n, int k)
{
	ll output = 1;
	int sum = n + k;
	vector<int> dividends;
	for (int i = 0; i < k; i++)
	{
		dividends.push_back(k - i);
	}
	for (int i = 0; i < k; i++)
	{
		output *= sum - i;
		for (auto it = dividends.begin(); it != dividends.end(); it++)
		{
			if (*it == 0)
				continue;
			if (output % *it == 0)
			{
				output /= *it;
				*it = 0;
			}
		}
		if (output > dividend)
		{
			output %= dividend;
		}
	}

	return output;
}

vector<vector<char>> inputs;
vector<vector<pair<int, int>>> xArray;
vector<vector<pair<int, int>>> coordinatesInArea;
int H, W, Ch, Cw, Dh, Dw;

void createAreaVec()
{
	for (int i = 0; i < H; i++)
	{
		int area = 0;
		xArray.push_back(vector<pair<int, int>>());
		for (int j = 0; j < W; j++)
		{
			if (inputs[i][j] == '#')
			{
				area++;
				continue;
			}
			xArray[i].push_back(pair<int, int>(j, area));
		}
	}

	for (int j = 0; j < W; j++)
	{
		for (int i = 0; i < H; i++)
		{

		}
	}
}

int calcJumps()
{
	return 0;
}

int getMinimum()
{
	return 0;
}

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

	if (in == 0)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
	return 0;
}



Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[10];
	for(int i=0;i<10;i++){
		cin>>a[i];
	}
	sort(a,a+10);
	for(int i=9;i>6;i--){
		cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
      	
      	int n;
      	cin>>n;
      	
      	int arr[n];
      	for(int i=0;i<n;i++)
      	{
      		cin>>arr[i];
		}
		
		sort(arr,arr+n);
		
		int cnt=0;
		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				for(int k=j+1;k<n;k++)
				{
					if(arr[i]+arr[j]>arr[k] && (arr[i]!=arr[j] && arr[j]!=arr[k] && arr[k]!=arr[i]))
					{
						cnt++;
					}
				}
			}
		}
		
		cout<<cnt<<endl;
      	return 0;
    }

Measured memory_bytes: 3636
#include<iostream>
#include<stdio.h>
using namespace std;
using ll=long long;
#include<algorithm>
#include<set>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using P=pair<int,int>;
const int mod=1000000007;

int main(){
string s;
cin>>s;
rep(i,s.size()){
  s[i]='x';
}
cout<<s<<endl;
return 0;
}



Measured memory_bytes: 3132
while 1:
 H,W=map(int,input().split())
 if H==0:break
 m=[input()for _ in[0]*H]
 y=x=0
 for _ in range(H*W):
  u,v=x,y
  c=m[y][x]
  if c=='>':x+=1;
  if c=='v':y+=1;
  if c=='<':x-=1;
  if c=='^':y-=1;
  if c=='.':print(x,y);break
 else:print('LOOP')


Measured memory_bytes: 5616
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let ab = read(&mut stdin_lock, &mut buf, b' ');
    let bc = read(&mut stdin_lock, &mut buf, b' ');
    let ca = read(&mut stdin_lock, &mut buf, b'\n');
    println!("{}", solve(ab, bc, ca));
}

fn solve(ab: i32, bc: i32, _: i32) -> i32 {
    (ab * bc) / 2
}

#[test]
fn example1() {
    assert_eq!(6, solve(3, 4, 5))
}

#[test]
fn example2() {
    assert_eq!(30, solve(5, 12, 13))
}

#[test]
fn example3() {
    assert_eq!(630, solve(45, 28, 53))
}


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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/
const ll mod=1e9+7;
const ll INF=1e18;
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int t,a,b,cnt=0; cin >>t;
	while (t--) {
		scanf("%d%d",&a,&b);
		if (a==b) {
			cnt++;
			if (cnt==3) {
				cout <<"Yes";
				return 0;
			}
		}
		else {
			cnt=0; 
		}
	}
	cout <<"No";
	return 0;
}
/******************************************************************************
******************************************************************************/


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

int main(){
  int n,m;

 while(cin >> n >> m,n!=0){
   int max;
    vector<int> v;
    
    for(int i=0; i<n; ++i){
      int tmp;
      cin >> tmp;
      v.push_back(tmp);
    }

    max = -1;

    for(int i=0; i<n-1; ++i){
      for(int j=i+1; j<n; ++j){
	int tmp = v[i]+v[j];
	if(tmp<=m && tmp>max){max = tmp;}
      }
    }
    
    if(max==-1){
      cout << "NONE" << endl;
    }else{
      cout << max <<endl;
    }
  }

  return 0;
}
    



Measured memory_bytes: 3156