akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main{
    static public void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        //BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        //String[] buf = reader.readLine().split(" ");
        int H =sc.nextInt(), W = sc.nextInt(), K = sc.nextInt();
        int firstLine = 10000;
        ArrayList<Integer>[] rec = new ArrayList[H];
        for(int i=0;i<H;i++) rec[i] = new ArrayList<>();
        for(int i=0;i<H;i++){
            char[] line = sc.next().toCharArray();
            for(int j=0;j<W;j++){
                if(line[j]=='#') rec[i].add(j);
            }
            if(rec[i].size()>0) firstLine = Math.min(firstLine,i);
        }
        int[][] ans = new int[H][W];
        int curNum = 0;
        for(int i=firstLine; i<H;i++){
            if(rec[i].size()==0){
                for(int j=0;j<W;j++) ans[i][j] = ans[i-1][j];
            } else{
                // do the left of the first one
                int curIdx = 0, size = rec[i].size();
                for(int j=rec[i].get(0);j<W;j++){
                    if(curIdx>=size || j != rec[i].get(curIdx)) ans[i][j] = curNum;
                    else{
                        curNum += 1;
                        curIdx += 1;
                        ans[i][j] = curNum;
                    }
                }
                for(int j=rec[i].get(0)-1; j>=0; j--) ans[i][j] = ans[i][j+1];
            }
        }
        // finally do the top part
        for(int i=firstLine-1; i>=0;i--){
            for(int j=0;j<W;j++) ans[i][j] = ans[i+1][j];
        }
        PrintWriter out = new PrintWriter(System.out);
       for(int i=0;i<H;i++){
            for(int j=0;j<W;j++) out.print(ans[i][j]+" ");
            out.print("\n");
        }
        out.flush();
    }
}



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

int main() {
  int N;
  cin >> N;
  int B_a,B_b,ans;
  cin >> ans;
  B_a=ans;
  int i;
  for(i=0;i<N-2;i++){
    cin >> B_b;
    ans+=min(B_a,B_b);
    B_a=B_b;
  }
  ans+=B_a;
  cout << ans << endl;
}


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

struct state {
  ll x, y, d, c;
  bool operator<(const state &s) const {
    return c > s.c;
  }
};

ll dx[2][7] = { { +0, +1, +1, +0, -1, -1, +0 }, { +0, +1, +1, +0, -1, -1, +0 } };
ll dy[2][7] = { { +1, +0, -1, -1, -1, +0, +0 }, { +1, +1, +0, -1, +0, +1, +0 } };

int main(void) {
  ll SX, SY, GX, GY;
  cin >> SX >> SY >> GX >> GY;
  ll N;
  cin >> N;
  vector<pll> P(N);
  REP(i, 0, N) cin >> P[i].first >> P[i].second;
  ll LX, LY;
  cin >> LX >> LY;

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

  const ll INF = 1LL << 50;
  vector<vector<vector<ll>>> dp(LX * 2 + 1, vector<vector<ll>>(LY * 2 + 1, vector<ll>(6, INF)));
  priority_queue<state> q;
  q.push((state) { SX, SY, 0, 0 });

  while(q.size()) {
    ll x = q.top().x, y = q.top().y, d = q.top().d, c = q.top().c;
    q.pop();

    if(dp[x + LX][y + LY][d] <= c) continue;
    dp[x + LX][y + LY][d] = c;

    ll op = abs(x * y * d) % 6;
    REP(i, 0, 7) {
      ll nx = x + dx[abs(x) % 2][i];
      ll ny = y + dy[abs(x) % 2][i];
      ll nd = (d + 1) % 6;
      ll nc = c + (i == op ? 0 : 1);
      if(-LX <= nx && nx <= LX && -LY <= ny && ny <= LY) {
        if(!binary_search(P.begin(), P.end(), pll(nx, ny))) {
          q.push((state) { nx, ny, nd, nc });
        }
      }
    }
  }

  ll ans = INF;
  REP(i, 0, 6) ans = min(ans, dp[GX + LX][GY + LY][i]);
  cout << (ans < INF ? ans : -1) << endl;
}


Measured memory_bytes: 8468
program ABC_072_B_OddString
   implicit none
   integer i
   character(1000000) s
   read(*, *) s
   do i = 2, len_trim(s)
       s(i:i)= s(2*i-1:2*i-1)
   end do
   write(*, *) trim(s)
end program ABC_072_B_OddString

Measured memory_bytes: 1596
# AOJ 0157: Russian Dolls
# Python3 2018.6.19 bal4u
#   単調増加シーケンスの最長値問題（LIS）

def LIS(hr):
	n = len(hr)
	lis = [0]*n
	lis[n-1] = 1;
	for i in range(n-2, -1, -1):
		m = 0;
		for j in range(i+1, n):
			if hr[i][0] < hr[j][0] and hr[i][1] < hr[j][1] and lis[j] > m: m = lis[j]
		lis[i] = m+1
	return lis[0]

while True:
	n = int(input())
	if n == 0: break
	hr = []
	for i in range(n):
		hr.append(list(map(int, input().split())))
	for i in range(int(input())):
		hr.append(list(map(int, input().split())))
	hr = list(sorted(hr))
	print(LIS(hr))



Measured memory_bytes: 5608
#include <stdio.h>

int vsub2( double *a, double *b, double *ab ) {

	ab[0] = b[0] - a[0];
	ab[1] = b[1] - a[1];

	return 0;

}

double vcross2( double *a, double *b ) {

	return a[0] * b[1] - b[0] * a[1];

}

int main( void ) {

	double a[2], b[2], c[2], p[2], ab[2], bc[2], ca[2], ap[2], bp[2], cp[2];

	while ( scanf( "%lf %lf %lf %lf %lf %lf %lf %lf", &a[0], &a[1], &b[0], &b[1], &c[0], &c[1], &p[0], &p[1] ) != EOF ) {

		vsub2( a, b, ab ); vsub2( b, c, bc ); vsub2( c, a, ca );
		vsub2( a, p, ap ); vsub2( b, p, bp ); vsub2( c, p, cp );

		if ( ( vcross2( ab, ap ) > 0 && vcross2( bc, bp ) > 0 && vcross2( ca, cp ) > 0 ) || ( vcross2( ab, ap ) < 0 && vcross2( bc, bp ) < 0 && vcross2( ca, cp ) < 0 ) ) {
			
			printf( "YES\n" );

		} else {

			printf( "NO\n" );

		}

	}

	return 0;

}

Measured memory_bytes: 612
def knapsack(items, num, weight):
    C = [0] * (weight + 1)
    for i in items:
        item_v, item_w = i
        for w in range(weight, 0, -1):
            if item_w <= w:
                v1 = item_v + C[w - item_w]
                v2 = C[w]
                C[w] = max(v1, v2)
    return C[weight]

import sys

file_input = sys.stdin

N, W = map(int, file_input.readline().split())

items = [map(int, line.split()) for line in file_input]

ans = knapsack(items, N, W)

print(ans)

Measured memory_bytes: 7968
L, R = map(int, input().split())
if R-L >= 2019:
    print(0)
else:
    ans = 2018**2
    for i in range(L, R):
        for j in range(i+1, R+1):
            mod2019 = i*j%2019
            if mod2019 < ans:
                ans = mod2019
    print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <map>

const float PI = 3.1415926;

using namespace std;
typedef long long ll;
typedef long double ld;

string W;
map<char, int> mp;

int main() {
  cin >> W;
  for(int i=0; i < W.size(); i++) {
    mp[W[i]] = 0;
  }
  for(int i=0; i < W.size(); i++) {
    mp[W[i]] += 1;
  }
  bool res = true;
  for(int i=0; i < W.size(); i++) {
    if(mp[W[i]] % 2 == 1) res = false;
  }
  if(res)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
const ll INF =  1LL << 60;
const int inf = 1 << 30;
int n, m, x, y;ll z, w, h, sum = 0, ans = 0;
int main(void) {
	cin >> n >> m;
	if (m % 2) {
		cout << "No" << endl;
		return 0;
	}
	if (m - 2 * n < 0 || (m - 2 * n) % 2) {
		cout << "No" << endl;
		return 0;
	}
	if ((m - 2 * n) / 2 > n) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 3632
fn main() {
    let s = read::<String>();
    let v: Vec<char> = s.chars().into_iter().collect();
    let n = v.len();

    let mut ret = 0;
    for i in 0..n/2 {
        if v[i] != v[n-1-i] {
            ret += 1;
        }
    }

    println!("{}", ret);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}


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

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> inputs(N);
    for(int i=0; i<N; i++){
        cin >> inputs.at(i);
    }
    sort(inputs.begin(), inputs.end());
    int ans = 0;
    for(int i=0; i<K; i++){
        ans += inputs.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3568
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    xl = sorted([LI() for _ in range(n)], key=lambda x: [sum(x), x])
    r = 0
    c = -inf
    for x,l in xl:
        if x-l >= c:
            r += 1
            c = x+l

    return r


print(main())





Measured memory_bytes: 43024
import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created 2017/06/01.
 */
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> ary = new ArrayList<>();

    while (true) {
      int input = Integer.parseInt(sc.next());
      ary.add(input);
      if (ary.size() == 3) break;
    }

    int a = ary.get(0);
    int b = ary.get(1);
    int c = ary.get(2);
    int ans = 0;

    for (int i = a; i <= b; i++) {
      if (c % i == 0) {
        ans++;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 26188
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
long long n,m,i,j,a[205],ans;
int main()
{
	scanf("%lld",&n);
	fz1(i,n+n){
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+n+n+1); 
	fz1(i,n)ans+=a[i+i-1];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt(); sc.nextLine();
    String S = sc.nextLine();
    String[] Sarray = S.split("");
    String before = "";
    int ans = 0;
    for (int i=0;i<N;i++){
      if (!before.equals(Sarray[i])){
        ans++;
      }
      before = Sarray[i];
    }
    System.out.println(ans);
  }
}

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

int main(){
    long long N,K;
    cin >> N >> K;
    vector<long long>H(N);
    for(int i = 0; i < N; i++) {
        cin >> H[i];
    }
    sort(H.begin(),H.end());
    if(N <= K) {
        cout << 0 << endl;
        return 0;
    }
    long long ans = 0;
    for(int i = 0; i < (N-K); i++) {
        ans+=H[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define int long long 
const int N=1e5+5;
const int INF=1e9+5;
vector<int> dp(N,INF);



int main(){
    int n;
    scanf("%d",&n);
  
    int a[n][3];
    int dp[n][3];
    for(int i=0;i<n;i++){
       for(int j=0;j<3;j++){
         cin>>a[i][j];
         dp[i][j]=0;
       }
    }
     
     dp[0][0]=a[0][0];
     dp[0][1]=a[0][1];
     dp[0][2]=a[0][2];

    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
               if(j!=k)
                 dp[i][j]=max(dp[i-1][k]+a[i][j],dp[i][j]);
            }
        }
    }   
  
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
  

return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
main(){
  string str;
  int res=0;
  while(cin >> str){
    string st = str;
    reverse(str.begin(),str.end());
    if(str == st) res++; 
  }
  cout << res << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  
  vector<vector<int>> connect(N, vector<int>());
  
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    connect.at(A - 1).push_back(B - 1);
    connect.at(B - 1).push_back(A - 1);
  }
  
  vector<bool> good(N, true);
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < connect.at(i).size(); j++) {
      if (H.at(i) <= H.at(connect.at(i).at(j))) {
        good.at(i) = false;
      }
    }
  }
  int count = 0;
          
  for (int i = 0; i < N; i++) {
    if (good.at(i)) {
      count++;
    }
  }
          
   cout << count << endl;
}

Measured memory_bytes: 8728
n,k=map(int,input().split())
p=list(map(int,input().split()))
def exp(x):
    return (x+1)*(1/2)
p2=[]
for i in range(n):
    p2.append(exp(p[i]))
sum=0
for i in range(k):
    sum+=p2[i]
max=sum
for j in range(n-k):
    sum-=p2[j]
    sum+=p2[j+k]
    if sum>max:
        max=sum
print(max)


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll N, M;
priority_queue<PL, vector<PL>, greater<PL>> p;

int main() {
    cin >> N >> M;
    REP(i, N) {
        LCIN(A, B);
        p.push({A, B});
    }
    ll sum = 0;
    while(M > 0) {
        ll val = p.top().first;
        ll num = p.top().second;
        p.pop();
        ll buy = min(num, M);
        M -= buy;
        sum += val * buy;
    }
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 2420
#include<stdio.h>
#include<math.h>
int main ( )
{
	int a,b,c,d;
	
	scanf("%d%d%d%d",&a,&b,&c,&d);
	
	if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))
	{
		printf("Yes\n");
	}
	
	
	
	else
	{
		printf("No\n");
	}
	
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


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


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

int main(void){
    long long int i, j, n, d, ans=0, po=0;
    scanf("%lld %lld", &n, &d);
    long long int x[n], y[n];
    for(i=0; i<n; i++) scanf("%lld %lld", &x[i], &y[i]);
//    for(i=0; i<n; i++) printf("%lld", x[i]*x[i]+y[i]*y[i]);
    for(i=0; i<n; i++) if(x[i]*x[i]+y[i]*y[i]<=d*d) ans++;
    printf("%lld", ans);
    
    
}

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

vector<long long>  prime(long long n){
    long long i ;
    vector<long long > ret;
    ret.push_back(1LL) ;
    for(i=2;i*i<=n;i++){
            if (n%i==0) {
        while(n%i==0){
            n/=i ;
        }
        ret.push_back(i) ;
    }
    }
    if (n>1)
        ret.push_back(n) ;
    return ret ;

}

int main() {
    long long a , b ,ans=0 ;
    cin >> a >> b ;

    vector<long long > pa , pb ;
    pa= prime(a) ;
    pb= prime(b) ;

    for(auto it :pa){
          //  auto x = pb.find(it) ;
            //cout << *x ;
        if (binary_search(pb.begin(),pb.end(),it) ) ++ans ;
    }
    cout << ans << endl ;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1000000007;
# define pi 3.141592
int b,c;
inline double f(double x){
	double v=(x*x+b*x+c)/sin(x);
	return v;
}
ll power(ll a,ll x){
    ll r=1;
    while(x!=0){
        if(x%2==1){
            r=r*a;
        }
        a=a*a;
        x=x/2;
    }
    return r;
}
int main() {
    
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
    	int n,m;cin>>n>>m;
    	int a[n]={0};
    	rep(i,n)a[i]=-1;
    	int flag=0;
    	rep(i,m){
    		int s,c;cin>>s>>c;s--;
    		if(a[s]==-1)a[s]=c;
    		else if(c!=a[s]){
    			flag=-1;
    		}
    	}
    	int ans=0;
    	if((a[0]==0&&n!=1)||flag==-1){
    		ans=-1;
    	}
    	else{
    		rep(i,n){
    			int x=a[i];if(x==-1)x=0;
    			if(i==0&&x==0&&n!=1)x=1;
    			// cout<<x<<endl;
    			ans=ans*10+x;
    		}
    	}
    	cout<<ans;
    } 	
    return 0;   
}	

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint unsigned long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++)
#define DUMP(ar) for(auto itd=begin(ar); itd != end(ar); itd++) cout << "["s << itd - begin(ar) << "]:"s << *itd << endl
#define DUMPL(ar) for(auto itd=begin(ar); itd != end(ar); itd++) { cout << *itd; if(end(ar)-itd > 1) cout << ' '; } cout << endl
#define COUT(x) cout << (x) << endl
#define VCIN(ar) for(auto &vcin: (ar)) cin >> vcin
#define ALL(ar) ar.begin(), ar.end()
#define LOOPD(i) cout << "ループ["s << i << "]回目---------------"s << endl
using namespace std;
// lint:64ビット 10^19

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

    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    VCIN(p);

    vector<lint> sum(n+1, 0);
    for(int i=1; i<n+1; i++){
        sum[i] = sum[i-1] + p[i-1];
    }
    
    double mmax = 0;
    int midx = 0;
    for(int i=0; i<n+1-k; i++){
        if(sum[i+k] - sum[i] > mmax){
            midx = i;
            mmax = sum[i+k] - sum[i];
        }
    }

    mmax = 0;
    for(int i=midx; i<midx+k; i++){
        mmax += 1.0 + (p[i]-1) * 0.5;
    }

    cout << fixed << setprecision(12) << mmax << endl;

    return 0;
}

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

int main(void) {
  string s;
  cin >> s;
  
  int a=0,b=0,c=0,small=1000,num=0;
  for (int i=0;i<s.size()-2;i++) {
    a = s[i]-'0';
    b = s[i+1]-'0';
    c = s[i+2]-'0';
    num = abs((100*a+10*b+c) - 753);
    small = min(small,num);
  }
  cout << small << endl;
  return 0;
}

Measured memory_bytes: 256
/* ex3_4
   Acro  */
 
#include <stdio.h> 
int main(void){
    int n,i;
    int ans = 1;
    scanf("%d",&n);
    for(i = 1; i < 10 ; i++){
        /* 1から9まで探索 */
        if(n % i == 0){
            /* 割り切れたとき */
            if(n/i < 10){
                /* 商が10より小さければYes */
                printf("Yes\n");
                ans = 0;
                break;
            }
        }
    }
    if(ans){
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
# 今回はもし組み合わせがあるとしたらa1=0である組み合わせが確実にある。
# なぜなら、a1, a2, a3をxだけ引いた分b1, b2, b3をxだけ足せばつじつまがあうから
if __name__ == "__main__":
    c1 = list(map(int, input().split()))
    c2 = list(map(int, input().split()))
    c3 = list(map(int, input().split()))
    c = [c1, c2, c3]
    a = [0, 0, 0]
    b = [c1[0], c1[1], c1[2]]
    a[1] = c2[1] - b[1]
    a[2] = c3[1] - b[1]
    flg = True
    for i in range(3):
        for j in range(3):
            flg = flg&(a[i]+b[j] == c[i][j])
    if flg:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin>>n;
  VEC<int>h(n);
  REP(i,0,n)cin>>h[i];
  int cnt=0;
  REP(i,0,n){

    bool all=true;
    REP(j,0,i){
      if(h[j]>h[i])all=0;
    }
    if(all)++cnt;
  }
  cout<<cnt<<endl;

  return 0;
}


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

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

  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (i * j == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3516
n = int(input())
alist = list(map(int, input().split()))

m = int(input())
blist = list(map(int, input().split()))

for a, b in zip(alist, blist):
    if a > b:
        print(0)
        exit()
    elif a < b:
        print(1)
        exit()

if len(alist) < len(blist):
    print(1)
else:
    print(0)



Measured memory_bytes: 5620
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int[] L = new int[N];
            for (int i = 0; i < N; i++) {
                L[i] = sc.nextInt();
            }

            int count = 0;
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    if (L[j] == L[i]) {
                        continue;
                    }

                    for (int k = j + 1; k < N; k++) {
                        if (L[k] == L[i] || L[k] == L[j]) {
                            continue;
                        }

                        int max = Math.max(L[i], Math.max(L[j], L[k]));
                        if (L[i] == max) {
                            if (L[j] + L[k] > max) {
                                count++;
                            }
                        }
                        if (L[j] == max) {
                            if (L[i] + L[k] > max) {
                                count++;
                            }
                        }
                        if (L[k] == max) {
                            if (L[i] + L[j] > max) {
                                count++;
                            }
                        }
                    }
                }
            }

            System.out.println(count);
        }
    }
}


Measured memory_bytes: 27532
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=26;
int S,n;
string s;
vi a,b;
vvi g;

void Add(int u,int v){
	g[u].push_back(v);
	g[v].push_back(u);
}

int dfs(int v){
	b[v]=1;
	int res=a[v];
	for(int i=0;i<g[v].size();i++){
		int u=g[v][i];
		if(!b[u]) res+=dfs(u);
	}
	return res;
}

int main(){
	cin>>s>>n;
	S=s.size();
	a=b=vi(S+1);
	g=vvi(S+1);
	for(int i=0;i<=S;i++){
		char c=(i<S?s[i]:'a'),c_=(i>0?s[i-1]:'a');
		a[i]=(c-c_+M)%M;
		if(i<(S+1)/2) Add(i,S-i);
	}
	for(int i=0;i<n;i++){
		int u,v;
		cin>>u>>v;
		Add(u-1,v);
	}
	bool B=1;
	for(int i=0;i<=S;i++) if(!b[i]&&dfs(i)%M!=0) B=0;
	cout<<(B?"YES":"NO")<<endl;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep1(i, n) for(ll i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  map<ll,ll> mp;
  rep(i,n) mp[a[i]] ++;
  ll sum = 0;
  for(auto p : mp){
    ll q = p.second;
    sum += q*(q-1)/2;
  }
  ll m = mp.size();
  rep(i,n){
    cout << sum - mp[a[i]] + 1 << endl;
  }
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if ((c - (a - b)) <= 0)
    pr(0);
  else
    pr(c - (a - b));
}


Measured memory_bytes: 3604
#include<stdio.h>
int main()
{
    int a[4],temp;
    for(int i=0;i<3;i++)
    scanf("%d",&a[i]);
    for(int i=0;i<3;i++)
    for(int j=0;j<3-i-1;j++)
    if(a[j]>a[j+1])
    {
        temp=a[j];
        a[j]=a[j+1];
        a[j+1]=temp;
    }
    for(int i=0;i<3;i++)
    {
        printf("%d",a[i]);
        if(i<2)
        printf(" ");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2108
#include <stdio.h>

int main(void) {
	int a,b,c,x;
	scanf("%d%d%d",&a,&b,&c,&x);
	if(b<a){
		x=a;
		a=b;
		b=x;	
	}if(c<b){
		x=b;
		b=c;
		c=x;	
	}if(b<a){
		x=a;
		a=b;
		b=x;	
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}



Measured memory_bytes: 2608
def function(n):
  string = str(n)
  for i in range(len(string) - 1):
    error = int(string[i]) - int(string[i + 1])
    if error > 1:
      return i + 1, error
    elif error < -1:
      return i, abs(error)
  return -1, 0
 
k = int(input())
ans = []
n = 1
while len(ans) < k:
  m, error = function(n)
  if m == -1:
    ans.append(n)
    n += 1
  else:
    n = n + (error - 1) * (10 ** (len(str(n)) - m - 1)) - n % (10 ** (len(str(n)) - m - 1))
print(ans[-1])

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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  reverse(h.begin(), h.end());

  bool high = false;
  rep(i, n-1){
    if(h[i]+1 == h[i+1]) h[i+1] -= 1;
    else if(h[i] < h[i+1]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


/*





















*/


Measured memory_bytes: 640
a = gets.chomp

h = {}
('a'..'z').each{|c|
  h[c] = 0
}

len = a.size

sum = 1 + len*(len-1)/2
a.each_char{|c|
  h[c] += 1
}
('a'..'z').each{|c|
  ct = h[c]
  sum -= ct*(ct-1)/2
}
p sum

Measured memory_bytes: 2300
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
string out[1010];
int n1[1010],n2[1010];
int main()
{
	int h,w,a,b;cin>>h>>w>>a>>b;
	rep(i,h) out[i]=string(w,'0');
	rep(i,h+1) rep(j,w+1){
		if(i*a+(h-i)*(w-a)!=j*b+(w-j)*(h-b)) continue;
		rep(k,h){
			if(k<i) n1[k]=a;else n1[k]=w-a;
		}
		rep(k,w){
			if(k<j) n2[k]=b;else n2[k]=h-b;
		}
		rep(k,h) rep(l,w){
			if(n1[k]>0 && n2[l]>0){
				out[k][l]='1';n1[k]--;n2[l]--;
			}
		}
		rep(k,h) cout<<out[k]<<endl;
		return 0;
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
ll a,b,c;
int main(){
	ios::sync_with_stdio(0);
	cin>>a>>b>>c;
	if(a+b>=c)
	cout<<"No";
	else{
		if(4*a*b<(c-a-b)*(c-a-b))
		cout<<"Yes";
		else
		cout<<"No";
	}
	re 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(true){
			int n = stdIn.nextInt();
			int m = stdIn.nextInt();
			if(n==0&&m==0){
				return;
			}
			
			int[] nt = new int[n];
			int[] mh = new int[m];
			int st = 0, sh = 0;
			for(int i=0;i<n;i++){
				nt[i] = stdIn.nextInt();
				st += nt[i];
			}
			for(int i=0;i<m;i++){
				mh[i] = stdIn.nextInt();
				sh += mh[i];
			}
			Arrays.sort(nt);
			Arrays.sort(mh);
			int ans = -1;
			int x=0, y=0;
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(st-nt[i]+mh[j]==sh-mh[j]+nt[i]){
						if(ans==-1||nt[i]+mh[j]<ans){
							ans = nt[i]+mh[j];
							x = nt[i];
							y = mh[j];
						}
					}
				}
			}
			if(ans==-1){
				System.out.println(ans);
			}
			else{
				System.out.println(x+" "+y);
			}
		}
	}
}

Measured memory_bytes: 12000
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int mod = 998244353;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i]; --A[i];
	}
	int ptr = -1;
	for (int i = 0; i < N; ++i) {
		if (A[(i + N - 1) % N] != 0 && A[i] == 0) {
			ptr = i;
		}
	}
	if (ptr == -1) {
		if (find(A.begin(), A.end(), 0) == A.end()) {
			cout << 0 << endl;
		}
		else {
			int fact = 1;
			for (int i = 1; i <= N; ++i) fact = (long long)(fact) * i % mod;
			cout << fact << endl;
		}
		return 0;
	}
	vector<int> shiftA(N);
	for (int i = 0; i < N; ++i) {
		shiftA[i] = A[(i + ptr) % N];
	}
	A = shiftA;
	vector<int> L(N, -1), R(N, -1);
	for (int i = 0; i < N; ++i) {
		if (L[A[i]] == -1) L[A[i]] = i;
		R[A[i]] = i;
	}
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		if (R[i] != -1) ++R[i];
		sum += R[i] - L[i];
	}
	if (sum != N || L[0] == -1) {
		cout << 0 << endl;
	}
	else {
		int len = R[0] - L[0];
		bool ok = true;
		vector<int> cand(N, -1); cand[0] = 0;
		int ans = 1;
		for (int i = N - 1; i >= 1 && ok; --i) {
			if (L[i] == -1) {
				continue;
			}
			if (R[i] - L[i] > len) {
				ok = false;
				break;
			}
			int ln = A[L[i] - 1], rn = A[R[i] % N];
			cand[(ln > i ? L[i] : R[i] - len)] = i;
			if (ln > i && rn > i) {
				if (R[i] - L[i] != len) ok = false;
			}
			if (ln < i && rn < i) {
				ans = (long long)(ans) * (len - (R[i] - L[i]) + 1) % mod;
			}
		}
		vector<int> lmax(N), rmax(N);
		for (int i = 1; i < N; ++i) lmax[i] = (cand[i] == -1 ? lmax[i - 1] : cand[i]);
		if (cand[N - 1] != -1) rmax[N - 1] = cand[N - 1];
		for (int i = N - 2; i >= 0; --i) rmax[i] = (cand[i] == -1 ? rmax[i + 1] : cand[i]);
		vector<int> hist(N);
		for (int i = 0; i < N; ++i) {
			if (cand[i] == -1) {
				++hist[max(lmax[i], rmax[i])];
			}
		}
		int unused = 0;
		for (int i = 0; i < N; ++i) {
			unused += hist[i];
			if (L[i] == -1) {
				if (unused == 0) {
					ok = false;
					break;
				}
				ans = (long long)(ans) * unused % mod;
				--unused;
			}
		}
		cout << (ok ? ans : 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
const int maxn=4e5+10,mod=998244353;
void plusle(int &a,int b){
    a+=b;if(a>=mod)a-=mod; return;
}
void minun(int &a,int b){
    a-=b; if(a<0)a+=mod; return;
}
int add(int a,int b) {
  a+=b;
  return a>=mod?a-mod:a;
}
int sub(int a,int b) {
  a-=b;
  return a<0?a+mod:a;
}
int mul(int a,int b) {
  return (int)((long long)a*b%mod);
}
struct BIT{
    vector<int> bit;
    int n;
    BIT(int _n){
            bit.resize(_n+5,0);
            n=_n+5;
    }
    void update(int idx,int val){
        for(;idx<n;idx+=(idx&(-idx)))
            bit[idx]+=val;
        return;
    }
    int get(int idx){
        int sum=0;
        for(;idx>0;idx-=(idx&(-idx)))
            sum+=bit[idx];
        return sum;
    }
    int get(int l,int r){
        return get(r)-get(l-1);
    }
};
struct pt{
    int x,y;
    pt():x(0),y(0){}
    void read(){
        scanf("%d%d",&x,&y);
    }
    bool operator <(const pt &a){
        return x==a.x?y<a.y:x<a.x;
    }
}p[maxn];
vector<int> ss,sss;
int ans,n;
int p2[maxn];

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        p[i].read();
        ss.push_back(p[i].x);
        sss.push_back(p[i].y);
    }
    ss.push_back((int)(-1e9-7));
    sss.push_back((int)(-1e9-7));
    sort(ss.begin(),ss.end());
    sort(sss.begin(),sss.end());
    ss.erase(unique(ss.begin(),ss.end()),ss.end());
    sss.erase(unique(sss.begin(),sss.end()),sss.end());
    for(int i=1;i<=n;i++){
        p[i].x=(int)(lower_bound(ss.begin(),ss.end(),p[i].x)-ss.begin());
        p[i].y=(int)(lower_bound(sss.begin(),sss.end(),p[i].y)-sss.begin());
    }
    p2[0]=1;
    for(int i=1;i<=n;i++){
        p2[i]=add(p2[i-1],p2[i-1]);
    }
    sort(p+1,p+1+n);
    int cur=0,u1,u2,d1,d2;
    BIT f1(n),f2(n);
    for(int i=1;i<=n;i++)
        f1.update(p[i].y,1);
    for(int i=1;i<=n;i++){
        int j=i,ct=0;
        while(p[j].x==p[i].x&&j<=n){
            f1.update(p[j].y,-1);
            ct++;
            j++;
        }
        j--;
        for(int k=i;k<=j;k++){
        u1=f1.get(p[k].y+1,n),u2=f2.get(p[k].y+1,n);
        d1=f1.get(p[k].y-1),d2=f2.get(p[k].y-1);
        plusle(ans,p2[n]-1);
        ///completely above
        cur = u1 + u2 + (j-k);
        minun(ans,p2[cur]-1);
        ///completely below
        cur = d1 + d2 + (k-i);
        minun(ans,p2[cur]-1);
        ///completely left
        minun(ans,p2[i-1]-1);
        ///completely right
        minun(ans,p2[n-j]-1);
        ///shitty four corners
        ///left-up
        plusle (ans,p2[u2]-1);
        ///left down
        plusle(ans,p2[d2]-1);
        ///right up
        plusle(ans,p2[u1]-1);
        ///right down
        plusle(ans,p2[d1]-1);
        }
        for(int k=i;k<=j;k++){
            f2.update(p[k].y,1);
        }
        i=j;
    }
    printf("%d\n",ans);
}

/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 7532
import sys
for line in sys.stdin.readlines():
    line=map(float,line.strip().split())
    x=line[0::2]
    y=line[1::2]
    if x[1]<x[2] or x[0]>x[3] or y[1]<y[2] or y[0] > y[3]:print "NO"
    else:print "YES"

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

main() {
    string S; cin >> S; int ans = 999999;
    for(int i=0;i<S.size()-2;i++){
        int a;
        a=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
        ans=min(ans,abs(a-753));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;




int main(){
  ll H;
  cin>>H;

  ll A[100000];
  A[0] = 1;
  
  ll h1 = 1;
  ll h2 = 2;

  ll n=0;

  for(int i=0;;i++){

    if(h1 <= H and H < h2) break;

    n++;
    h1 *= 2;
    h2 *=2;

    
  }







//cout<<99999<<endl;
  //cout<<n<<endl;

  ll ans = 0;

  for(int i=0;i<n;i++){

    A[i+1] = 2 * A[i] + 1;
    //cout<<A[i]<<endl;


  }

  cout<<A[n]<<endl;
  return 0;

 
   
 }


Measured memory_bytes: 256
n,t= map(int, input().split())
a= [list(map(int, input().split())) for i in range(n)]


# dp[i][j]: i番目の料理まで見て時間がjの時の満足度のMAX
dpA=[[0]*t for i in range(n+1)]
# dp[i][j]: n-i番目の料理まで見て時間がjのときの満足度のMAX
dpB=[[0]*t for i in range(n+1)]

for i in range(n):
    for j in range(t):
        if a[i][0]>j:
            dpA[i+1][j]=dpA[i][j]
        else:
            dpA[i+1][j]=max(dpA[i][j-a[i][0]]+a[i][1],dpA[i][j])

for i in range(n):
    for j in range(t):
        if a[n-i-1][0]>j:
            dpB[n-i-1][j]=dpB[n-i][j]
        else:
            dpB[n-i-1][j]=max(dpB[n-i][j-a[n-i-1][0]]+a[n-i-1][1],dpB[n-i][j])

ans=0

for i in range(n):
    for j in range(t):
        ans=max(dpA[i][j]+dpB[i+1][t-j-1]+a[i][1],ans)
print(ans)

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

int n,a[100001];
long long ans;
int main()
{
	cin>>n;
    for(int i=0;i<n;i++)
    	cin>>a[i];
    for(int i=0;i<n;i++)
    {
        ans+=a[i]/2;
        a[i]%=2;
        if(a[i]&&a[i+1])
            ans++,a[i]--,a[i+1]--;
	}
    cout<<ans;
    return 0;
}

Measured memory_bytes: 640
using namespace std;
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void solve()
{
int a,l,r;
cin>>l>>r>>a;
int n=a;
int ans=0;
while (a<=r)
{
    if(a>=l&&a<=r)
    {
    ans++;
    }
    a=a+n;
}
cout<<ans<<endl;
}
int main()
{

FASTIO
 long long int t;
 t=1;
 while(t--)
  solve();
  return 0;
}


Measured memory_bytes: 3660
N, M, Q = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(Q)]


def dfs(x):
    if len(x) == N + 1:
        res = 0
        for a, b, c, d in X:
            if x[b] - x[a] == c:
                res += d
        return res

    res = 0
    for n in range(x[-1], M + 1):
        x.append(n)
        res = max(res, dfs(x))
        x.pop()
    return res


print(dfs([1]))


Measured memory_bytes: 73924
#include <bits/stdc++.h>
 
using namespace std;
using LL = long long int; 

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
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 DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAXN = 5e5;

int main() {
  int k;
  cin >> k;
  priority_queue<LL> q;
  for (int i = 1; i <= 9; ++i) {
    q.push(-i);
  }
  int cnt = 0;

  while (!q.empty()) {
    cnt++;
    auto s = -q.top();
    q.pop();
    // debug(s);
    if (cnt == k) {
      cout << s << endl;
      return 0;
    }

    LL last = s % 10;
    if (last != 0) {
      q.push(-(s * 10LL + last - 1LL));
    }

    if (last != 9) {
      q.push(-(s * 10 + last + 1LL));
    }

    q.push(-(s * 10 + last));
  }
}


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

typedef signed long long ll;
typedef long double ld;

#define MAX (int)1e9

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) x.begin(),x.end()

#define DEBUG

int main()
{
	vector<int> v;
	int ans = MAX;

	int s;
	rep(i,3)
	{
		cin >> s;
		v.push_back(s);
	}
	sort(all(v));
	ans = v[0] + v[1];

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


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

int main() {
	int n, k; cin >> n >> k;
	int ans = 1;
	for (int i = 0; i < n; i++) {
		if (ans + k > ans * 2)ans *= 2;
		else ans += k;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vector<long double> a(n);
  rep(i,n)cin >> a[i];
  long double x = 0;
  priority_queue<long double> q;
  rep(i,n)q.push(-a[i]);
  while(sz(q)>1){
    long double a = -q.top();
    q.pop();
    long double b = -q.top();
    q.pop();
    q.push(-((a+b)/2));
  }
  printf("%.10Lf\n",-q.top());
  return 0;
}

Measured memory_bytes: 3808